Introduction PL/SQL

Basic PL/SQL

Advance PL/SQL

PL/SQL Cursors(Implicit, Explicit, For Loop, Parameterized Cursor)

What is Cursor?
Cursor is the work area which Oracle reserves for internal processing of SQL statements. This work area is private for oracles reserved are called cursor.

How to Use Cursor

In PL/SQL block SELECT statement can not return more than one row at a time. So Cursor use to some group of rows (more than one row) for implementing certain logic to all the records of group are show.

Classification of CURSORS

Cursors can be classified as:

  • Implicit Cursor or Internal Cursor - Manage for Oracle itself or Internal Process itself.
  • Explicit Cursor or User-defined Cursor - Manage for User/Programmer or External Processing.

Implicit Cursor

Oracle uses implicit cursors for its internal processing. Even if we execute a SELECT statement Oracle reserves a private SQL area in memory called cursor.

Explicit Cursor

Explicit Cursor which declared by user are called Explicit Cursor. The user has to declare the cursor, open cursor to reserve the memory are and populate data, fetch the records from the active data set one at a time, apply logic and last close the cursor.

Step for Using Explicit Cursor

  1. Declare Cursor

  2. Open Cursor

  3. Loop

  4. Fetch Record into Cursor

  5. Exit Loop

  6. Close Cursor