3 Replies Latest reply on Feb 27, 2010 2:30 PM by Solomon Yakobson

    Get line number error

    muttleychess
      Hi

      Is there some way to get line number error when there is some exception ?

      I use oracle 9.2.02
      thank you in advance
        • 1. Re: Get line number error
          When you don't trap the exception you will get a line number, of the line in error.
          When you trap the exception you need to use dbms_utility.format_error_stack.
          Thid will not provide correct line numbers. This issue has been resolved in 10g or 11g, and 9iR2 is going completely out of support in July.

          -----------
          Sybrand Bakker
          Senikor Oracle DBA
          • 2. Re: Get line number error
            Solomon Yakobson
            Not in 9.2, AFAIK. DBMS_UTILITY.FORMAT_ERROR_BACKTRACE was introduced in 10g.

            SY.
            • 3. Re: Get line number error
              Solomon Yakobson
              sybrand_b wrote:
              When you trap the exception you need to use dbms_utility.format_error_stack.
              Thid will not provide correct line numbers. This issue has been resolved in 10g or 11g, and 9iR2 is going completely out of support in July.
              FORMAT_ERROR_STACK will not provide any line numbers:
              SQL> select * from v$version
                2  /
              
              BANNER
              --------------------------------------------------------------------------------
              Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
              PL/SQL Release 11.1.0.6.0 - Production
              CORE    11.1.0.6.0      Production
              TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
              NLSRTL Version 11.1.0.6.0 - Production
              
              SQL> set serveroutput on format word_wrapped
              SQL> begin
                2      raise no_data_found;
                3    exception
                4      when no_data_found
                5        then
                6          dbms_output.put_line('ERROR_STACK: ' || DBMS_UTILITY.FORMAT_ERROR_STACK);
                7          dbms_output.put_line('ERROR_BACKTRACE: ' || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
                8  end;
                9  /
              ERROR_STACK: ORA-01403: no data found
              
              ERROR_BACKTRACE: ORA-06512: at line 2
              
              
              PL/SQL procedure successfully completed.
              
              SQL>  
              SY.