what is cursor in plsql

what is cursor in plsql

1 year ago 43
Nature

In PL/SQL, a cursor is a pointer to a private SQL area that stores information about the processing of a SELECT or data manipulation language (DML) statement (INSERT, UPDATE, DELETE, or MERGE) . A cursor is used to fetch and process the rows returned by the SQL statement, one at a time. There are two types of cursors in PL/SQL:

  • Implicit Cursors: These 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.

  • Explicit Cursors: These 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. Working with an explicit cursor includes the following steps: declaring the cursor for initializing the memory, opening the cursor for allocating the memory, fetching the data from the cursor into PL/SQL variables or records, and closing the cursor before ending the PL/SQL Block.

In summary, a cursor in PL/SQL is a pointer to a private SQL area that stores information about the processing of a SELECT or DML statement. It is used to fetch and process the rows returned by the SQL statement, one at a time. There are two types of cursors in PL/SQL: implicit cursors and explicit cursors. Implicit cursors are automatically created by Oracle, while explicit cursors are programmer-defined cursors for gaining more control over the context area.

Read Entire Article