Home » Developer & Programmer » Forms » Continue statement (Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod, Windows XP) , Forms 6i)
Continue statement [message #410806] Tue, 30 June 2009 06:16 Go to next message
waqasbhai
Messages: 118
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 Go to previous messageGo to next message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
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 #410809 is a reply to message #410806] Tue, 30 June 2009 06:39 Go to previous messageGo to next message
waqasbhai
Messages: 118
Registered: August 2008
Location: Pakistan
Senior Member
does it work in forms 6i?
Re: Continue statement [message #410811 is a reply to message #410809] Tue, 30 June 2009 06:56 Go to previous messageGo to next message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
GOTO does; DBMS_OUTPUT does not (but it was here just to illustrate the solution).
Re: Continue statement [message #410815 is a reply to message #410806] Tue, 30 June 2009 07:07 Go to previous messageGo to next message
waqasbhai
Messages: 118
Registered: August 2008
Location: Pakistan
Senior Member
do we need to declare finito? if yes then whts the type. Its giving me the error when i compile the form
Re: Continue statement [message #410857 is a reply to message #410815] Tue, 30 June 2009 13:15 Go to previous messageGo to next message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
"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 Go to previous messageGo to next message
waqasbhai
Messages: 118
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 Go to previous message
Littlefoot
Messages: 20888
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
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;
Previous Topic: OG.PLL
Next Topic: How to make a field not updatable(update_allowed property)
Goto Forum:
  


Current Time: Sat Dec 03 10:20:14 CST 2016

Total time taken to generate the page: 0.07228 seconds