绑定 int64 (SQL_BIGINT) 作为查询参数会导致在 Oracle 10g ODBC 中执行期间出错
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
附录 G.1 表示 Oracle 10g ODBC 驱动程序不支持
SQL_C_SBIGINT
或SQL_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
orSQL_C_UBIGINT
.Like you, we also find that at run time the
SQLExecute()
fails. And a call toSQLGetDiagRec()
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.