Explain cursor types?

devquora
devquora

Posted On: Feb 22, 2018

 

There are two types of PL/SQL cursors -

Explicit cursors– Explicit cursors are used for queries that return more than one row. It is a programmer-defined cursor for gaining more control over context area. In order to use explicit cursors, the following steps are used-

Declare the cursor,

Syntax: CURSOR <cursor_name> is

SELECT statement;

Here, cursor name is the name given to the cursor and SELECT is used for returning rows to cursor active set.

Open the cursor

Syntax: OPEN <cursor_name>

Where <cursor_name> is name of previously-defined cursor.

Fetch rows from the cursor

Syntax: FETCH <cursor_name> INTO <record_list>

Close the cursor

Syntax: CLOSE <cursor_name>

Implicit cursors- These cursors are created when any SQL statements are executed. PL/SQL uses following implicit cursors-

  • INSERT
  • UPDATE
  • DELETE
  • SELECT

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    PL/SQL Interview Questions

    What is PL/SQL?

    PL/SQL stands for Procedural Language extension of Structured Query Language (SQL). It is a block-structured language ha..

    PL/SQL Interview Questions

    Differentiate between PL/SQL and SQL?

    PL/SQL is Oracle’s Procedural Language SQL which allows you to write full programs to execute options like insert/ sel..

    PL/SQL Interview Questions

    State few characteristics of PL/SQL?

    Some of the characteristics of PL/SQL are furnished below: PL/SQL is completely portable as code can be executed on any ..