Manual Experiment 2.3
Manual Experiment 2.3
3
AIM: Introduction and implementation of programs using Cursors.
S/W Requirement: Oracle Database Express Edition
Cursors
Oracle creates a memory area, known as context area, for processing an SQL statement,
which contains all information needed for processing the statement, for example, number of
rows processed etc.
A cursor is a pointer to this context area. PL/SQL controls the context area through a cursor.
A cursor holds the rows (one or more) returned by a SQL statement. The set of rows the
cursor holds is referred to as the active set.
You can name a cursor so that it could be referred to in a program to fetch and process the
rows returned by the SQL statement, one at a time. There are two types of cursors:
Cursors
Implicit Explicit
Implicit Cursors
Implicit cursors are automatically created by Oracle whenever an SQL statement is executed,
when there is no explicit cursor for the statement. Programmers cannot control the implicit
cursors and the information in it.
Whenever a DML statement (INSERT, UPDATE and DELETE) is issued, an implicit cursor
is associated with this statement.
Attribute Description
Explicit Cursors
Explicit cursors are programmer defined cursors for gaining more control over the context
area. An explicit cursor should be defined in the declaration section of the PL/SQL Block. It
is created on a SELECT Statement which returns more than one row.
Syntax
Working with an explicit cursor involves four steps:
EXAMPLE
--