这适用于 ASE 15.7 和 ESQL/C。使用准备好的语句更新 CURSOR 中的一行:
EXEC SQL BEGIN DECLARE SECTION;
CS_IMAGE image[512];
EXEC SQL END DECLARE SECTION;
strcpy(image, "foo");
EXEC SQL PREPARE updt FROM "UPDATE image_test SET nettodaten = ? WHERE CURRENT OF hc_image_test";
EXEC SQL EXECUTE updt USING :image;
来自 ASE 的消息失败:
** SQLCODE=(-201)
** ASE Error
** Procedure *sq1625128094_1900377684ss* expects parameter
Invalid pointer param number 4, pointer value 0x(nil)
, which was not supplied.
这可能是什么原因?
更新 1
我稍微修改了 ESQL/C 代码,使其看起来像这样:
strcpy(anweisung, "UPDATE image_test SET katkey = ?, nettodaten = ? WHERE CURRENT OF hc_image_test");
EXEC SQL PREPARE updt FROM :anweisung;
EXEC SQL EXECUTE updt USING :key, :blobfld;
EXEC SQL CLOSE hc_image_test;
错误与上述相同。但是查看生成的 C 代码会CPRE
显示一个有趣的细节:
/*
** SQL STATEMENT: 17
** EXEC SQL EXECUTE updt USING :key, :blobfld;
*/
{
_SQL_CT_HANDLES * _sql;
_sqlinitctx(&_sql, CS_CURRENT_VERSION, CS_TRUE, &sqlca, (long
*)NULL, (CS_CHAR *)NULL);
if (_sql != (_SQL_CT_HANDLES *) NULL)
{
_sql->stmtData.persistent = CS_FALSE;
_sql->stmttype = SQL_EXECUTE;
_sql->connName.lnlen = CS_UNUSED;
_sql->stmtName.fnlen = 4;
strcpy(_sql->stmtName.first_name, "updt");
if ((_sql->retcode = _sqlprolog(_sql)) == CS_SUCCEED)
{
_sql->retcode = ct_dynamic(_sql->conn.command,
CS_EXECUTE, "updt", 4, NULL, CS_UNUSED);
if (_sql->retcode == CS_SUCCEED)
{
_sql->dfmtCS_INT_TYPE.count = 0;
_sql->dfmtCS_INT_TYPE.status = CS_INPUTVALUE;
_sql->retcode = ct_param(_sql->conn.command,
&_sql->dfmtCS_INT_TYPE, &key, (CS_INT)
CS_UNUSED, (CS_SMALLINT) 0);
_sql->dfmtCS_INT_TYPE.status = 0;
}
_sql->retcode = ct_send(_sql->conn.command);
_sql->hastate = (_sql->retcode == CS_RET_HAFAILOVER);
_sql->retcode = _sqlResults(_sql);
_sql->retcode = _sqlepilog(_sql);
}
if (sqlca.sqlcode < 0)
{
error_handler();
}
正如上面所见,指向宿主变量的指针CS_INT :key
被放置在ct_param()
对内部结构的调用中,但没有对宿主变量的任何引用CS_IMAGE :blobfld
。这就是 ASE 抱怨缺少参数值的原因,因为它在准备好的语句中看到了两个问号。在我看来,这在某种程度上是编译器中的错误,而不是 ASE 本身中的错误。?
UPDATE
CPRE