调用 MobileFirst SQLAdapter 时出现 SQLException
SQLException while invoking MobileFirst SQLAdapter
我收到这个错误:
FWLSE0101E: Caused by: [project ***]com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-313, SQLSTATE=07004, SQLERRMC=null, DRIVER=3.66.46 java.lang.RuntimeException: DB2 SQL Error: SQLCODE=-313, SQLSTATE=07004, SQLERRMC=null, DRIVER=3.66.46.
Performed query:
update account set regTstamp = (current timestamp) where accountId = ?
调用 SQLAdapter 时。
这是调用过程:
var AcceptTocInvokeData = {
adapter : 'DataAdapter',
procedure : 'updateAcceptTocDate',
params: [accountId]
};
WL.Client.invokeProcedure(AcceptTocInvokeData, {
onSuccess: function(resp) {
deferred.resolve(resp);
},
onFailure: function(resp) {
deferred.reject(resp);
}
});
和 SQLAdapter 代码:
var prepStmt = WL.Server.createSQLStatement("update account set regTstamp = (current timestamp) where accountId = ?");
function updateAcceptTocDate(accountId) {
return WL.Server.invokeSQLStatement({
preparedStatement: prepStmt,
parameters: [accountId]
});
}
如果我从 MobileFirst Studio (运行 as...) 调用适配器,它会完美运行。
有人知道这是怎么回事吗?
如果您查看 SQLCODE -313
的 DB2 手册,您可能会看到类似这样的内容:
The number of variables in the EXECUTE statement, the number of variables in the OPEN statement, or the number of arguments in an OPEN statement for a parameterized cursor is not equal to the number of values required.
显然,参数没有绑定到准备好的语句。
我自己找到了解决方案:
我在 invokeData 中写了 params
而不是 parameters
.
我收到这个错误:
FWLSE0101E: Caused by: [project ***]com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-313, SQLSTATE=07004, SQLERRMC=null, DRIVER=3.66.46 java.lang.RuntimeException: DB2 SQL Error: SQLCODE=-313, SQLSTATE=07004, SQLERRMC=null, DRIVER=3.66.46. Performed query: update account set regTstamp = (current timestamp) where accountId = ?
调用 SQLAdapter 时。
这是调用过程:
var AcceptTocInvokeData = {
adapter : 'DataAdapter',
procedure : 'updateAcceptTocDate',
params: [accountId]
};
WL.Client.invokeProcedure(AcceptTocInvokeData, {
onSuccess: function(resp) {
deferred.resolve(resp);
},
onFailure: function(resp) {
deferred.reject(resp);
}
});
和 SQLAdapter 代码:
var prepStmt = WL.Server.createSQLStatement("update account set regTstamp = (current timestamp) where accountId = ?");
function updateAcceptTocDate(accountId) {
return WL.Server.invokeSQLStatement({
preparedStatement: prepStmt,
parameters: [accountId]
});
}
如果我从 MobileFirst Studio (运行 as...) 调用适配器,它会完美运行。 有人知道这是怎么回事吗?
如果您查看 SQLCODE -313
的 DB2 手册,您可能会看到类似这样的内容:
The number of variables in the EXECUTE statement, the number of variables in the OPEN statement, or the number of arguments in an OPEN statement for a parameterized cursor is not equal to the number of values required.
显然,参数没有绑定到准备好的语句。
我自己找到了解决方案:
我在 invokeData 中写了 params
而不是 parameters
.