1
Name:Name:
Pansuriya Chandani V.Pansuriya Chandani V.
ClassClass:: S.Y. B.C.A.S.Y. B.C.A.
Div.Div.:: 33
Roll.NoRoll.No:: 135135
SubSub:: RDBMSRDBMS
CURSOR FOR LOOP
2
CURSOR FOR LOOPCURSOR FOR LOOP
It is with explicte cursor to process
multiple Records .
Syntax:-
FOR <record name> IN <cursor_
name>
LOOP
<loop statement>;
.……………….
END LOOP;
3
*WRITE A PL/SQL BLOCK USING
CURSOR FOR LOOP TO DISPLAY
STUDENT ROLLNO,NAME &
CITY.*
4
DECLARE
CURSOR C.STUD
IS
SELECT ROLLNO,NAME,CITY FROM STUDENT;
// R_STUD C.STUD %ROWTYPE;
BEGIN
//OPEN C.STUD;
FOR R_STUD IN C.STUD
LOOP
DBMS_OUTPUT.PUT_LINE(R_STUD.ROLLNO||’ ‘|| R_STUD
||’ ‘|| R_STUD.CITY);
END LOOP;
END;
/
ADVANTAGE OF CURSOR FORADVANTAGE OF CURSOR FOR
LOOP.LOOP.
 Whenever the cursor For loop is used, the
cursor is not required to be opened,
records fetched, or closed explicitly.
 These operations are done automatically.
 The first time control enters the loop, the
cursor is opened and the first record is
fetched.
 For subsequent iterations in the loop the
next records are fetched one by one.
 After the last fetch the cursor is closed
and control comes out the loop. 5
ADVANTAGE OF CURSOR FORADVANTAGE OF CURSOR FOR
LOOP.LOOP.
 Whenever the cursor For loop is used, the
cursor is not required to be opened,
records fetched, or closed explicitly.
 These operations are done automatically.
 The first time control enters the loop, the
cursor is opened and the first record is
fetched.
 For subsequent iterations in the loop the
next records are fetched one by one.
 After the last fetch the cursor is closed
and control comes out the loop. 5

135 cursor for loop

  • 1.
    1 Name:Name: Pansuriya Chandani V.PansuriyaChandani V. ClassClass:: S.Y. B.C.A.S.Y. B.C.A. Div.Div.:: 33 Roll.NoRoll.No:: 135135 SubSub:: RDBMSRDBMS
  • 2.
  • 3.
    CURSOR FOR LOOPCURSORFOR LOOP It is with explicte cursor to process multiple Records . Syntax:- FOR <record name> IN <cursor_ name> LOOP <loop statement>; .………………. END LOOP; 3
  • 4.
    *WRITE A PL/SQLBLOCK USING CURSOR FOR LOOP TO DISPLAY STUDENT ROLLNO,NAME & CITY.* 4 DECLARE CURSOR C.STUD IS SELECT ROLLNO,NAME,CITY FROM STUDENT; // R_STUD C.STUD %ROWTYPE; BEGIN //OPEN C.STUD; FOR R_STUD IN C.STUD LOOP DBMS_OUTPUT.PUT_LINE(R_STUD.ROLLNO||’ ‘|| R_STUD ||’ ‘|| R_STUD.CITY); END LOOP; END; /
  • 5.
    ADVANTAGE OF CURSORFORADVANTAGE OF CURSOR FOR LOOP.LOOP.  Whenever the cursor For loop is used, the cursor is not required to be opened, records fetched, or closed explicitly.  These operations are done automatically.  The first time control enters the loop, the cursor is opened and the first record is fetched.  For subsequent iterations in the loop the next records are fetched one by one.  After the last fetch the cursor is closed and control comes out the loop. 5
  • 6.
    ADVANTAGE OF CURSORFORADVANTAGE OF CURSOR FOR LOOP.LOOP.  Whenever the cursor For loop is used, the cursor is not required to be opened, records fetched, or closed explicitly.  These operations are done automatically.  The first time control enters the loop, the cursor is opened and the first record is fetched.  For subsequent iterations in the loop the next records are fetched one by one.  After the last fetch the cursor is closed and control comes out the loop. 5