PL/SQL Trace Back Error

Since the first release of Oracle 10g, it’s possible to trace back pl/sql errors in case of exceptions using dbms_utility.format_error_backtrace.


SQL> set serverout on

SQL> declare
2     i number;
3  begin
4     select 100/0 into i from dual;
5  exception
6     when others then
7       dbms_output.put_line(sqlerrm);
8       dbms_output.put_line(dbms_utility.format_error_backtrace);
9  end;
10  /
ORA-01476: divisor is equal to zero
ORA-06512: at line 4


PL/SQL procedure successfully completed.

as you see, dbms_utility.format_error_backtrace shows the error occurs at line 4 but we need sqlerrm to report error message.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: