When we explicitly RAISE an error, it looks like the CALL STACK is removed from the errror message. Why does that happen? Here's a simple example of what I'm seeing:
SQL> create or replace procedure proc2
2 is
3 v number;
4 begin
5 v := 1/0;
6 end;
7 /
Procedure created.
SQL> create or replace procedure proc1
2 is
3 begin
4 proc2();
5 end;
6 /
Procedure created.
SQL> exec proc1();
BEGIN proc1(); END;
*
ERROR at line 1:
ORA-01476: divisor is equal to zero
ORA-06512: at "XRFOR.PROC2", line 5
ORA-06512: at "XRFOR.PROC1", line 4
ORA-06512: at line 1
This is what I like. I can see that the error occured in PROC2 in this case. But if I put an EXCEPTION HANDLER in PROC1, I lose that information:
SQL> create or replace procedure proc1
2 is
3 begin
4 proc2();
5 exception when others then
6 raise;
7 end;
8 /
Procedure created.
SQL> exec proc1();
BEGIN proc1(); END;
*
ERROR at line 1:
ORA-01476: divisor is equal to zero
ORA-06512: at "XRFOR.PROC1", line 6
ORA-06512: at line 1
I'm left erroneously thinking that the error came out of PROC1. I'm not sure why, but I've never noticed this before. How do I intervene in an EXCEPTION HANDLER (to write the error to a log) without losing the contents of the stack in the error message?
Thanks,
--=Chuck