ACE Director Alum Daniel Morgan, founder of Morgan's Library, is scheduling
complimentary technical Workshops on Database Security for the first 30
Oracle Database customers located anywhere in North America, EMEA, LATAM, or
APAC that send an email to
asra_us@oracle.com. Request a Workshop for
your organization today.
Purpose
Provides an interface to provide information about currently executing subprograms. Functions return subprogram names, unit names, owner names, edition names, and line numbers for given dynamic depths.
Other functions return error stack information.
AUTHID
DEFINER
Data Types
TYPE UNIT_QUALIFIED_NAME IS VARRAY(256) OF VARCHAR2(32767);
Dependencies
DBMS_REDEFINITION
DBMS_SWAT_VER_INTERNAL
SDO_RDF_INTERNAL
DBMS_SWAT_ARM_INTERNAL
DRIUTL
UTL_TCP
DBMS_SWAT_MM_UTILS
PLITBLM
Documented
Yes
Exceptions
Error Code
Reason
ORA-64610
BAD_DEPTH_INDICATOR: This exception is raised when a provided depth is out of bounds. Dynamic and lexical depth are positive integer values.
Error and backtrace depths are non-negative integer values and are zero only in the absence of an exception.
Returns the name of the edition in which the unit of the subprogram at the specified dynamic depth is actual
utl_call_stack.actual_edition(dynamic_depth IN PLS_INTEGER)
RETURN VARCHAR2;
SQL> show edition
EDITION
------------------------------
ORA$BASEXX
SQL> SELECT utl_call_stack.actual_edition(1)
2 FROM dual;
SELECT utl_call_stack.actual_edition(1)
*
ERROR at line 1:
ORA-64610: bad depth indicator
ORA-06512: at "SYS.UTL_CALL_STACK", line 88
SQL> SELECT utl_call_stack.actual_edition(0)
2 FROM dual; 2
SELECT utl_call_stack.actual_edition(0)
*
ERROR at line 1:
ORA-64610: bad depth indicator
ORA-06512: at "SYS.UTL_CALL_STACK", line 86
SQL> BEGIN
2 dbms_output.put_line(utl_call_stack.actual_edition(1));
3 END;
4 / PL/SQL procedure successfully completed.
-- no exception is raised but does not output the edition name.
Returns the current edition name of the unit of the subprogram at the specified dynamic depth
Deprecated: Replace with ACTUAL_EDITION
utl_call_stack.current_edition(dynamic_depth IN PLS_INTEGER) RETURN VARCHAR2;
CREATE OR REPLACE PROCEDURE utc_current_edition AUTHID CURRENT_USER IS
BEGIN
dbms_output.put_line(utl_call_stack.current_edition(1));
END utc_current_edition;
/
exec utc_current_edition;
PL/SQL procedure successfully completed.
-- this function returned no values in Beta and does not do so now
-- we have SR opened that confirmed the issue and opened bug 17061888
Returns the unit-qualified name of the subprogram at the specified dynamic depth
utl_call_stack.subprogram(dynamic_depth IN PLS_INTEGER) RETURN unit_qualified_name;
CREATE OR REPLACE FUNCTION utc_testfunc RETURN BOOLEAN AUTHID DEFINER IS
uqn utl_call_stack.unit_qualified_name;
BEGIN
uqn := utl_call_stack.subprogram(utl_call_stack.dynamic_depth);
dbms_output.put_line('2nd Level: ' || TO_CHAR(uqn.COUNT));
dbms_output.put_line(uqn(1));
dbms_output.put_line('Concat SubProg: ' || utl_call_stack.concatenate_subprogram(uqn));
dbms_output.put_line('Line Number 2: ' || utl_call_stack.unit_line(utl_call_stack.dynamic_depth));
RETURN TRUE;
END utc_testfunc;
/
CREATE OR REPLACE PROCEDURE utc_subprogram AUTHID CURRENT_USER IS
uqn utl_call_stack.unit_qualified_name;
b BOOLEAN;
BEGIN
uqn := utl_call_stack.subprogram(utl_call_stack.dynamic_depth);
dbms_output.put_line('Top Level: ' || TO_CHAR(uqn.COUNT));
b := utc_testfunc;
dbms_output.put_line(uqn(1));
dbms_output.put_line('Line Number 1: ' || utl_call_stack.unit_line(utl_call_stack.dynamic_depth));
END utc_subprogram;
/
exec utc_subprogram;
SQL> exec utc_subprogram; Top Level: 1
2nd Level: 1
__anonymous_block
Concat SubProg: __anonymous_block
Line Number 2: 1
__anonymous_block
Line Number 1: 1
CREATE OR REPLACE PACKAGE utc_pkg AUTHID CURRENT_USER IS
uqn utl_call_stack.unit_qualified_name;
PROCEDURE top_proc;
PROCEDURE down_level;
END utc_pkg;
/
CREATE OR REPLACE PACKAGE BODY utc_pkg IS
PROCEDURE top_proc IS
BEGIN
utc_subprogram;
utc_pkg.down_level;
END top_proc;
PROCEDURE down_level IS
BEGIN
NULL;
EXCEPTION WHEN OTHERS THEN
dbms_output.put_line('Backtrace Unit: ' || utl_call_stack.backtrace_unit(0));
END down_level;
END utc_pkg;
/
SQL> exec utc_pkg.top_proc; Top Level: 1
2nd Level: 1
__anonymous_block
Concat SubProg: __anonymous_block
Line Number 2: 1
__anonymous_block
Line Number 1: 1
Returns the type of the unit of the subprogram at the specified dynamic depth.
utl_call_stack.unit_type(dynamic_depth IN PLS_INTEGER) RETURN VARCHAR2;
SQL> BEGIN
2 dbms_output.put_line(utl_call_stack.unit_type(1));
3 END;
4 / ANONYMOUS BLOCK
PL/SQL procedure successfully completed.
-- Evaluated by comparing with OWA_UTIL.WHO_CALLED_ME that has been in Oracle since
-- version 8.1.7. We are not especially impressed. They should have just enhanced the
-- existing functionality with a new overload.
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
owa_util.who_called_me(vSchemaName, vPkgName, vLineNumber, vObjType);
IF dbms_utility.is_cluster_database THEN
dbms_utility.active_instances(vInstTab, vInstCount);
END IF;
-- this recovers the physical CPUs and the resource mgr plan count
dbms_wlm.get_cpu_count(cpu_phys, plan_count);
FOR i IN 1 .. cTraceDepth LOOP
INSERT /* mlib_utils.change_config05 */ INTO util_event_log
(instance_id, run_no, schema_name, package_name, object_type, line_number,
beg_date, host_name, instance_name, active_instances, service_name,
module_name, action_name, client_info, severity, log_comment)
VALUES
(cInstID, pRunNo, vSchemaName, vPkgName, vObjType, vLineNumber,
pBegDate, cHostName, cInstName, vInstCount, cServName,
cModName, cActName, cCliInfo, pSeverity, pLogComment);
END LOOP;
COMMIT;
-- this procedure intentionally does not contain exception handling: do not add one.
END Log_Event_Start;
/