Oracle8i Supplied Packages Reference Release 8.1.5 A68001-01 |
|
Oracle8i PL/SQL provides an API for tracing the execution of PL/SQL programs on the server. You can use the Trace API, implemented on the server as the DBMS_TRACE
package, to trace PL/SQL functions, procedures, and exceptions.
DBMS_TRACE
provides subprograms to start and stop PL/SQL tracing in a session. The trace data gets collected as the program executes, and it is written out to the Oracle Server trace file.
A typical session involves:
DBMS_TRACE
.SET_PLSQL_TRACE
).
DBMS_TRACE
.CLEAR_PLSQL_TRACE
).
This package must be created under SYS
.
You cannot use PL/SQL tracing with the multi-threaded server (MTS).
trace_all_calls constant INTEGER := 1; trace_enabled_calls constant INTEGER := 2; trace_all_exceptions constant INTEGER := 4; trace_enabled_exceptions constant INTEGER := 8; /* * The version of the trace package. These constants will change as the * package evolves. Use the PLSQL_TRACE_VERSION procedure (described below) * to get the current version of the package. */ trace_major_version constant BINARY_INTEGER := 1; trace_minor_version constant BINARY_INTEGER := 0;
Profiling large applications may produce a huge volume of data. You can control the volume of data collected by enabling specific program units for trace data collection.
You can enable a program unit by compiling it debug. This can be done in one of two ways:
alter session set plsql_debug=true; create or replace ... /* create the library units - debug information will be generated */
or:
/* recompile specific library unit with debug option */ alter [PROCEDURE | FUNCTION | PACKAGE BODY] <libunit-name> compile debug;
Two levels of call tracing are available:
trace_all_calls
.
trace_enabled_calls
.
Enabling cannot be detected for remote procedure calls (RPCs); hence, RPCs are only traced with level 1.
Two levels of exception tracing are available:
trace_all_exceptions
.
trace_enabled_exceptions
.
If tracing is requested only for enabled program units, and if the current program unit is not enabled, then no trace data is written.
If the current program unit is enabled, then call tracing writes out the program unit type, name, and stack depth.
If the current program unit is not enabled, then call tracing writes out the program unit type, line number, and the stack depth.
Exception tracing writes out the line number. Raising the exception shows information on whether the exception is user-defined or pre-defined and the exception number, in the case of pre-defined exceptions.
Subprogram | Description |
---|---|
SET_PLSQL_TRACE procedure |
Starts tracing in the current session. |
CLEAR_PLSQL_TRACE procedure |
Stops trace data dumping in session. |
PLSQL_TRACE_VERSION procedure |
Gets the version number of the trace package. |
This procedure enables PL/SQL trace data collection.
DBMS_TRACE.SET_PLSQL_TRACE ( trace_level INTEGER);
Parameter | Description |
---|---|
trace_level |
This must be one of the constants See "Collecting Trace Data" for more information. |
This procedure disables trace data collection.
DBMS_TRACE.CLEAR_PLSQL_TRACE;
None.
This procedure gets the version number of the trace package. It returns the major and minor version number of the DBMS_TRACE
package.
DBMS_TRACE.PLSQL_TRACE_VERSION ( major OUT BINARY_INTEGER, minor OUT BINARY_INTEGER);
Parameter | Description |
---|---|
major |
Major version number of |
minor |
Minor version number of |