I have two tables. Lets say tab1 and tab2.
tab1 has data like this:
ID Field Name
00001 col1
00001 col63
00002 col3
00002 col47
00003 col22
00003 col40
Each ID has always 2 Field Name values.
And tab2 has columns col1,col2,col3,col4....col70
I want to select columns dynamically from tab2.
Like for 00001 it should be:
select col1,col63 from tab2;
Similarly for 00002 it should be :
select col3,col47 from tab2;
Is there any way to achieve this without using function or procedure ? I am using Oracle 11G.
case field_name when 'col1' then col1 when 'col2' then col2.... Or in Oracle fashion:decode(field_name, 'col1', col1, 'col2', col2, 'col3', col3)no dynamic SQL and its vulnerability