Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

"raise" and stack trace

Avi AbramiJul 9 2007 — edited Jul 9 2007

Greetings,
When re-raising an exception, the error stack is lost.
I am using Oracle Database 10g Release 10.1.0.4.0 - 64bit Production on Red Hat Enterprise Linux ES release 4 (Nahant Update 1)
Consider the following code:

SQL> declare
  2    L_DUMMY  char(1);
  3  --
  4    procedure P
  5    is
  6    begin
  7      select 'X' into L_DUMMY from DUAL where 1 = 0;
  8    end;
  9  begin
 10    P;
 11* end;
 12  /
declare
*
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at line 7
ORA-06512: at line 10

When I add an exception handler to above code and use "raise" to re-raise the exception, the stack trace is lost, as shown below:

SQL> declare
  2    L_DUMMY  char(1);
  3  --
  4    procedure P
  5    is
  6    begin
  7      select 'X' into L_DUMMY from DUAL where 1 = 0;
  8    end P;
  9  begin
 10    P;
 11  exception
 12    when others then
 13      raise;
 14  end;
 15  /
declare
*
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at line 13

Is there some way to keep the stack trace when re-raising an error?

Thanks,
Avi.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 6 2007
Added on Jul 9 2007
6 comments
1,316 views