In Big/complex applications, it is essential to call Sub-programs (Procedures/Functions) from other sub-programs. In that case it will be difficult to trace out Errors/Exceptions from where it is raised i.e. which sub-program caused the exception. Normally we can use SQLCODE and SQLERRM to get the error/exception, but these may not work in the above case. For this issue, Oracle has defined FORMAT_ERROR_BACKTRACE in DBMS_UTILITY package.
This function displays the call stack at the point where an exception was raised, even if the subprogram is called from an exception handler in an outer scope. The output is similar to the output of the SQLERRM function, but not subject to the same size limitation.
How to use: