Size the cursor buffer
The cursor buffer is the buffer that the application uses to hold the data (except simple large-object data) in a cursor.
- The fetch buffer holds data from a select or function cursor.
When the database server returns rows from the active set of a query, stores these rows in the fetch buffer.
- The insert buffer holds data for an insert cursor.
stores the rows to be inserted in the insert buffer then sends this buffer as a whole to the database server for insertion.
- 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.
- Retrieves the rows from the database server and puts them in the fetch buffer.
- 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.
- Put the data from the first PUT statement into the insert buffer.
- 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 insert buffer is full
- It executes the FLUSH statement on the insert cursor
- It executes the CLOSE statement on the insert cursor