What is a cursor and when should you use one?

Untitled Forums Programming Assignment Help What is a cursor and when should you use one?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #8564
    Aakanksha
    Participant

    What is a cursor and when should you use one?

    #15595
    aastha
    Member

    Cursor in SQL is a temporary work area that is created in the system memory whenever the SQL statement is executed. This contain information of the statement you selected and the row of the data accessed by it. Basically the temporary work area is used to store the data received from the database, and manipulate it. A cursor have a capability to hold more than one row, but process only one row at a time. Cursor hold the set of row that known as active set. Cursor is mainly of two type Implicit and Explicit.

    When cursor should be used by implicit and explicit way

    Implicit
    Implicit cursors are created by default when the statements like INSERT, UPDATE, DELETE all DML statements are executed. When they are created? When the SELECT statement that returns just one row is executed.

    Explicit
    Explicit cursor is used when SELECT statement is executing and returning more than one row. This cursor is able to store multiple records that can be processed at a time which are known as current row. Once the row is fetched then cursor move to the next row.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.