0% found this document useful (0 votes)
26 views2 pages

Cursors

A cursor is a pointer to a memory location called a context area that contains information for processing a SQL statement, including the number of rows and a pointer to the parsed statement. A cursor has two parts - a header with the cursor name, parameters, and data type, and a body with the SQL statement. Cursors can be implicit, explicit, parameterized, or reference cursors and go through open, fetch, and close stages. Cursors have attributes like %found, %notfound, and %rowcount and can be declared and used in simple, while, and for loops.

Uploaded by

chowdarylikes
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 DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

Cursors

A cursor is a pointer to a memory location called a context area that contains information for processing a SQL statement, including the number of rows and a pointer to the parsed statement. A cursor has two parts - a header with the cursor name, parameters, and data type, and a body with the SQL statement. Cursors can be implicit, explicit, parameterized, or reference cursors and go through open, fetch, and close stages. Cursors have attributes like %found, %notfound, and %rowcount and can be declared and used in simple, while, and for loops.

Uploaded by

chowdarylikes
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 DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

CURSORS

Cursor is a pointer to memory location which is called as context area which contains the information necessary for processing, including the number of rows processed by the statement, a pointer to the parsed representation of the statement, and the active set which is the set of rows returned by the query. Cursor contains two parts Header Body Header includes cursor name, any parameters and the type of data being loaded. Body includes the select statement. Ex: Cursor c(dno in number) return dept%rowtype is select *from dept; In the above Header cursor c(dno in number) return dept%rowtype Body select *from dept CURSOR TYPES Implicit (SQL) Explicit Parameterized cursors REF cursors CURSOR STAGES Open Fetch Close

CURSOR ATTRIBUTES %found %notfound %rowcount %isopen %bulk_rowcount %bulk_exceptions

CURSOR DECLERATION Syntax: Cursor <cursor_name> is select statement; Ex: Cursor c is select *from dept; CURSOR LOOPS Simple loop While loop For loop


SIMPLE LOOP

Syntax: Loop Fetch <cursor_name> into <record_variable>; Exit when <cursor_name> % notfound; <statements>; End loop;

You might also like