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.

fetch cl into cl-val;     -- every fetch will pick l record and assigns to cl-val

exit when cl%NOTFOUND;   -- when reads come to last record … it

 

stops

 

cum-rainfall := cum-rainfall + cl-val,rainfall;

 

end loop; close cl; end;

 

18.05      How to use for loop

 

for <<l-temp> l ,,  l0  loop end  loop;

For Example:

 

We have one table named as test and we have two columns as coll and col2, I want to insert l0 records, Coll will have some values and col2 must be stored as square of coll, First value starts from l22,

declare

 

temp-Value number;

 

begin

 

for temp-value in l22 ,, l3l loop

 

insert into test values ( temp-value, temp-value * temp-value);

 

end loop;

 

end;

 

 

18.06      How to use while loop

 

while   <<l-temp>>    <= 99