use resultset returned by WL.Server.invokeSQLStatement within sql adapter procedure

久未见 提交于 2019-11-28 14:34:32

Try changing your adapter JavaScript implementation to the following instead.

I tried a version of this with different table and variables and it worked for me (at least, the adapter invocation from Worklight Studio).

Note how I am using locId.resultSet and not locId.invocationResult.resultSet. The latter is used on the client-side whereas the former is used on the server-side.

Also note the separation to two functions.

function getStudentInfos(Name,Location) {
    var locId, a, b;

    locId = getlocId(Location);
    a = locId.resultSet;
    if (a && a.length>0) {
        b = a[0].LocId;
    }
    return WL.Server.invokeSQLStatement({
        preparedStatement : selectStatement3,
        parameters : [b]
    });
}

function getlocId (Location) {
    var result = WL.Server.invokeSQLStatement({
        preparedStatement : selectStatement2,
        parameters : [Location]
    });
    return result;
}

Note the if statement... make sure to add some error handling there as well...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!