Click to See Complete Forum and Search --> : A question about Oracle stored procedure


Cristal
April 4th, 2003, 12:26 PM
Hi,

I have a question about Oracle stored procedure.

I have a table that contains fields ITEM1, ITEM2, ... ITEM120. Can I do a loop to go through them following the logic as:

totCnt = 0
for i = 1 .. 120
fieldname='ITEM' & to_string(i)

select count(*) cnt
from table1
where fieldname='1234'

totCnt = totCnt + cnt
insert into table2 (totCnt)
loop

Can I do this? If I can, how can I make Oracle know that fieldname is a name of a table column.

Thanks a lot for your help!

Cristal