Optimize OPEN, FETCH, and CLOSE
- saves
one round trip because it does not send the OPEN statement as a separate
command.
When executes the OPEN statement, it does not open the cursor. Instead, it saves any input value that was supplied in the USING clause of the OPEN statement. When executes the initial FETCH statement, it sends this input value along with the FETCH statement. The database server opens the cursor and returns the first value in this cursor.
- saves
a second round trip because it does not send the CLOSE statement as
a separate command.
When the database server reaches the last value of an open cursor, it automatically closes the cursor after it sends the last value to the client application. Therefore, does not need to send the CLOSE statement to the database server.