PL/SQL Cursor 1 – Introduction

A cursor is a mechanism by which you can assign a name to a "select statement" and manipulate the information within that SQL statement.

Cursor without parameters (simplest)

The basic syntax for a cursor without parameters is:

CURSOR cursor_name
IS
  SELECT_statement;

 
Cursor with parameters

The basic syntax for a cursor with parameters is:

CURSOR cursor_name (parameter_list)
IS
  SELECT_statement;  

 
Cursor with return clause

The basic syntax for a cursor with a return clause is:

CURSOR cursor_name
RETURN field%ROWTYPE
IS
   SELECT_statement;

Open Cursor

The basic syntax to OPEN the cursor is:

OPEN cursor_name;

Fetch Cursor values

The basic syntax for a FETCH statement is:

FETCH cursor_name INTO <list of variables>;

Close Cursor

The basic syntax to CLOSE the cursor is:

CLOSE cursor_name;
 


You can leave a response, or trackback from your own site.

Leave a Reply