Oracle SQL,PL/SQL

What is a cursor in PL/SQL?

what is cursor in pl
Written by shohal

Cursor:

Cursor is a memory variable, it take space with in row and column.it also can take matrix data.

Also ,A cursor is a pointer that points to a result of a query.

PL/SQL has two types of cursors:

â€ĸImplicit cursors

â€ĸExplicit cursors

Implicit Cursors

Whenever Oracle executes an SQL statement such as Select Into , Insert , Update  and Delete it automatically creates an implicit cursor.

Implicit Cursors Example:

implicity Cursor
Here employee_id,first_name insert into the variable v_emp,v_name. This is a select into implicit cursor example.

Explicit cursors

An explicit cursor is an Select statement declared explicitly in the declaration section of the current block or a package specification.

Explicit cursors Example:

Explicit Cursor Example 1
Here select statement work within cursor c_emp. Open cursor then fetch insert into the variable and close the c_emp.

Cursor with parameters:

Example:

Cursor with parameters

PLSQL Records and Cursor:

Difference between records and cursor is : Cursor take data from direct table where records take data from cursor.

PLSQL Records and Cursor
*Here r_emp is record.

Cursor FOR Loops:

Example:

Cursor FOR Loops
*for loop : for r_emp in c_emp loop.

About the author

shohal

Leave a Comment