Link to home
Start Free TrialLog in
Avatar of mikezang
mikezang

asked on

Can I use a parameter in SELECT FROM as table name?

I am making a common functuion, one parameter is a array table name, I need to select some columns from that table. Can I use as below?

Select *
FROM param1
Avatar of sathyagiri
sathyagiri
Flag of United States of America image

You can use dynamic query to do that

Example

qry_string := 'select * from ' || param1;
execute immediate qry_string into var;
Avatar of MohanKNair
MohanKNair

If the function rsturns the colelction object then it can be used in select statements

select * from TABLE(<function name>);
Avatar of mikezang

ASKER

Can you explain more detail or give a smaple?
ASKER CERTIFIED SOLUTION
Avatar of MohanKNair
MohanKNair

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
SOLUTION
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
Hi,

For more details related EXECUTE IMMIDIATE or Dynamic SQL:
http://www.utexas.edu/its/unix/reference/oracledocs/v92/B10501_01/appdev.920/a96624/11_dynam.htm

With regards, Hardik