I am trying to get rows where id in 1,2,3.
Here is my code:
app.use('/', async function(req, res, next){
try{
var query = await connection.execute(`SELECT * FROM ERROR_LIST WHERE ID IN :1`, [[1,2,3]]);
console.log(query);
res.send(query.rows)
} catch(err) {
next(err);
}
next();
});
As the result: ORA-01484: arrays can only be bound to PL/SQL statements
The node-oracledb documentation has a whole section Binding Multiple Values to a SQL WHERE IN Clause.
You'll need one of the solutions, the simplest of which is like:
const sql = `SELECT last_name FROM employees WHERE first_name IN (:bv1, :bv2, :bv3, :bv4)`;
const binds = ['Alyssa', 'Christopher', 'Hazel', 'Samuel'];
const result = await connection.execute(sql, binds);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With