Reopening a cursor

After the results of a cursor-open command have been processed, the previous cursor-open command can be restored with a single ct_cursor call (with the syntax described below). The restore operation readies the command structure to send the previous cursor-open command. The following command information is restored:

Cursor-declare commands that were batched with the cursor-open command are not restored.

An application restores a cursor-open command by calling ct_cursor with type as CS_CURSOR_OPEN and option as CS_RESTORE_OPEN. Most applications use the program structure below to restore and send a cursor-open command.

 /*
 ** Assign new variables in the program variables
 ** bound with ct_setparam.
 */
 ... assignment statement for each parameter
      source variable ...
ct_cursor(CS_CURSOR_OPEN, ..., CS_RESTORE_OPEN)
 ct_send
 ... handle cursor results ...

You can also reopen a cursor by initiating a new cursor open command (preceded by a cursor-rows command if necessary). However, applications that restore the previous command can eliminate several Client-Library calls.