有时在INSERT期间,我收到来自SQLExecute()的非常奇怪的错误消息。我不知道如何处理这个,其他查询都可以。
日志
[ODBC][67383][1485443238.457802][SQLPrepare.c][196]
Entry:
Statement = 0x101022600
SQL = [INSERT INTO Core_Message(channel_id, date, member_id, reply_id) VALUES(25, '2017-01-26 18:07:18', 4, NULL)
][length = 109 (SQL_NTS)]
[ODBC][67383][1485443238.457893][SQLPrepare.c][377]
Exit:[SQL_SUCCESS]
[ODBC][67383][1485443238.458014][SQLExecute.c][187]
Entry:
Statement = 0x101022600
[ODBC][67383][1485443238.458189][SQLExecute.c][357]
Exit:[SQL_ERROR]
DIAG [HY000] no error information;
Error while preparing parameters
[ODBC][67383][1485443238.458543][SQLFreeHandle.c][381]
Entry:
Handle Type = 3
Input Handle = 0x101022600
[ODBC][67383][1485443238.458670][SQLFreeHandle.c][494]
Exit:[SQL_SUCCESS]
代码
SQLLEN length(0);
if (!isSuccess(SQLPrepare(_statement, (unsigned char *)query.c_str(), SQL_NTS))) {
_status = StatementStatus::Fault;
return false;
}
for (std::size_t i=0; i<reference_vector.size(); i++) {
length = reference_vector.at(i).get().length();
if (!isSuccess(SQLBindParameter(_statement, i + 1, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_VARBINARY, reference_vector.at(i).get().length(), 0, (char *)reference_vector.at(i).get().c_str(), (SQLLEN)reference_vector.at(i).get().length(), &length))) {
_status = StatementStatus::Fault;
return false;
}
}
if (!isSuccess(SQLExecute(_statement))) {
_status = StatementStatus::Fault;
return false;
}
在运行时不使用带有SQLBindParameter()事件的棘手块。
提前致谢。