Ver Mensaje Individual
  #5 (permalink)  
Antiguo 15/10/2010, 05:17
jc3000
 
Fecha de Ingreso: junio-2007
Mensajes: 891
Antigüedad: 16 años, 11 meses
Puntos: 43
Respuesta: Capturar mens. de error de excepciones no predefinidas

Eso si no recuerdo mal ya existia en la 7.3 .

No tienes que complicarte la vida, con que uses el WHEN OTHERS te vale. En cuanto haya algún castañazo se te va a ir por el when others y ahí ya capturas el sqlerrm.

Mira :

SQL> CREATE TABLE KKFUTIS (CAMPO1 CHAR(10));

Tabla creada.

SQL> set serveroutput on

SQL> begin
2 declare
3 error1 varchar(199);
4 error2 varchar(199);
5 begin
6 INSERT INTO KKFUTIS (CAMPO1) VALUES ('ALGOMASGRANDEDE10');
7 exception
8 when OTHERS then
9 error1 := sqlerrm;
10 error2 := to_char(sqlcode);
11 dbms_output.put_line(error1);
12 dbms_output.put_line(error2);
13 end;
14 end;
15
16 /

ORA-12899: value too large for column "user"."KKFUTIS"."CAMPO1" (actual: 17, maximum: 10)
-12899


Procedimiento PL/SQL terminado con éxito.


SQL> ed
Escrito fichero afiedt.buf

1 begin
2 declare
3 error1 varchar(199);
4 error2 varchar(199);
5 begin
6 INSERT INTO KKFUTIS (CAMPO1) VALUES (1/0);
7 exception
8 when OTHERS then
9 error1 := sqlerrm;
10 error2 := to_char(sqlcode);
11 dbms_output.put_line(error1);
12 dbms_output.put_line(error2);
13 end;
14* end;
15 /
ORA-01476: divisor is equal to zero
-1476

Procedimiento PL/SQL terminado con éxito.

SQL>