Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable as column name in SELECT statment

Status
Not open for further replies.

IjumpOverU

Technical User
Jul 31, 2003
43
US
Is there any way to use a variable as a column name in a select statement?

Example:

DECLARE
v_col_name VARCHAR2(40);
v_value VARCHAR2(80);

SELECT v_col_name INTO v_value
FROM table_name;

This is of course a valid sql statement, but I do not want the column name selected into the value variable I want the column name varibale to be referenced as the column in the "table_name" table.
 
Try a search on dynamic SQL (you have to build the SELECT statement as a text string and then execute it).

Beware of false knowledge; it is more dangerous than ignorance. ~George Bernard Shaw
Consultant Developer/Analyst Oracle, Forms, Reports & PL/SQL (Windows)
My website: Emu Products Plus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top