Node-oracledb: [Error: ORA-01008: not all variables bound] errorNum: 1008, offset: 0

Created on 3 Sep 2019  路  3Comments  路  Source: oracle/node-oracledb

Hello,

  • SQL to create table:
CREATE TABLE "SYSTEM"."TEST" 
( "ID_TYPE_REALTY" NUMBER ) 
process.platform win32
process.version v10.13.0
process.arch x64
oracledb.versionString 3.0.1
  • Oracle Database version: 12褋

  • Node code:

objInput = { test : 1 }

queryString = `INSERT INTO test ( ID_TYPE_REALTY) VALUES ( :idtr ) `;
optionsObj =  { idtr:  { type: oracledb.NUMBER, val: objInput.test } }

try { 

     // connect to db...

     result = await connection.execute(
         queryString
         ,[]
         ,optionsObj
     ); 

     response.send(result)

} catch (err) {

    console.error(err);
    response.send(err);

} finally {
    if (connection) {
        try {
    await connection.close();
        } catch (err) {
    console.error(err);
        }
    }
}

I send request and had error-response:
_[Error: ORA-01008: not all variables bound] errorNum: 1008, offset: 0_

Where is my mistake?
Thnks

question

All 3 comments

Take a look at the documentation. The binds are the second parameter and you have passed an empty array (and attempted to pass the bind parameters in the options).

@anthony-tuininga

The binds are the second parameter and you have passed an empty array (and attempted to pass the bind parameters in the options).

Its doesnt worked when i try to send more options like this:

optionsObj = {    
    autoCommit: true,
    bindDefs: { 
            idtr:  { type: oracledb.NUMBER, val: objInput.test }  
    } 
}

The bindDefs option is only valid for connection.executeMany(). Please read the documentation!

Was this page helpful?
0 / 5 - 0 ratings