Monday, February 20, 2012

ODBC inserting against open cursor

Im receiving 'HY000 Connection is busy with results for another hstmt' when trying to insert. The reason is down to another hstmt with a cursor still open (as not all results have been fetched) against the same connection handle. My current design is one connect handle per file, with multiple statement handle depending on sql issued so i dont need to rebind.
I'm guessing, but is there a sqlsetconnectattr/sqlsetstmtattr setting to which will allow me to insert/update/delete to a file with a open cursor that may include the result ?

sqlserver version 8So more like you've locked the rows...

Look at sp_lock...|||doesnt seem like a locking issue, as cant insert. sp_lock shows one new process with a lock mode S (presume shared, to which insert should be ok)

my sql generated ..

DECLARE KSQL$001_00 CURSOR FOR SELECT ROWID,KEY_1A,KEY_5A,KEY_NUM
BER,SOMETHING FROM A2R.DBO.CJS ORDER BY KEY_5A,KEY_NUMBER,KEY_1A

OPEN KSQL$001_00

FETCH KSQL$001_00

INSERT INTO A2R.DBO.CJS(KEY_1A,KEY_5A,KEY_NUMBER,SOMETHING) VALUES (?,?,?,?)

[Microsoft][ODBC SQL Server Driver]Connection is busy with results for another h
stmt
****************************
HY000

The above is fine via SQLQuery (note: ? are sqlbindparameter), but not ODBC?|||In RDO it used to be rdOpenForwardOnly resultset qualifier that would allow you to issue action queries on the same connection while the resultset mentioned above is open.|||Cheers for pointing me in the right direction,
I needed to issue the following, which now allows insert etc with open cursors.

SQLSetStmtAttr(vsql_area.current_logon->stmt_current>hstmt,
SQL_ATTR_CURSOR_SENSITIVITY,
SQL_INSENSITIVE,
1);

Regards,
Carl.

No comments:

Post a Comment