RE: basic question for loop

RE: basic question for loop

 

  

It's not always good practice to use exceptions to control program flow,
but here it is useful. Try this ...

declare
iterate exception ;
begin
FOR I in 1..4 LOOP
begin
IF I=2 THEN
raise iterate ; -- << here I want to go to start of loop for
next value of I>>
ELSE
DBMS_OUTPUT.PUT_LINE('value of I is ' || I);
END IF;
-- <<some other executable statements>>
exception
when iterate then null ;
end ;
END LOOP;
end ;


Stephen Weston




-----Original Message-----
From: Abhishek.Goel
[mailto:oracledba-ezmlmshield-x8827587.[Email address protected]
Sent: 02 August 2006 22:53
To: LazyDBA Discussion
Subject: basic question for loop

Hi All

I have one basic question..
I have one FOR LOOP and want to goto start of loop for next value of I,
NOTE: I am not suppose to use GOTO statement.

FOR I in 1..4 LOOP
IF I=2 THEN
<< here I want to go to start of loop for next value of I>>
ELSE
DBMS_OUTPUT.PUT_LINE('value of I is ' || I);
END IF;
END LOOP;


--------
website: http://www.LazyDBA.com
Please don't reply to RTFM questions
Oracle documentation is here: http://tahiti.oracle.com
To unsubscribe: see http://www.lazydba.com/unsubscribe.html
To subscribe: see http://www.lazydba.com
By using this list you agree to these
terms:http://www.lazydba.com/legal.html


Oracle LazyDBA home page