2

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

MT0
  • 143,790
  • 11
  • 59
  • 117

1 Answers1

2

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);
Christopher Jones
  • 9,449
  • 3
  • 24
  • 48