Monday, March 2, 2009

Cursor: The CURrent Set Of Records

Declare
v_First Varchar2(20);
v_Last Varchar2(20);
--+--------------------------------------------------------
--| The current set of records (cursor)
--+--------------------------------------------------------
Cursor C_Students Is
Select First_Name, Last_Name
From Students;

--+----------------------------------------------------------
--| Execution Section
--+----------------------------------------------------------
Begin

Open C_Students;

Loop
-- Fetch retreives 1 row for processing
Fetch C_Students Into v_First, v_Last;
Exit When C_Students%Notfound;

/* Add code here to process the records */

End Loop;

Close C_Students;
End;
/

No comments:

Post a Comment