Machine-translated by Google. Questions are authored in English.
Top

Discussion

In what correct order must the following PL/SQL cursor operations be performed ?

  • A.OPEN → DECLARE → FETCH → CLOSE
  • B.DECLARE → FETCH → OPEN → CLOSE
  • C.OPEN → FETCH → DECLARE → CLOSE
  • D.DECLARE → OPEN → FETCH → CLOSE

Answer: D

The correct order is DECLARE → OPEN → FETCH → CLOSE.

An explicit cursor is first declared with its query in the declaration section. OPEN then runs the query and identifies the result set. FETCH retrieves the rows one at a time into variables, usually in a loop until %NOTFOUND. CLOSE finally releases the cursor's resources.

A cursor cannot be opened before it is declared, and nothing can be fetched before it is opened, so every other order fails at its first step.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.