DCCoolBreeze
Programmer
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
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