[IMP] Need help with PL/SQL

raksrules

Well-Known Member
Elite
Aug 30, 2007
9,859
1,728
378
Mumbai <--> Pune
This query may seem to be simple for some but i am not able to get how to achieve this. The scene is that i have a Lines table (say tab_lines) having 70 to 80 columns(approx). Now in this table i have a few columns starting at col8 to col65 (these are actual column names). Now my problem is that i need to look at the values in each of these columns (i.e. 8 to 65) for a value and do processing accordingly. This has to be done for each row in the table.

In gist, in need to check the value of each of the columns from col8 to col65 for each row in the tab_lines table. How do i do the looping to achieve this ? I have a rough idea that it will be nested loops wherein i will make a cursor that will select all the rows from the tab_lines table and open this cursor in a FOR loop. But after this i dont know how to loop through each of the columns (i.e. col8 to col65) in this row.

Please help me in this.
 

47Shailesh

Active Member
Disciple
Apr 4, 2008
777
20
31
71
You'll need to write a sql procedure for this. I'll try to write one for you tomorrow sometime
 

hammerhead

New Member
Adept
Jun 26, 2006
683
26
0
32
www.teamreflex.org
I think you got your concepts wrong. A cursor will select one row at a time in a loop not all rows at once. Use a structure like this

Code:
for cursor_record in cursor loop

if cursor_record.column8 <val then
-- do something
end if;
if cursor_recode.column9 <val2 then
--do something
end if;

-- similarly for other columns

end loop;
the loop will run for all rows selecting one row at a time.