[unixODBC-support] Correct closing the cursor

Nick Gorham nick.gorham at easysoft.com
Mon Apr 19 11:06:12 BST 2010


Daniil A Megrabjan wrote:
> Hello
>
> I'm using Sybase Anywhere 9 driver with unixODBC. I do a simple query
> SELECT * FROM TABLE1, and then I close the cursor. The problem is that
> after closing the shared lock remains, that is why I can not write
> anything in this table. How I must close cursors correctly, any
> ideas?!
>
> Now.
>
> Open:
> ====
> SQLAllocHandle(SQL_HANDLE_STMT, Connection->DbcHandle, &Stmt);
> SQLSetStmtAttr(Stmt, SQL_ATTR_CURSOR_SENSITIVITY, (void *) SQL_INSENSITIVE, 0);
> SQLSetStmtAttr(Stmt, SQL_ATTR_CONCURRENCY, (void *) SQL_CONCUR_READ_ONLY, 0);
> SQLSetStmtAttr(Stmt, SQL_ATTR_USE_BOOKMARKS, (void *) SQL_UB_VARIABLE, 0);
> SQLSetStmtAttr(Stmt, SQL_CURSOR_TYPE, (void *) SQL_CURSOR_KEYSET_DRIVEN, 0);
> SQLPrepare(Stmt, (unsigned char *) SQL, SQL_NTS);
> SQLExecute(Stmt);
>
> Close:
> ====
> SQLCloseCursor(Stmt);
> SQLFreeStmt(Stmt, SQL_UNBIND);
> SQLFreeHandle(SQL_HANDLE_STMT, Stmt);
> Stmt = SQL_NULL_HANDLE;
>
>   
Well, AFAIKS what you are doing should close the cursor and release any 
locks. I would guess some magic in the driver. Maybe try a

SQLFreeStmt(Stmt, SQL_CLOSE);

instead of the SQLCloseCursor and see if thats any better.

-- 
Nick




More information about the unixODBC-support mailing list