Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find out name of PL/SQL procedure

Tags:

oracle

plsql

Can PL/SQL procedure in Oracle know it's own name?

Let me explain:

CREATE OR REPLACE procedure some_procedure is
    v_procedure_name varchar2(32);
begin
    v_procedure_name := %%something%%;
end;

After %%something%% executes, variable v_procedure_name should contain 'SOME_PROCEDURE'. It is also OK if it contains object_id of that procedure, so I can look up name in all_objects.

like image 581
icuric Avatar asked Nov 13 '08 08:11

icuric


People also ask

How can I see the procedure code in PL SQL Developer?

You can use the connections tab which is in the left side of sql developer. Show activity on this post. Browse to the connection name in the connections tab, expand the required object and just click, it will open the code in new tab.

What is stored procedure in PL SQL?

A stored procedure in PL/SQL is nothing but a series of declarative SQL statements which can be stored in the database catalogue. A procedure can be thought of as a function or a method. They can be invoked through triggers, other procedures, or applications on Java, PHP etc.

How do you find where a stored procedure is being used in Oracle?

Expand Databases, expand the database in which the procedure belongs, and then expand Programmability. Expand Stored Procedures, right-click the procedure and then click View Dependencies. View the list of objects that depend on the procedure. View the list of objects on which the procedure depends.


2 Answers

Try:

v_procedure_name := $$PLSQL_UNIT;

There's also $$PLSQL_LINE if you want to know which line number you are on.

like image 92
cagcowboy Avatar answered Nov 24 '22 00:11

cagcowboy


If you are pre-10g, you can 'dig' (parse) it out of dbms_utility.format_call_stack Procedures/functions in packages can be overloaded (and nested), so the package name/line number is normally better than the name.

like image 28
Gary Myers Avatar answered Nov 23 '22 23:11

Gary Myers