RE: PLSQL exception handling
Date: Tue, 14 Jun 2011 10:51:13 -0400
Message-ID: <6B0D50B70F12BD41B5A67F14F5AA887F115BDFFA_at_us-bos-mx022.na.pxl.int>
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_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Schauss, Peter (ESS)
Sent: Thursday, June 09, 2011 3:13 PM
To: oracle-l_at_freelists.org
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
--
http://www.freelists.org/webpage/oracle-l
--
http://www.freelists.org/webpage/oracle-l
Received on Tue Jun 14 2011 - 09:51:13 CDT