To open a cursor for updates or deletes, you can set a statement attribute called SQL_ATTR_CONCURRENCY to SQL_CONCUR_LOCK:
SQLSetStmtAttr(stmt,SQL_ATTR_CONCURRENCY,(SQLPOINTER) SQL_CONCUR_LOCK,0);
The following code fragment from the cursor sample illustrates using cursors for updates and deletes. Error checking has been omitted for clarity. For the complete code, refer to the cursor.cpp sample.
/* 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) ;