0% found this document useful (0 votes)
117 views

Oracle 9i Cursor

A cursor in PL/SQL represents a private SQL area or context area in memory that acts as a pointer or handle to retrieve and process data from a database table one row at a time. There are two types of cursors - implicit cursors which are automatically declared by PL/SQL for single row queries, and explicit cursors which must be declared, opened, and closed by the programmer to process multiple rows of data from a table. When a cursor is declared, a pointer variable is created but does not point to anything until the cursor is opened, at which point memory is allocated and the cursor structure is populated.

Uploaded by

Ridho Wijaya
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
117 views

Oracle 9i Cursor

A cursor in PL/SQL represents a private SQL area or context area in memory that acts as a pointer or handle to retrieve and process data from a database table one row at a time. There are two types of cursors - implicit cursors which are automatically declared by PL/SQL for single row queries, and explicit cursors which must be declared, opened, and closed by the programmer to process multiple rows of data from a table. When a cursor is declared, a pointer variable is created but does not point to anything until the cursor is opened, at which point memory is allocated and the cursor structure is populated.

Uploaded by

Ridho Wijaya
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

PL/SQL Oracle 9i

CURSOR
For every SQL statement execution certain area in memory is allocated. PL/SQL al
low you to name this
area. This private SQL area is called context area or cursor. A cursor acts as a
handle or pointer into
the context area. A PL/SQL program controls the context area using the cursor. C
ursor represents a
structure in memory and is different from cursor variable.
When you declare a cursor, you get a pointer variable, which does not point any
thing. When the
cursor is opened, memory is allocated and the cursor structure is created. The c
ursor variable now
points the cursor. When the cursor is closed the memory allocated for the cursor
is released.
Cursors allow the programmer to retrieve data from a table and perform actions o
n that data one row
at a time. There are two types of cursors implicit cursors and explicit cursors.

Implicit cursors
For SQL queries returning single row PL/SQL declares implicit cursors. Implicit
cursors are simple
SELECT statements and are written in the BEGIN block (executable section) of the
PL/SQL. Implicit
cursors are easy to code, and they retrieve exactly one row. PL/SQL implicitly d
eclares cursors for all
DML statements. The most commonly raised exceptions here are NO_DATA_FOUND or
TOO_MANY_ROWS.
Syntax:
SELECT ename, sal INTO ena, esa FROM EMP WHERE EMPNO = 7844;
Note: Ename and sal are columns of the table EMP and ena and esa are the variabl
es
used to store ename and sal fetched by the query.

You might also like