|
Home
: A Trace Procedure For
Oracle Revision Notes July
24, 2001 - Document Created
Downloads/Links
Overview
One of the problems with tracing a process associated with
an application is that the process is frequently spawned on the server or
middle tier. The SID and SERIAL# associated with the job are not the
same as the user who requested the job. This can make it very
difficult to quickly identify the session you want to trace. This
script solves the problem for you. When run it will set SQL_TRACE to
TRUE on all new sessions since the time you initialized the
procedure. Then you will be sure you are capturing the trace file
for the session associated with the job. The procedure accepts three
possible values for it's single parameter. SET -
Initializes the procedure by grabbing the max logon time from V$SESSION
and stores it in a table. Also sets SQL_TRACE to false for any
existing sessions that are being traced by this procedure. START
- Sets SQL_TRACE = TRUE for all sessions that have a logon time after the
stored logon time. STOP - Sets SQL_TRACE to false for any
existing sessions that are being traced by this procedure.
| EXAMPLE:
SQL> set serveroutput on
SQL> exec trace('SET');
PL/SQL procedure successfully completed.
SQL> exec trace('START');
Tracing session 7
Tracing session 26
PL/SQL procedure successfully completed.
SQL> exec trace('STOP');
PL/SQL procedure successfully completed. |
You can now check your user dump destination for the
expected trace files. Cut and paste the code into a .sql
file and run it on you system. Make sure you log in as SYS and grant
execute permissions on the DBMS_SYSTEM package to the user before you run
the script. You will also need access to the V$SESSION view. |