| Continue statement [message #410806] |
Tue, 30 June 2009 06:16  |
waqasbhai Messages: 116 Registered: August 2008 Location: Pakistan |
Senior Member |
|
|
|
I want to use the continue statement to by pass all the remaining statement(s) in the loop and move to the next iteration.
|
|
|
| Re: Continue statement [message #410807 is a reply to message #410806] |
Tue, 30 June 2009 06:31   |
Littlefoot Messages: 9167 Registered: June 2005 Location: Croatia, Europe |
Senior Member |
|
|
GOTO (not popular, but does the job):begin
for i in 1 .. 5 loop
dbms_output.put_line('one');
goto finito;
dbms_output.put_Line('two');
<<finito>>
dbms_output.put_Line('three');
end loop;
end;
|
|
|
|
|
|
| Re: Continue statement [message #410857 is a reply to message #410815] |
Tue, 30 June 2009 13:15   |
Littlefoot Messages: 9167 Registered: June 2005 Location: Croatia, Europe |
Senior Member |
|
|
"Finito" is a label and it doesn't have to be declared, other than specifying it using the syntax I have already showed: <<label_name>>.
I don't have Forms 6i to test, but the following WHEN-NEW-FORM-INSTANCE trigger's code works just fine in Forms 10g:begin
message('1');
message('1');
goto finito;
message('2');
message('2');
<<finito>>
message('3');
message('3');
end;
|
|
|
| Re: Continue statement [message #410941 is a reply to message #410806] |
Wed, 01 July 2009 03:26   |
waqasbhai Messages: 116 Registered: August 2008 Location: Pakistan |
Senior Member |
|
|
ok i got it. Actually i was getting the error because i am not putting any statement after <<finito>> as <<finito>> can not be the last statement.
Ok one last question, if GOTO is not the good approach then what is the better way of doing it?
|
|
|
| Re: Continue statement [message #410963 is a reply to message #410941] |
Wed, 01 July 2009 05:39  |
Littlefoot Messages: 9167 Registered: June 2005 Location: Croatia, Europe |
Senior Member |
|
|
Well, you might - if possible - enclose part(s) of your code into the IF-THEN-ELSE. So, if certain condition is met, execute these statements. Otherwise, you're at the end of the loop. Something like
begin
for i in 1 .. 5 loop
if some_condition_here then
execute_your_code
end if;
end loop;
end;
|
|
|