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.04  How to use cursor loop

 

CURSOR LOOP

 

loop

 

fetch  <<,,,,,>> int<<,,,,>>;

 

exit when <<,,,>>%NOTFOUND;

 

end loop; For example :

In one table ( named as testl ) has got two columns as rain-date and rain-fall,

We need to cumulate the rain-fall till the last record available, We are going to use one datatype as cursor along with looping concepts, Declare

cum-railfall         number; cursor Cl select * from testl; Cl-val Cl%ROWTYPE;

-- Cl the name assinged to cursor

 

-- * symbol is used for selecting all the columns available in the testl table,

--  Cl-val is another variable takes the value of cursor Cl Record as

 

Rowtype

 

Begin

 

open cl;

-----

opening the cursor

 

loop

----

repetitive action starts