Documentación de Invantiveparte de Invantive Cloud
Foros de Soporte de InvantiveIniciar Sesión / Registrarse

SQLERRM

Sintaxis

%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> SQLERRM[SQLERRM]:::quoted
    SQLERRM --> End((END))

Propósito

La función SQL SQLERRM obtiene el mensaje de error del último error SQL que se produjo durante la ejecución. La función se puede utilizar sin paréntesis.

Véanse también SQLCODE y SQLROWCOUNT.

Devuelve: el mensaje de error del último error como varchar2. Devuelve null cuando no se ha producido ningún error.

Ejemplos

El siguiente ejemplo recupera el mensaje de error del último error; la salida está vacía, ya que no se ha producido ningún error:

select sqlerrm

-------------------

En el siguiente ejemplo se genera primero un error de división por cero y, a continuación, se recupera el mensaje de error del último error:

select 1 / 0

itgenttn082: Division of 1 by zero is impossible.
select sqlerrm

--------------------------------------------------
itgenttn082: Division of 1 by zero is impossible.

El siguiente ejemplo detecta un error de división por cero y genera un nuevo error de aplicación con el mensaje de error proporcionado por SQLERRM:

declare
  x pls_integer;
begin
  x := 1 / 0;
exception
  when others
  then
    raise_application_error('sample', sqlerrm);
end;

sample: itgenttn082: Division of 1 by zero is impossible.