Friday 5 June 2015

Cursor in PL/SQL- Part 2

   In the previous  post Cursor in PLSQL-Part 1 we have discussed about the basics of PL/SQL Cursor. Let us discuss more about the Cursors in this post.

Cursor FOR-LOOP:
   Using cursor FOR LOOP you can process the records in the cursor without using OPEN and Fetch the Cursor. The Cursor FOR LOOP handles open and fetch the records from the cursor.

General Syntax for cursor FOR-LOOP :


You can refer the below example for Cursor FOR LOOP.

 

Output:












Parameterized Cursor:
  You can also pass the parameters to the cursor and while calling you need to call the cursor with parameter value.

General Syntax:


You can go through the below example for parameterized cursor.


Output:










Cursor FOR LOOP without declaring a Cursor:
    You can use the cursor FOR LOOP without declaring a cursor in DECLARE block. While using the for loop you can use the select statement.

General Syntax:

You can go through the below example.


Output:

No comments: