Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> PL/SQL - Use bind variable in "from <table>" query

PL/SQL - Use bind variable in "from <table>" query

From: Lyndon Tiu <ltiu_at_alumni.sfu.ca>
Date: Mon, 31 Jan 2005 21:05:06 -0800
Message-Id: <200501312105.06794.ltiu@alumni.sfu.ca>


Hello,

I have a lookup table with a column.

This column holds a variable - the name of another table.

In PL/SQL code, I need to query (at run time) the lookup table, retrieve the value stored in the lookup table's column and use it as the table in another query.

I have tried using bind variables but it seems that I cannot set the <table> in:

select * from <table>

to a bind variable.

The code:



declare:

v_table_name varchar2

v_value varchar2

begin

select table_name into v_table_name from lookup_table;

select value into v_value from :v_table_name;

end;


does not even compile. I get an error that :v_table_name is a bad bind variable.

Thanks for any help.

--

Lyndon Tiu
--

http://www.freelists.org/webpage/oracle-l Received on Tue Feb 01 2005 - 00:07:43 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US