Reputation: 11
I have upgraded the nodejs vesion from 14.x to 18.x . As part of this change upgrdaded the node oracledb version to "6.2.0". when i try to query the from oracle db its throwing following error
[ERROR]: ERROR null Unable to execute query: Error: NJS-098: 2 positional bind values are required but 1 were provided []
Package.json:
"devDependencies": { "@types/oracledb": "6.0.4", "typescript": "4.3.5" }
"dependencies": { "oracledb": "6.2.0", }
Query :
const sql = SELECT id,name,(select max(days) from days d where id =:0 ) as "days" from test d WHERE d.id = :0
const metadata = await db.findOne(sql, [Id]);
Upvotes: 0
Views: 1583
Reputation: 168730
The Using Bind Variables documentation states:
If a bind parameter name is repeated in the SQL string, then bind by name syntax should be used.
So you should use named bind variables:
const metadata = await db.findOne(sql, {"0": Id});
But you may be able to repeat the variable if you are using an array of positional bind variables:
const metadata = await db.findOne(sql, [Id, Id]);
(But using named bind variables is recommended.)
Upvotes: 1