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

发布于 2024-07-09 14:08:14 字数 710 浏览 5 评论 0原文

我在 Oracle 10g 上使用 ODBC 3.0 插入表失败,我不知道为什么。 数据库运行在Windows Server 2003上。客户端运行在Windows XP上。

表:

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

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 成功,但 SQLExecute 失败。 没有诊断消息。

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

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.

The table:

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

The ODBC calls:

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.

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掩于岁月 2024-07-16 14:08:14

附录 G.1 表示 Oracle 10g ODBC 驱动程序不支持SQL_C_SBIGINTSQL_C_UBIGINT

和您一样,我们也发现在运行时 SQLExecute() 失败。 调用 SQLGetDiagRec() 不会返回任何内容,而是返回一条简单的消息,如“Oracle 10g 不支持 SQL_C_SBIGINT”。 呃……

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

如果将数字转换为字符串然后进行绑定对您有用,请坚持这样做。

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.

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....

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.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文