Where Did My PL/SQL Error?

When your PL/SQL block errors, it has always been a rudimentary task in identifying the error generated using a combination of SQLCODE and SQLERRM.

These 2 functions however do not tell us the exact line of code that propagated the error. This feature would be very handy when debugging code.

In Oracle 10g, there is a function called: DBMS_UTILITY.format_error_backtrace

This will return the line number that generated the error. It does not tell us what the SQL Error message is so I use it in conjunction with SQLERRM to quickly debug problematic code.

In a recent application, I used it as part of my error logging and reporting function that allows the support team to quickly troubleshoot errors. The more information about the error we can give them, the quicker they should be able to response. At least that’s the theory.

For a more detailed explanation of how to best utilise this function, have a look at this atricle

Comments

Anonymous said…
Hi Duncan,
You're right, this has long been a bugbear of mine. Good spot, I'll certainly be using this in the future.

Mike
Anonymous said…
Very handy, nice one.

Andy

Popular posts from this blog

Custom Authentication / Authorisation Schemes (Part 1)

Custom Error Handling in APEX

Sum to Parent Nodes in Hierarchy Queries: CONNECT_BY_ROOT