To process a SQL statement, PL/SQL opens work are called private SQL area. PL/SQL allows user to name the private work areas and access the stored information. The PL/SQL construct to identify each and every work area used is called CURSOR. There are two types of cursors. IMPLICIT and EXPLICIT.
Explicit cursor
The set of rows returned by a query can consist of Zero, one or many rows, depending upon the number of rows that meet the query's search condition. When a query returns multiple rows, a cursor can be explicitly defined to
1) process beyond the first row returned by the query.
2) keep track of which row Is being processed.
There are four steps to DECLARE and USE a CURSOR
• DECLARE the cursor
• OPEN the cursor
• FETCH data from the cursor
• CLOSE the cursor
Declare cursor
Declare the cursor to associate Its name with a select statement. Forward references are not allowed in I SQL. So we must declare cursor before referencing in other statements.
DECLARE
CURSOR < cursor-name > IS