Updating Cursors
Data is usually modified one row at a time (there is an option in SQLSetPos to affect the entire rowset) by first positioning to the desired row. To position the cursor on a particular row, you can:
-
Call SQLFetch one or more times.
-
Call SQLExtendedFetch one or more times.
-
Call SQLSetPos with the SQL_POSITION option.
There are two ways of modifying data in the results set:
-
You can issue an UPDATE WHERE CURRENT OF cursor_name or DELETE WHERE CURRENT OF cursor_name to update or delete the row currently pointed to by the cursor. The positioned UPDATE or DELETE statement must be issued on a separate hstmt on the same connection, and it requires the cursor name (which you can explicitly set using the SQLSetCursorName function). This allows you to work with several cursors simultaneously.
-
You can use the SQLSetPos function to add, delete, and update rows of data. The SQLSetPos API provides options to specify the desired operation, the target row number, and how to lock the row. SQLSetPos can only be used on row sets that are fetched with SQLExtendedFetch.
The following ODBC functions are relevant:
SQLSetPos
SQLRowCount