Oracle has provided ways to dump errorstack to a trace file.
ErrorStack can be classified into 4 levels:
0 : Error stack only
1 " Error stack and function call stack
2 : As level 1 + the process state
3 : As level 2 + the context area (display all cursors)
To dump an error stack use the following syntax:
alter session set events 'immediate trace name errorstack level 3';
or
SQL> oradebug setmypid; -- debug current process
SQL> oradebug dump errorstack 3
SQL> oradebug close_trace; -- close trace file
For more information regarding ORADEBUG command, type:
SQL> oradebug help
For Example:
To dump a level 3 errorstack when facing ORA-00942 (table or view does not exist) , use :
SQL> alter session set events '942 trace name errorstack level 3';
or
SQL> alter system set events '942 trace name errorstack level 3';
event = "942 trace name errorstack level 3"
To turn off the error stack tracing, use:
SQL> alter system set events '942 trace name errorstack off';