Optimize OPEN, FETCH, and CLOSE
When the HCL
OneDB™ ESQL/C application
uses DECLARE and OPEN statements to execute a cursor, each statement
involves a round trip of message requests between the application
and the database server. The optimize-OPEN-FETCH-CLOSE feature (OPTOFC)
reduces the number of round trips by two, as follows:
- HCL
OneDB ESQL/C saves
one round trip because it does not send the OPEN statement as a separate
command.
When HCL OneDB ESQL/C 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 HCL OneDB ESQL/C 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.
- HCL
OneDB ESQL/C 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, HCL OneDB ESQL/C does not need to send the CLOSE statement to the database server.
Important: HCL
OneDB ESQL/C does
not send the CLOSE statement to the database server. However, if you
include the CLOSE statement, no error is generated.