Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a parameter's name

I want to get a parameter's name in plsql.

For example,

procedure sp_example(myParam in varchar2) is

paramName varchar2(30);
begin
    paramName = 'myParam';
end
end procedure sp_example;

Is there a way to get the name of myParam using reflection, instead of hard coding it?

like image 270
Netfangled Avatar asked Aug 28 '12 13:08

Netfangled


2 Answers

Try:

select argument_name from all_arguments where object_name = 'SP_EXAMPLE';

This view can also show you the data types, positions, etc., and you can use it in SQL or PL/SQL. Plenty of info in the various metadata views.

like image 55
tbone Avatar answered Sep 25 '22 22:09

tbone


If you want to get the names of parameters retrieved in their respective positions, use

select argument_name from user_arguments where object_name='SAMPLE_PROC' order by position;

like image 45
vinodhrajagopal Avatar answered Sep 22 '22 22:09

vinodhrajagopal