Monday, December 8, 2014

How to get Called and Calling Procedure name?

Sometimes we got requirement where we required few parameters like Owner name, calling procedure name, and Called procedure name.
In such scenario oracle provide some standard methods by using which we can achieve the functionality.
Below are the two ways I have used to fetch called procedure name and calling procedure name.

Method 1: Using OWA_UTIL.WHO_CALLED_ME
Method 2: Using $$PLSQL_UNIT

Example:

CREATE OR REPLACE PROCEDURE XX_CALLED
as
l_owner  varchar2(20);
l_name  varchar2(20);
l_lineno number;
l_callervarchar2(20);
BEGIN
OWA_UTIL.WHO_CALLED_ME (l_owner, l_name,l_lineno,l_caller);
dbms_output.put_line('You are called by '||'owner   '||l_owner||
' Calling Object '||l_name||' Line no '||l_lineno||' Caller Type '||l_caller  );
dbms_output.put_line('Calling Object '|| $$PLSQL_UNIT);
END XX_CALLED;

Testing
BEGIN
XX_CALLED;
END;

No comments:

Post a Comment