One of the SELECT crashes using unixOdbc - SQLSTATE [24000]: invalid cursor state

I am running Ubuntu 13.10 with FreeTDS and ODBC (package: php5-odbc). I am using tds version = 8.0, but also tried tds version = 7.2.

I am using PDO and this is my DSN:

$dsn = sprintf('odbc:Driver=FreeTDS;Server=%s;Port=1433;Database=%s', DB_SQL_SERVERNAME, DB_DB_NAME); 

I connect to an MSSQL instance and execute some INSERT / SELECT queries using transactions, however I cannot understand why this query fails:

 SELECT id FROM tblColumns WHERE siteID = 10063 AND typeID = 1000 AND extendedTypeID = 18 AND label = 'RwThiFc85A' 

error:

SQLSTATE [24000]: Invalid cursor state: 0 [FreeTDS] [SQL Server] Invalid cursor state (SQLExecute [0] at / build / buildd / php 5-5.5.3 + dfsg / ext / pdo_odbc / odbc_stmt.c: 254)

I run bundles of similar queries before, and they execute well, for example:

 SELECT id FROM tblColumns WHERE siteID = 10063 AND typeID = 1000 AND extendedTypeID = 3 AND label = 'VwThiFc91B' 

Do you have any idea why this is happening?

I had no such problems with dblib and sqlsrv, but now I am on Unix and can not use sqlsrv, and due to problems with dblib encoding UTF-8 I am trying to use ODBC.

+6
source share
1 answer

It looks like you are simultaneously opening two different sets of results. You must finish processing the first ResultSet and close it so that you can reuse the Statement to create the second ResultSet.

+7
source

All Articles