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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tough Questions about referencing Columns...at least for me...

Status
Not open for further replies.

DCCoolBreeze

Programmer
Jul 25, 2001
208
US
I need to be able to reference a table column data dynamically. For example. I want to generate a loop where I get the column names for a specific table and then use that column name to extract the value. For example:

cursor c1
select stuff from table where stuffid = something;
r1 c1%rowtype;

cursor c2
select column_name from all_tab_columns
where table_name = 'sometable';
r2 c2%rowtype;

...

open c1;
fetch c1 into r1;
close c1;

open c2;
fetch c2 into r2;
while c2%found
loop
dbms_output( r2.column_name || ' ' ||
r1.<I want to be able to put column_name here>
fetch c2 into r2;
exit when something goes wrong
end loop
close c2;

So if I have the name of the column; how can I use this name variable to grab the data in that specific column???

Thanks for your help,

DC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top