当我第二次尝试调用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 Adapter
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 : []
});
}
答案 0 :(得分:0)
我不确定它是第一次如何工作,或者哪一部分是第一次工作。
无论如何,我怀疑问题出在这里:
for (var i =0; i < result.length; i++)
也许您应该将result.length
更改为result.invocationResult.resultSet.length
。