Updating and Deleting Rows Through a Cursor

Set the statement attribute SQL_ATTR_CONCURRENCY to SQL_CONCUR_LOCK to open a cursor to update or delete rows.

SQLSetStmtAttr(stmt,SQL_ATTR_CONCURRENCY,(SQLPOINTER)
   SQL_CONCUR_LOCK,0);

This code fragment from the cursor sample illustrates using cursors for updates and deletes. Error checking has been omitted for clarity.

/* Set statement attribute for an updateable cursor */
SQLSetStmtAttr(stmt, SQL_ATTR_CONCURRENCY,
   (SQLPOINTER)SQL_CONCUR_LOCK, 0);
SQLSetCursorName(stmt1, "CustUpdate", SQL_NTS);
SQLExecDirect(stmt1, "select LastName 
   from t_CursorTable ", SQL_NTS) ;
SQLFetch(stmt1);
SQLExecDirect(stmt2, "Update t_CursorTable" 
   "set LastName='UpdateLastName'"
   "where current of CustUpdate", SQL_NTS) ;

For the complete code, refer to the cursor.cpp sample.