Fetch Next Record in Loop [message #38964] |
Fri, 31 May 2002 04:39 |
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 |
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 |
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.
|
|
|