Get name of function [message #305625] |
Tue, 11 March 2008 07:19 |
KieranJ
Messages: 3 Registered: March 2008
|
Junior Member |
|
|
Is there a way of getting the name of the function that is currently executing from inside it?
eg.
create or replace procedure test is
func_name varchar2(50);
begin
func_name := 'test'; -- Automate this
dbms_output.put_line(func_name);
end;
|
|
|
Re: Get name of function [message #305629 is a reply to message #305625] |
Tue, 11 March 2008 07:31 |
dhananjay
Messages: 635 Registered: March 2002 Location: Mumbai
|
Senior Member |
|
|
don't know if there any such thing which will tell you the current executing function.But what is the purpose you are trying to achive here?
regards
|
|
|
Re: Get name of function [message #305632 is a reply to message #305625] |
Tue, 11 March 2008 07:36 |
S.Rajaram
Messages: 1027 Registered: October 2006 Location: United Kingdom
|
Senior Member |
|
|
SQL> create or replace procedure test_proc
2 is
3 begin
4 dbms_output.put_line('My Name is : ' || $$PLSQL_UNIT);
5 end;
6 /
Procedure created.
SQL> exec test_proc;
My Name is : TEST_PROC
PL/SQL procedure successfully completed.
SQL> declare
2 begin
3 dbms_output.put_line('My name is : ' || $$PLSQL_UNIT);
4 end;
5 /
My name is :
PL/SQL procedure successfully completed.
Remember above code will only for stored proc or functions or packages. It will return null for an anonymous block and it will return the name of the package body and not the procedure / function defined in the package.
HTH
Regards
Raj
|
|
|
|
|
|
|
Re: Get name of function [message #306449 is a reply to message #306448] |
Fri, 14 March 2008 05:11 |
S.Rajaram
Messages: 1027 Registered: October 2006 Location: United Kingdom
|
Senior Member |
|
|
This features is introduced in 10gR2 and it is simple. Prior to that version refer the link posted by @anacedent. It has examples how to extract this information.
Regards
Raj
|
|
|