[英]return multiple ResultSet on IBM MobileFirst
當我嘗試第二次調用SQL resultSet時遇到問題,並且出現錯誤Cannot read property "resultSet" from undefined
。 所以我只是想知道如何重用resultSet
或調用多個resultSet
。
Main.js
function getAuthen(){
var username = $("#AuthUsername").val();
var password = $("#AuthPassword").val();
var invocationData = {
adapter: "ConnectDB",
procedure : 'getauthentication',
parameters : [username, password]
};
WL.Client.invokeProcedure(invocationData, {
onSuccess : getAuthenSuccess,
onFailure : getAuthenFailure
});
}
function getAuthenSuccess(result){
if(result.invocationResult.resultSet.length > 0)
{
$("#AuthDiv").hide();
$("#header_main").show();
$("#Menu").show()
$('#DisplayName').html(result.invocationResult.resultSet[0].NME);
$('#DisplaySurname').html(result.invocationResult.resultSet[0].SURNME);
} else {
getAuthenFailure();
}
}
function getAuthenFailure(result){
var alertTitle = "Fail to Login";
var alertText = "Please Enter Username and Password Correctly";
WL.SimpleDialog.show(alertTitle, alertText,[
{
text : 'OK',
handler : getLogout
}
]);
}
//***************************** END ************************\\
//*********** Get Problem On Going ************************//
function queryProblemOnGoing(){
var invocationDataP = {
adapter: "ConnectDB",
procedure : 'getproblemOngoing',
parameters : []
};
WL.Client.invokeProcedure(invocationDataP, {
onSuccess : getProblemOnGoingSuccess,
onFailure : getProblemOnGoingFailure
});
}
function getProblemOnGoingSuccess(result){
if(result.invocationResult.resultSet.length > 0)
{
window.alert("Success");
$("#Menu").show()
// displayQueryOnGoing(result.invocationResult.resultSet);
} else {
window.alert("Fail");
//getProblemOnGoingFailure();
}
}
function getProblemOnGoingFailure(result){
var alertTitle = "Fail to Retrive Data";
var alertText = "Please Contact Administrator";
WL.SimpleDialog.show(alertTitle, alertText,[
{
text : 'OK'
}
]);
}
function displayQueryOnGoing(result) {
for (var i =0; i < result.length; i++)
{
$('#problemOnGoingTable').append("<tr><td>" + result[i].CALLNO + "</td></tr>");
$('#problemOnGoingTable').append("<tr><td>" + result[i].CALLNOREF + "</td></tr>");
}
}
ConnectDB適配器
var AuthenStatement = WL.Server.createSQLStatement("select NME, SURNME, CUS_ID from USERS where USERID = ? AND PASSWD = ?");
var problemOngoingStatement = WL.Server.createSQLStatement("select * from CALL”);
function getauthentication(userid, password) {
return WL.Server.invokeSQLStatement({
preparedStatement : AuthenStatement,
parameters : [userid, password]
});
}
function getproblemOngoing() {
return WL.Server.invokeSQLStatement({
preparedStatement : problemOngoingStatement,
parameters : []
});
}
我不太確定它是第一次工作還是第一次工作。
無論如何,我懷疑問題出在這里: for (var i =0; i < result.length; i++)
也許你應該改變result.length
到result.invocationResult.resultSet.length
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.