RE: PLSQL exception handling

  • From: "Goulet, Richard" <Richard.Goulet@xxxxxxxxxxx>
  • To: <peter.schauss@xxxxxxx>, <oracle-l@xxxxxxxxxxxxx>
  • Date: Tue, 14 Jun 2011 10:51:13 -0400

Peter,

        You might want to try dbms_utility.format_error_backtrace as
follows:

declare a integer;
begin
   a := 'ABC';
exception when others then
dbms_output.put_line(DBMS_UTILITY.format_error_backtrace);
end;
/
ORA-06512: at line 3


PL/SQL procedure successfully completed.

Richard Goulet
Senior Oracle DBA/Na Team Leader

-----Original Message-----
From: oracle-l-bounce@xxxxxxxxxxxxx
[mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of Schauss, Peter (ESS)
Sent: Thursday, June 09, 2011 3:13 PM
To: oracle-l@xxxxxxxxxxxxx
Subject: PLSQL exception handling

Oracle 11.2.0.1.0 (Linux x86-64).

I am writing stored procedure which copies information from one table to
another, doing some transformations in the process.  I am using the
%rowtype construct for the fetches and inserts and doing a large number
of assignment statements in the form:

rec1.col1 := rec2.cola;

Since there is a possibility of type conversion errors in some cases, I
need to be able to trap errors and identify the offending column in the
input table.  The Oracle documentation suggests something like this:

step_num:= <n>
rec1.col1 := rec2.cola;
step_num:=<n+1>
rec1.col2 :=rec2.colb;

exception
        when <error type> dbms_output.put_line('error at '||step_num);
        raise;
end;

Is there a better way for me to identify the location of the error?

Thanks,
Peter Schauss
--
//www.freelists.org/webpage/oracle-l


--
//www.freelists.org/webpage/oracle-l


Other related posts: