Re: SELECT FOR UPDATE in ESQL/C?
Posted in 1995
In article <Cs1Yw0ElJXBI083yn@kcbbs.gen.nz> kerry@kcbbs.gen.nz (Kerry Sainsbury) writes: >I was just wondering how "SELECT ... FOR UPDATE" in conjunction with >"UPDATE ... WHERE CURRENT OF" works in languages using embedded SQL. > >How does the "WHERE CURRENT OF" bit get the cursor information from? > >(I want to use this via ODBC, but can't figure out how to do it yet) ODBC allows an application to explicitly name a cursor via SQLSetCursorName(). If not explicitly named by the application, the driver will create a cursor name for you after a successful SQLPrepare()+SQLExecute() or SQLExecDirect(). on the 'SELECT ... FOR UPDATE' statement. You obtain the cursor name currently associated with a statement via SQLGetCursorName(). On another ODBC statement, the application then uses the cursor name within the text of the "UPDATE WHERE CURRENT OF cursorname" statement. Of course you need to do some fetches before the update so that there will be something to update. If you are using SQLExtendedFetch() to fetch multiple rows, then you must do a SQLSetPos(SQL_POSITION, ...) with the specific row number within the rowset before the "UPDATE WHERE CURRENT OF cursorname". If this is not enough detail, let me know. I strongly recommend the Microsoft ODBC 2.0 Programmer's Reference. Scott