0

I want pass the column name as a parameter to the sql statement which I am using in the Mobile first adapter. I tried with the following :

var procedure1Statement = WL.Server.createSQLStatement("select * from table1 where ?='employee'");
function validate(columnname) {
    return WL.Server.invokeSQLStatement({
        preparedStatement : procedure1Statement,
        parameters : [columnname]
    });

}

but it is returning an empty result set:

{
   "isSuccessful": true,
   "resultSet": [
   ]
}
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
Gopi Nath
  • 413
  • 3
  • 7
  • 21

1 Answers1

0

From what I am reading about SQL, it is not possible to simply pass the column name as a parameter.

However there are alternate ways to do so, for example see here: Can I pass column name as input parameter in SQL stored Procedure

Basically you'll need to understand beforehand which column is required and based on that information construct your SQL query. So in your case you can implement a CASE and depending on the parameter ("column") value, you'll use a different query.

Community
  • 1
  • 1
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • Using switch case is little complex in my case. there are 31 columns in my table and depending on the current date respective column name has to be called – Gopi Nath May 22 '15 at 11:50