You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to parameterize the following query:
SELECT test_name FROM web_test_data WHERE test_id IN ('f_0001', 'f_0002', 'f_0003');
My thought is that I can use a variable @tests to plug in where my id values are specified by the IN operator. Here is my code:
var SQL = require('seriate');
var ids = "'f_0001', 'f_0002', 'f_0003'";
SQL.setDefault(config);
SQL.execute({
query: "SELECT test_name FROM web_test_data WHERE test_id IN (@tests)",
params: {
tests: {
type: SQL.NCHAR,
val: ids
}
}
})
.then(function(results) {
console.log('running tests ->', results);
}, function(err) {
console.log("An error occurred when attempting to query for running tests", err);
})
My query runs without errors but I get an empty result set. This is not expected. However, when I replace @tests with 'f_0001', 'f_0002', 'f_0003' I get the result set I expect. I'm wondering if the double quotes wrapping my inner id values when defining var ids is causing the problem?
Does Seriate support parameterized queries in this way using the IN operator or did I make some mistake that I'm overlooking?
The text was updated successfully, but these errors were encountered:
I am attempting to parameterize the following query:
SELECT test_name FROM web_test_data WHERE test_id IN ('f_0001', 'f_0002', 'f_0003');
My thought is that I can use a variable @tests to plug in where my id values are specified by the IN operator. Here is my code:
var SQL = require('seriate');
var ids = "'f_0001', 'f_0002', 'f_0003'";
SQL.setDefault(config);
SQL.execute({
query: "SELECT test_name FROM web_test_data WHERE test_id IN (@tests)",
params: {
tests: {
type: SQL.NCHAR,
val: ids
}
}
})
.then(function(results) {
console.log('running tests ->', results);
}, function(err) {
console.log("An error occurred when attempting to query for running tests", err);
})
My query runs without errors but I get an empty result set. This is not expected. However, when I replace @tests with 'f_0001', 'f_0002', 'f_0003' I get the result set I expect. I'm wondering if the double quotes wrapping my inner id values when defining var ids is causing the problem?
Does Seriate support parameterized queries in this way using the IN operator or did I make some mistake that I'm overlooking?
The text was updated successfully, but these errors were encountered: