Size the cursor buffer

The cursor buffer is the buffer that the Informix® ESQL/C application uses to hold the data (except simple large-object data) in a cursor.

Informix ESQL/C has the following uses for the cursor buffer:
  • The fetch buffer holds data from a select or function cursor.

    When the database server returns rows from the active set of a query, Informix ESQL/C stores these rows in the fetch buffer.

  • The insert buffer holds data for an insert cursor.

    Informix ESQL/C stores the rows to be inserted in the insert buffer then sends this buffer as a whole to the database server for insertion.

With a fetch buffer, the client application performs the following tasks:
  1. Sends the size of the buffer to the database server and requests rows when it executes the first FETCH statement.

    The database server sends as many rows that can fit in the fetch buffer to the application.

  2. Retrieves the rows from the database server and puts them in the fetch buffer.
  3. Takes the first row out of the fetch buffer and puts the data in the host variables that the user has provided.

For subsequent FETCH statements, the application checks whether more rows exist in the fetch buffer. If they do, it takes the next row out of the fetch buffer. If no more rows are in the fetch buffer, the application requests more rows from the database server, sending the fetch-buffer size.

The client application uses an insert buffer to perform the following tasks:
  1. Put the data from the first PUT statement into the insert buffer.
  2. Check whether more room exists in the insert buffer for subsequent PUT statements.

    If more rows can fit, the application puts the next row into the insert buffer. If no more rows can fit into the insert buffer, the application sends the contents of the insert buffer to the database server.

The application continues this procedure until no more rows are put into the insert buffer. It sends the contents of the insert buffer to the database server when:
  • The insert buffer is full
  • It executes the FLUSH statement on the insert cursor
  • It executes the CLOSE statement on the insert cursor