SELECT之一使用unixOdbc失败-SQLSTATE [24000]:无效的游标状态 [英] One of the SELECT fails using unixOdbc - SQLSTATE[24000]: Invalid cursor state

查看:84
本文介绍了SELECT之一使用unixOdbc失败-SQLSTATE [24000]:无效的游标状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行装有FreeTDS和ODBC(软件包:php5-odbc)的Ubuntu 13.10. 我使用的是tds版本= 8.0,但也尝试过使用tds版本= 7.2.

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

我正在使用PDO,这是我的DSN:

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);

我连接到MSSQL实例并使用事务执行一些INSERT/SELECT查询,但是我无法弄清楚该查询失败的原因:

I connect to MSSQL instance and perform some INSERT/SELECT queries using transactions, however I can not figure out why this query fails:

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

给出错误:

SQLSTATE [24000]:无效的游标状态:0 [FreeTDS] [SQL Server]无效 游标状态(SQLExecute [0]位于 /build/buildd/php5-5.5.3+dfsg/ext/pdo_odbc/odbc_stmt.c:254)

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

我之前运行过许多类似的查询,它们的执行效果很好,例如:

I am running bunches of similiar queries before and they are performed well, e.g.:

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

您是否知道为什么会发生?

Do you have ideas why it happens?

我在dblib和sqlsrv上没有这样的问题,但是现在我在Unix上并且不能使用sqlsrv,并且由于dblib UTF-8编码的问题,我试图使用ODBC.

I did not have such a issues with dblib and sqlsrv, however now I am on Unix and can not use sqlsrv, and due to issues with dblib UTF-8 encoding I am trying to use ODBC.

推荐答案

看起来您同时打开了两个不同的结果集.您必须完成第一个ResultSet的处理并将其关闭,以便可以重新使用Statement创建第二个ResultSet.

It looks you have two different result sets open at the same time. You have to finish processing your first ResultSet and close it so you can re-use the Statement to create the second ResultSet.

这篇关于SELECT之一使用unixOdbc失败-SQLSTATE [24000]:无效的游标状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆