Skip to Main Content

Programming Languages & Frameworks

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

bind parameters as an array of objects

User514049-OracleMay 1 2017 — edited May 7 2017

All:

Is it possible to pass an array of bind variables i.e. w/o names, just as positional objects?

"INSERT INTO countries VALUES (:country_id, :country_name)",

  {

  country_id: { val: 90, dir: oracledb.BIND_IN, type: oracledb.NUMBER },

  country_name: { val: "Tonga", dir: oracledb.BIND_IN, type:oracledb.STRING }

  }

  [

     { val: 90, dir: oracledb.BIND_IN, type: oracledb.NUMBER },

     { val: "Tonga", dir: oracledb.BIND_IN, type:oracledb.STRING }

  ]

Some specifications like ODBC/JDBC support ? as bind parameter marker -- insert into countries values(?.?).   It will be useful in such cases.

With regards

Comments

Gaz in Oz

What happened when you tried it?

Did it work or

did you get errors?

User514049-Oracle

Hi:

It worked.  But I am up against an open and shut issue of support for question marks as parameter markers.  See https://github.com/oracle/node-oracledb/issues/109

With regards

It's not much more complex in most cases to use array bind with numeric parameters instead of question marks:

connection.execute(

  "INSERT INTO countries VALUES (:0, :1)",

  ["Tonga", 90],

  . . .

I understand question marks might be useful for compatibility in some cases.  The identification of bind variables in SQL is an Oracle OCI 'feature', and not specific to node-oracledb.

1 - 3

Post Details

Added on May 1 2017
3 comments
3,478 views