Skip to content

Issue using IN SQL Statement and parameterization #6174

Closed Answered by rjkroll
jtyme asked this question in Q&A
Discussion options

You must be logged in to vote

The IN clause expects a list or array of values, but you're passing a single string containing comma-separated values.

var idList = ['2', '3']; 
var query = "SELECT * FROM TEST WHERE tableID IN (?)";
var param = new Lists.list(idList); 

var dbConn = createDBConn('testdb');
var results = dbConn.executeCachedQuery(query, param);

or something like this:

var ids = ['2', '3', '4', '5'];
var idList = new Lists.list(ids);
var query = "SELECT * FROM TEST WHERE tableID IN (?)";
var param = idList;

var dbConn = createDBConn('testdb');
var results = dbConn.executeCachedQuery(query, param);

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@pacmano1
Comment options

@jtyme
Comment options

@pacmano1
Comment options

Comment options

You must be logged in to vote
1 reply
@jtyme
Comment options

Answer selected by pacmano1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants