What are cursors? Name four types of cursors and when each
one would be applied?

Answer Posted / khushboo rastogi

A cursor is a temporary work area created in the system memory when a SQL statement
is executed. A cursor contains information on a select statement and the rows of data
accessed by it. This temporary work area is used to store the data retrieved from the
database, and manipulate this data. A cursor can hold more than one row, but can process
only one row at a time. The set of rows the cursor holds is called the active set.

There are two types of cursors in PL/SQL:

Implicit cursors:

These are created by default when DML statements like, INSERT, UPDATE, and
DELETE statements are executed. They are also created when a SELECT statement that
returns just one row is executed.

Explicit cursors:

They must be created when you are executing a SELECT statement that returns more
than one row. Even though the cursor stores multiple records, only one record can be
processed at a time, which is called as current row. When you fetch a row the current row
position moves to next row.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between view and materialized view?

531


How to transfer data from a cursor to variables with a "fetch" statement?

581


Where is localdb stored?

549


How many tables can be joined in SQL Server?

584


How to use subqueries with the exists operators in ms sql server?

579






What is the purpose of object explorer and its features? : sql server management studio

592


What is the security principal at the server level that represents your session?

551


What are triggers? How do you invoke a trigger on demand?

744


What are click through reports?

99


How will you find out if there are expensive SQL statements running or not?

572


What is the maximum size of sql server database?

496


What is the difference between createstatement and preparedstatement?

486


What is the new security features added in sql server 2016? : sql server security

610


Define self join in sql server joins?

514


what changed between the previous version of sql server and the current version? : Sql server database administration

513