After an application has fetched a block of data with SQLFetchScroll, it can update or delete the data in the block. To execute a positioned update or delete, the application:
UPDATE table-name
SET column-identifier = {expression | NULL}
[, column-identifier = {expression | NULL}]
WHERE CURRENT OF cursor-name
DELETE FROM table-name WHERE CURRENT OF cursor-name
The easiest way to construct the SET clause in a positioned update statement is to use parameter markers for each column to be updated and use SQLBindParameter to bind these to the rowset buffers for the row to be updated. In this case, the C data type of the parameter will be the same as the C data type of the rowset buffer.
Caution If the application does not correctly update the rowset buffers before executing a positioned update statement, the data in the cache will be incorrect after the statement is executed.
Caution The WHERE clause constructed by the cursor library to identify the current row can fail to identify any rows, identify a different row, or identify more than one row. For more information, see “Constructing Searched Statements” later in this appendix.
All positioned update and delete statements require a cursor name. To specify the cursor name, an application calls SQLSetCursorName before the cursor is opened. To use the cursor name generated by the driver, an application calls SQLGetCursorName after the cursor is opened.
After the cursor library executes a positioned update or delete statement, the status array, rowset buffers, and cache maintained by the cursor library contain the values shown in the following table.
Statement used |
Value in row status array |
Values in rowset buffers |
Values in cache buffers |
Positioned update | SQL_ROW_UPDATED | New values [1] | New values [1] |
Positioned delete | SQL_ROW_DELETED | Old values | Old values |
[1]The application must update the values in the rowset buffers before executing the positioned update statement; after executing the positioned update statement, the cursor library copies the values in the rowset buffers to its cache.