Hi,
I would ask, how can I find the line number of the root error in PL/SQL (or the "whole error stack")? Here is an example, what I mean:
SQL> set serveroutput on
SQL> begin
2 begin
3 dbms_output.put_line(1/0);
4 exception when others then
5 dbms_output.put_line('handle the error locally');
6 raise_application_error(-20501,'anything',keeperrorstack=>true);
7 end;
8 exception when others then
9 dbms_output.put_line(dbms_utility.format_error_backtrace);
10 dbms_output.put_line(dbms_utility.format_error_stack);
11 dbms_output.put_line('how can I retrieve the root error line here?');
12 end;
13 /
handle the error locally
ORA-06512: at line 6
ORA-20501: anything
ORA-01476: divisor is equal to zero
how can I retrieve the root error line here?
PL/SQL procedure successfully completed.
SQL>
As you see the line "3" does not appear in the output. How can I find that the line of the root error was "3", without storing it directly during the first error handling (in line "5", "6")? Can I change the line "6" to preserve the orig error stack, without storing the orig error stack manually? The line "6" (with keeperrorstack=>true) or the simple"raise;" preserves the root error code, but not the root error stack. I know, that I can change the literal "anything" to "dbms_utility.format_error_backtrace" in line "6", or I can change the line "5" to store the orig errorstack in a table (in autonomous trx). I know the dbms_trace too. But is there a more automatic and simplier solution?
Thx: lados.