What is a cursor in PL/SQL?

Written by shohal


Cursor is a memory variable, it take space with in row and 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:

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:

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

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.

*Here r_emp is record.

Cursor FOR Loops:


*for loop : for r_emp in c_emp loop.

About the author


Leave a Comment