10. Understanding ODBC Connectivity : ODBC Programming : Fetched Data : Updatable Cursors
 
Share this page                  
Updatable Cursors
For a cursor to be made updatable, the ODBC Driver imposes a set of syntax rules:
The cursor must be explicitly named via SQLSetCursorName().
SQLSetStmtAttr() must be invoked with SQL_ATTR_CONCURRENCY specified as SQL_CONCUR_VALUES.
The update statement must include the "where current of" clause and refer to the cursor name declared in SQLSetCursorName().
The following code highlights the minimum code required to declare an updatable cursor:
SQLSetCursorName( hstmtS, /* Select statement handle */
    "C1",                 /* Cursor Name */
    SQL_NTS );            /* This is a null-terminated string */
 
SQLSetStmtAttr( hstmtS, SQL_ATTR_CONCURRENCY,
    (SQLPOINTER)SQL_CONCUR_VALUES, 0 );
 
SQLExecDirect ( hstmtS,
    "select model from cars where model = 'Hummer '",
    SQL_NTS );
 
SQLExecDirect( hstmtU,
    "UPDATE cars SET model = 'HummV ' WHERE CURRENT OF C1",
    SQL_NTS );