Home » SQL & PL/SQL » SQL & PL/SQL » Fetch Next Record in Loop
Fetch Next Record in Loop [message #38964] Fri, 31 May 2002 04:39 Go to next message
Stupid
Messages: 8
Registered: November 2001
Junior Member
Dear all,

I am writing a while-loop like below :
open cur_c
loop
<<start_loop>>
fetch cur_c into cur_c_rec ;
exit when cur_c%not_found;
if ... then
goto <<start_loop>>;
end if;
end loop;

I know it is poor to use "GOTO" in PL/SQL
However, it is complicate logic, I want to read next record if there is any error.
If anyone has any ideas about reading next record without using "GOTO", it would be greatly appreciated.
THANK YOU VERY MUCH.
Re: Fetch Next Record in Loop [message #38968 is a reply to message #38964] Fri, 31 May 2002 07:46 Go to previous messageGo to next message
Rick Cale
Messages: 111
Registered: February 2002
Senior Member
You could do the following

open cur_c
loop
fetch cur_c into cur_c_rec ;
exit when cur_c%not_found;
if NOT ... then
NULL; -- Do Nothing
else
process record
end if;
end loop;
Re: Fetch Next Record in Loop [message #38970 is a reply to message #38968] Fri, 31 May 2002 08:52 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
What about just:

if not some error_condition then
  -- process
end if;


And by error_condition, I'm assuming we mean something you notice about the data as opposed to an actual Oracle exception.

We definitely don't need a GOTO for this situation.
Previous Topic: triggers help URGENT!!
Next Topic: Counting unique values in a table
Goto Forum:
  


Current Time: Wed Apr 24 22:33:10 CDT 2024