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!

DBMS_UTILITY.FORMAT_ERROR_BACKTRACE returns wrong line number

xxsawerMay 28 2019 — edited May 28 2019

Hi All,

I am using function DBMS_UTILITY.FORMAT_ERROR_BACKTRACE to track on which line we raised an exception. However it seems when there is more than one occurance of raising the same exception then Oracle takes always the 1st occurance as the position where the exception was raised.

1  DECLARE

2    e_Exception    EXCEPTION;

3    vbo_Raise      BOOLEAN;

4  BEGIN

5     DBMS_OUTPUT.PUT_LINE('------ 1 ------');

6     vbo_Raise := False;

7     IF vbo_Raise THEN

8        RAISE e_Exception;

9     END IF;

10    DBMS_OUTPUT.PUT_LINE('------ 2 ------');

11    vbo_Raise := True;

12    IF vbo_Raise THEN

13       RAISE e_Exception;

14    END IF;

15 EXCEPTION

16    WHEN OTHERS THEN

17       DBMS_OUTPUT.PUT_LINE(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);

18 END;

19 /

Output:

------ 1 ------

------ 2 ------

ORA-06512: at line 8

From the output it is clear that the exception was not raised at line 8.

I have tested this on different Oracle versions 10 - 12.2 locally over sqlplus

I still have SQL Developer version 3.2.20 installed and interesting is that when I run the script above in this version of Developer then it returns correct results again in different versions of DB. Newer versions of SQL Developer return wrong results...

This post has been answered by Anton Scheffer on May 28 2019
Jump to Answer
Comments
Post Details
Added on May 28 2019
5 comments
3,020 views