Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Fetch dynamic columns from table

571706Oct 15 2008 — edited Oct 15 2008
I have table with 1000 rows and 200 columns. Columns have incremental suffix i.e
Table="X"
Columns=ID,A,B,C, D1,D2,D3....D200

I would like to get values from each column so i can process them accordingly.


OPEN c1 FOR SELECT * FROM X

LOOP
FETCH c1 BULK COLLECT INTO l_dies;

FOR indx IN 1 .. l_dies.COUNT
LOOP
FOR indx IN 0 .. 200
LOOP
colStr:=l_dies(indx).||'D'||indx; <-- Trying to concat dynamic column name but it gives error.
DBMS_OUTPUT.put_line('indx='|| indx || 'col value=' || colStr);
END LOOP;
END LOOP;
END LOOP;

This may not be the right way but just an example of what i would like to achieve.

Thanks in advance.
This post has been answered by 561825 on Oct 15 2008
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 12 2008
Added on Oct 15 2008
12 comments
2,041 views