I need to get the specific column value from rowtype variable. My sample code is
declare
col_name varchar2(100);
col_val varchar2(100);
TYPE column_table_type IS TABLE OF COLUMN_TABLE%ROWTYPE;
column_table column_table_type ;
begin
SELECT * BULK COLLECT INTO column_table FROM COLUMN_TABLE;
for data_table in (select * from DATA_TABLE)
loop
for i in column_table.first .. column_table.count
loop
col_name=column_table(i).COLUMN_NAME;
/*
How to get the col_val for col_name from the data_table with out extra query.
*/
end loop;
end loop
end;
/
COLUMN_TABLE:
COLUMN_NAME
----------------
emp_name
emp_id
emp_addr
DATA_TABLE:
emp_name emp_id emp_addr
----------------------------
A 1 aaaa
B 2 bbbb
C 3 cccc
Need to write this piece of code in optimal way. To get the value 'A' for whenever i get col_name is emp_name for the first row set.
Here DATA_TABLE contains so many columns, but i need only specific column which are getting from the column table and need column names and values for further processing.
Please help me out from this.