Monthly Archives: November 2015

PL/SQL: What exactly to log when exception is raised

To catch the exact error message and the line that raised it insert the following into your log table.

trim( DBMS_UTILITY.FORMAT_ERROR_BACKTRACE ) 
    || chr(13) || chr(10) || trim( DBMS_UTILITY.FORMAT_CALL_STACK )  
    || chr(13) || chr(10) || trim( DBMS_UTILITY.FORMAT_ERROR_STACK )

It will help you to determine the culprit even if an exception was thrown from anonymous block inside dynamic call.