Get a parameter's name

2019-05-03 08:10发布

问题:

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?

回答1:

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.



回答2:

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;