As much as I like coding in PL\SQL I always hated those exceptions in the code. Whenever the code fails all I get is the line number of the error on the last exception section of the code and finding out on which line the error really occured would invlove removing the exception block which sometimes is really wacky when
the process invloves calling multiple program units.
But today I came across this new utility in 10g DBMS_UTILITY.FORMAT_ERROR_BACKTRACE which can be used to trace the line numbers of all the programs in which the error occured.
I am really ashamed of myself for not knowing it this long. 10g was released long back and 11g is also soon becoming matured enough for many applications to be upgraded to it. But I am glad I learned about it neverthless. I guess its high time I read the new features document.
Example Code:
--------------
declare
l_emp_id number(10);
begin
select EMPNO
into l_emp_id
from emp
where 1=2;
exception when no_data_found then
dbms_output.put_line('sqlcode-->'sqlcode);
dbms_output.put_line('DBMS_UTILITY.FORMAT_ERROR_BACKTRACE-->'DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
end;
/
No comments:
Post a Comment