Using Client-Library cursors

A typical application uses the steps below to declare and open a Client-Library cursor.

  1. Send a cursor-declare command.

    For cursors declared with a select statement:

    For cursors declared with an execute statement:

    For cursors declared with a prepared dynamic SQL statement:

  2. (Optional) Send a cursor-rows command.

  3. Send a cursor-open command.

    A successful open command returns a CS_CURSOR_RESULT result set. If batching commands, several calls to ct_results are required (to retrieve the status results from the batched commands) before the cursor rows are available.

  4. Process cursor rows.

  5. Close the cursor.

    An application can close and deallocate the cursor with one command by setting the CS_DEALLOC bit in the ct_cursor option parameter when defining the cursor-close command. In that case, the step 6 is unnecessary.

  6. Deallocate the cursor.

Each step in the process above sends one Client-Library cursor command to the server. After sending each command, the application must handle the results with ct_results. Code your application to handle the results of a cursor command with a standard results loop, as discussed in “Structure of the basic loop”.