将int64(SQL_BIGINT)绑定为查询参数会导致在Oracle 10g ODBC中执行期间出错

时间:2022-08-12 15:47:52

I've got an insert into a table using ODBC 3.0 on Oracle 10g that is failing and I have no idea why. The database is on Windows Server 2003. The client is on Windows XP.

我在Oracle 10g上使用ODBC 3.0插入到表中的操作失败,我不明白为什么。该数据库位于Windows Server 2003上。客户端位于Windows XP上。

The table:

CREATE TABLE test ( testcol NUMBER(20,0) NULL );

The ODBC calls:

ODBC调用:

SQLAllocHandle(SQL_HANDLE_STMT) = SQL_SUCCESS
SQLPrepare(INSERT INTO test (testcol) VALUES (?);) = SQL_SUCCESS

SQLINTEGER nStrLen = 0;
__int64 nInt64 = 99;
SQLBindParameter(hStatement, 1, SQL_PARAM_INPUT, 
    SQL_C_SBIGINT, SQL_BIGINT, 20, 0, &nInt64, 0, &nStrLen) = SQL_SUCCESS

SQLExecute() = SQL_ERROR
SQLGetDiagRec(1) = SQL_NO_DATA

SQLBindParameter succeeds but then SQLExecute fails. There is no diagnostic message.

SQLBindParameter成功,但SQLExecute失败。没有诊断信息。

I have had to resort to writing the int64 to a string and binding it as a string. Is this the only way to bind a int64?

我不得不求助于将int64写入字符串并将其绑定为字符串。这是绑定int64的唯一方法吗?

1 个解决方案

#1


4  

The Oracle 10g Admin Guide in Appendix G.1 says that the Oracle 10g ODBC driver does not support either SQL_C_SBIGINT or SQL_C_UBIGINT.

附录G.1中的Oracle 10g管理指南说Oracle 10g ODBC驱动程序不支持SQL_C_SBIGINT或SQL_C_UBIGINT。

Like you, we also find that at run time the SQLExecute() fails. And a call to SQLGetDiagRec() returns nothing, rather than a simple message like "Oracle 10g does not support SQL_C_SBIGINT", . Grr....

和你一样,我们也发现在运行时SQLExecute()失败了。并调用SQLGetDiagRec()不返回任何内容,而不是像“Oracle 10g不支持SQL_C_SBIGINT”这样的简单消息。格儿....

Anyway, the Appendix G.1 does not say how you should bind data to send into a table with a column defined like NUMBER(20). So we all have to guess, and use whatever (undocumented) technique works. It would be nice if the Appendix G.1 gave some kind of hint or suggestion as to the "best" way.

无论如何,附录G.1没有说明如何绑定数据以发送到具有NUMBER(20)定义列的表中。所以我们都必须猜测,并使用任何(未记录的)技术。如果附录G.1对“最佳”方式提出某种暗示或建议,那就太好了。

If converting the number to a string and then binding works for you, stick with that.

如果将数字转换为字符串然后绑定适合您,请坚持下去。

#1


4  

The Oracle 10g Admin Guide in Appendix G.1 says that the Oracle 10g ODBC driver does not support either SQL_C_SBIGINT or SQL_C_UBIGINT.

附录G.1中的Oracle 10g管理指南说Oracle 10g ODBC驱动程序不支持SQL_C_SBIGINT或SQL_C_UBIGINT。

Like you, we also find that at run time the SQLExecute() fails. And a call to SQLGetDiagRec() returns nothing, rather than a simple message like "Oracle 10g does not support SQL_C_SBIGINT", . Grr....

和你一样,我们也发现在运行时SQLExecute()失败了。并调用SQLGetDiagRec()不返回任何内容,而不是像“Oracle 10g不支持SQL_C_SBIGINT”这样的简单消息。格儿....

Anyway, the Appendix G.1 does not say how you should bind data to send into a table with a column defined like NUMBER(20). So we all have to guess, and use whatever (undocumented) technique works. It would be nice if the Appendix G.1 gave some kind of hint or suggestion as to the "best" way.

无论如何,附录G.1没有说明如何绑定数据以发送到具有NUMBER(20)定义列的表中。所以我们都必须猜测,并使用任何(未记录的)技术。如果附录G.1对“最佳”方式提出某种暗示或建议,那就太好了。

If converting the number to a string and then binding works for you, stick with that.

如果将数字转换为字符串然后绑定适合您,请坚持下去。