Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: PL/SQL Question re: loops

Re: PL/SQL Question re: loops

From: Martin Haltmayer <Martin.Haltmayer_at_0800-einwahl.de>
Date: 2000/04/14
Message-ID: <38F779EC.D616136A@0800-einwahl.de>#1/1

Yes, there is in 8.1.5:

set serveroutput on size 1000000
begin

	for j in 1.. 10 loop
		if (mod (j, 3) = 0) then
			goto nextone;
		end if;
		dbms_output.put_line ('j = ' || j);
		<<nextone>>
		null;
	end loop;

end;
/

yields

j = 1
j = 2
j = 4
j = 5
j = 7
j = 8
j = 10

You asked for advice, you got one. Now I ask you not to use it, please.

Reason 1: Some 20 years ago FORTRAN programs got condemned because they allowed gotos which made FORTRAN programs look like spaghetti code.

Reason 2: I learnt in university that the semantics of a program is a very complicated one if it contains gotos.

Reason 3: If you keep to the rule "Each block has exactly one input and one output" your programs may be longer or a bit more tedious to write, but you know that changes in your code will stay local and your code is easier to maintain.

Martin

Jeremy Ovenden wrote:
>
> Apologies if this is a really simple question, but in the 'mock' pl/sql
> below, is there a command to skip this iteration of a loop - basically not
> quit the procedure with 'return;' nor quit the loop using 'exit;'. I am
> aware this can be done using labels but is there an alternative?
>
> for i in 1..10
> loop
> if (some condition is satisfied) then
> skip this iteration
> end if;
>
> do all the other stuff
> end loop;
>
> Mant tia
>
> cheers
> jeremy - jovenden_at_hazelweb.co.uk
  Received on Fri Apr 14 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US