Dynamic column name using cursor in Oracle PLSQL -


i need generate column name dynamically in loop , access column in oracle table using plsql. how do that?

declare  varvalue varchar(20);  cursor c   select * test1;  begin      in c loop        j in 1..5        loop         execute immediate 'select ''name1'||to_char(j)||''' dual' varvalue;          dbms_output.put_line(j);          dbms_output.put_line(i.varvalue);        end loop;      end loop;  end; 

actual issue is, need acccess cell values of each row (i) given cursor (c) i.name11, i.name12....i.name1100. logic deployed in each cell same. need column name used here i.e. name11 generated dynamically. alread done , stored variable varvalue. how can access cells i.varvalue such var value generated in loop.

the error follows:

ora-06550: line 14, column 34: pls-00302: component 'varvalue' must declared ora-06550: line 14, column 11: pl/sql: statement ignored 

declare  varvalue varchar(20);  cursor c   select * test1;  begin      in c loop        j in 1..5        loop         execute immediate 'select ''name1'||to_char(j)||''' dual' varvalue;          dbms_output.put_line(j);          dbms_output.put_line('name1'||to_char(j)||' : '||varvalue);        end loop;      end loop;  end; 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

angularjs - ng-repeat duplicating items after page reload -