UPDATE & Incorrect SQLRowCount() on Informix 7.2 Intersolv ODBC 3.11
Posted in 1998
Topics: Connectivity: ODBC / JDBC / .NET
Hi, Here's a code "fragment" that exemplifies a problem we're experiencing with Informix (7.2) accessed through Intersolv 3.11 (EVAL version) ODBC drivers. The problem is the fact that a prepared UPDATE statement after having been successfully executed once (rowcount <> 0), with 'new parameter bindings' keeps reporting the rowCount of the initial SQLExecute(), whereas the new parameter bindings don't match any records (rowcount should be 0). The code, which is adapted from our C++ application to a VB version runs finde with Informix' ODBC driver (ver. 2.80). The code creates its own table and data and drops that afterwards. Since we have other problems using Informix' driver this is still very important to us. Has anyone seen anything like this? I don't think we're doing anything wrong here, since this code runs fine with other databases/drivers. The problem the code below turns up is that the second time SQLRowCount() is called, 1 is returned, where 0 was expected. Thankful for any pointers/leads, Jorik de Wit retcode = SQLAllocStmt(hdbc1, hstmt) If retcode <> SQL_SUCCESS Then Err.Raise retcode stmt = "CREATE TABLE a (i SMALLINT, j CHAR(1))" retcode = SQLExecDirect(hstmt, stmt, Len(stmt)) If retcode <> SQL_SUCCESS Then Err.Raise retcode retcode = SQLFreeStmt(hstmt, SQL_CLOSE) If retcode <> SQL_SUCCESS Then Err.Raise retcode stmt = "INSERT INTO a VALUES(1, 'a')" retcode = SQLExecDirect(hstmt, stmt, Len(stmt)) If retcode <> SQL_SUCCESS Then Err.Raise retcode retcode = SQLFreeStmt(hstmt, SQL_DROP) If retcode <> SQL_SUCCESS Then Err.Raise retcode 'NEW handle here!? retcode = SQLAllocStmt(hdbc1, hstmt) If retcode <> SQL_SUCCESS Then Err.Raise retcode retcode = SQLTransact(henv1, hdbc1, SQL_COMMIT) If retcode <> SQL_SUCCESS Then Err.Raise retcode stmt = "UPDATE a SET j='b' WHERE i=?" retcode = SQLPrepare(hstmt, stmt, Len(stmt)) If retcode <> SQL_SUCCESS Then Err.Raise retcode Dim i As Integer Dim ii As Integer Dim pcrow As Long pcbValue = 0 i = 1 retcode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_SHORT, SQL_SMALLINT, _ 2, 0, i, 0, pcbValue) If retcode <> SQL_SUCCESS Then Err.Raise retcode retcode = SQLExecute(hstmt) If retcode <> SQL_SUCCESS Then Err.Raise retcode retcode = SQLRowCount(hstmt, pcrow) If retcode <> SQL_SUCCESS Then Err.Raise retcode Debug.Print pcrow retcode = SQLFreeStmt(hstmt, SQL_CLOSE) If retcode <> SQL_SUCCESS Then Err.Raise retcode ii = 2 retcode = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_SHORT, SQL_SMALLINT, _ 2, 0, ii, 0, pcbValue) If retcode <> SQL_SUCCESS Then Err.Raise retcode retcode = SQLExecute(hstmt) 'Accept success_with_info (Informix' driver returns that with -11008 (no rows updated)). If retcode <> SQL_SUCCESS And retcode <> SQL_SUCCESS_WITH_INFO Then Err.Raise retcode End If retcode = SQLRowCount(hstmt, pcrow) If retcode <> SQL_SUCCESS Then Err.Raise retcode Debug.Print pcrow '''HERE WE GET 1 INSTEAD OF THE EXPECTED ZERO !! retcode = SQLFreeStmt(hstmt, SQL_CLOSE) If retcode <> SQL_SUCCESS Then Err.Raise retcode stmt = "DROP TABLE a" retcode = SQLExecDirect(hstmt, stmt, Len(stmt)) retcode = SQLFreeStmt(hstmt, SQL_DROP) If retcode <> SQL_SUCCESS Then Err.Raise retcode hstmt = SQL_NULL_HSTMT retcode = SQLTransact(henv1, hdbc1, SQL_COMMIT) If retcode <> SQL_SUCCESS Then Err.Raise retcode -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own