Link to home
Start Free TrialLog in
Avatar of mccallw
mccallw

asked on

PL/SQL - Determining which procedure called current procedure

Using PL/SQL, is there a way within a current procedure to determine which procedure called it.  

Also, is there a way to determine within the current procedure to return the name of the current procedure.

So, in summary I need to know a method to return the name of the calling procedure and the current procedure.
Avatar of mandarexpert
mandarexpert

For to get the procedure name and calling procedure name we have to take care while coding itself.Like u can make the string dynamically and display it on the screen with the help of DBMS_OUTPUT.PUT_LINE(string).
Or if that procedure is getting called from Front-End we can put the dynamic string in one of the temp.table. so if u select from that temp table we can get which procedure is currently running.
Avatar of mccallw

ASKER

Thanks for the response mandarexpert, but both of your options are workarounds that we cannot use.  We would like to somehow using an existing package that can determine the name and calling name and use it for logic rather than just a return to the screen.

The temp table idea may be interesting.  Are you suggesting to change the code of all procedures to update a temp table with it's own name prior to running or calling another procedure?
ASKER CERTIFIED SOLUTION
Avatar of syakobson
syakobson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mccallw

ASKER

Thanks for the complete and thorough answer!  I will give these options a try.
Here's a quick and dirty way to at least NARROW down the possibilities of what procedure/function called a procedure or function.

If you use TOAD, in the Schema Browser, there is a tab on the left side for Procedures/Functions/Packages called "PROCS".  When you have chosen the callee procedure you're interested in, then on the right hand side, there's a tab called "Deps (Used By)" meaning Dependencies (aka what procedures/functions use this callee).

When you click on this tab it will list the potential caller objects.  Not as thorough an answer as Solomon's but it's quick.

Gio
Here's a quick and dirty way to at least NARROW down the possibilities of what procedure/function called a procedure or function.

If you use the TOAD PL/SQL editor in the Schema Browser, there is a tab on the left side for Procedures/Functions/Packages called "PROCS".  When you have chosen the callee procedure you're interested in, then on the right hand side, there's a tab called "Deps (Used By)" meaning Dependencies (aka what procedures/functions use this callee).

When you click on this tab it will list the potential caller objects.  Not as thorough an answer as Solomon's but it's quick.

Gio
Avatar of mccallw

ASKER

Thanks jaramill.  I use TOAD as well and have seen this function.

I am really interested in getting this information during the execution of the procedure itself, however, so that I can perform logic based on the calling procedure.