Oracle SQL, PLSQL, APEX How To's by Dr. S. Raghunathan - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

 

18.03  HOW TO USE SIMPLE LOOP

 

loop

 

exit when <<variable>> = 100;

 

end loop;

 

 

 

For Example:

 

declare

 

some-val   number;

 

cumulative-value number;

 

begin

 

some-val : = 35  ;          -- initital value assigned loop

exit when cumulative-value > 2000  -- sets the value to discontinue looping

cumulative-value := cumulative-value + some-Val;

 

some-Val := some-Val + 1;

 

end loop;

 

end;

 

Here it will go on add as 35 + 36 + 37 + 38 ….. and when the cumulative value exceeds 2000 this program quits and stop incrementing the some-val variable,