Thread: SQL_CONCUR_LOCK not supported ?
Hi again !
I am sorry that I have to bother you all with my porting problems again.
In our backend we create special cursors for row locks like this (works fine with MSSQL):
SQLAllocStmt(); // Create the cursor
SQLSetStmtAttr(SQL_ATTR_MAX_ROWS, 1); // The lock cursor only delivers one row
SQLSetStmtAttr(SQL_ATTR_CURSOR_TYPE, SQL_CURSOR_FORWARD_ONLY);
SQLSetStmtAttr(SQL_ATTR_CONCURRENCY, SQL_CONCUR_LOCK); // Lock mode that other cursor of this type will fail
// !!! Postgres changes this to SQL_CONCUR_ROWVER with "01S02 Requested value changed" !!!
SQLSetStmtAttr(SQL_ATTR_QUERY_TIMEOUT, 1); // Timeout to return when a lock occours
SQLPrepare("SELECT col FROM table WHERE col = ? FOR UPDATE");
SQLBindCol();
SQLBindParameter();
SQLExecute(); // Lock the specified row and prevent that SELECT FOR UPDATE from other users succeeds
// !!! Postgre brings here "01S02: cursor updatability changed"
Do I have to change the way to lock rows ?
I tested it with the actual PostgreSQL 9.2 and ODBC.
Big thanks in advance.
Regards
Johann