cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

how to call a query service from javascript service passing json object

pbadiger
1-Newbie

how to call a query service from javascript service passing json object

Hi Team,

I have a requirement where in I am calling a javascript service from a mashup, this service will inturn call a sql query service passing the json parameter. Once the sql service is executed, result of the query execution is retrieved in the javascript service.

Below are my services

Javascript service

var params = {

username: username /* STRING */,

password: password /* STRING */

};

logger.warn("username in params = " +params.username);

logger.warn("password in params = " +params.password);

var queryparams = {};

queryparams['name'] = params.username;

queryparams['password'] = params.password;

// result: INFOTABLE dataShape: "undefined"

var result = me.queryUser(queryparams);

SQL Query service

select * from DPD_USERS where NAME=[[params.name]] and password=[[params.password]] //where params is the json parameter sent in from JS service

When I execute the JS service its gets data properly and tries to execute the query service. However, in query service execution, I get the following error

Wrapped org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "SELECT * FROM <MY_TABLE> WHERE NAME=[

  • [PARAMS['name']]] AND PASSWORD=[[PARAMS['password']]] "; expected "ALL, ANY, SOME, SELECT, FROM, WITH"; SQL statement: select * from <MY_TABLE> where NAME=[[params['name']]] and password=[[params['password']]] [42001-192] Cause: Syntax error in SQL statement "SELECT * FROM <MY_TABLE> WHERE NAME=[
  • [PARAMS['name']]] AND PASSWORD=[[PARAMS['password']]] "; expected "ALL, ANY, SOME, SELECT, FROM, WITH"; SQL statement: select * from <MY_TABLE> where NAME=[[params['name']]] and password=[[params['password']]] [42001-192]
  • I believe I am making a mistake in extracting parameters from json object. I could not get find any post which could lead me to correct syntax. Please help.

    Thanks,

    Pawan

    1 REPLY 1

    Your SQL Servrice queryUser, should have two input parameters name and password

    select * from DPD_USERS where NAME='<<name>>' and password='<<password>>'


    Top Tags