Question

I want to send a query to different tables. I want to take the table name as the parameter so I used "?" but it gives an error when I invoke it. If I write the table name instead of "?" without any parameters, there is no error. Can you guys suggest a solution? Thanks.

var selectStatement = WL.Server.createSQLStatement("select * from ?");
function getStudentInfos(param1) {    

    return WL.Server.invokeSQLStatement({
        preparedStatement : selectStatement,
        parameters : [param1]
    });
}
Was it helpful?

Solution

There is no way to take the table name as a parameter in a static sql query. The only way to do this is to create the sql query dynamically. Take a look here: Table name as variable

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top