oracle / node-oracledb

Oracle Database driver for Node.js maintained by Oracle Corp.
http://oracle.github.io/node-oracledb/
Other
2.24k stars 1.07k forks source link

Error on oracledb version 6 upgrade: "NJS-021: invalid type for conversion specified" #1654

Closed ghc20 closed 3 months ago

ghc20 commented 3 months ago
  1. What versions are you using? oracledb version 6
  1. Is it an error or a hang or a crash? Yes

  2. What error(s) or behavior you are seeing? NJS-021: invalid type for conversion specified

  1. Include a runnable Node.js script that shows the problem.
    connection.execute(sql, params,
        { fetchInfo: { DATA: { type: oracledb.STRING}}, outFormat: oracledb.OUT_FORMAT_OBJECT},
        (err, res) => {
          if (err) {
              console.error('Failed to get session.');
              console.error(err);
              return cb && cb(err, null);
          }
    ...
        }}

    The above code works well with oracledb version 5 and earlier versions. However, following an upgrade to oracledb version 6, an error occurs: "NJS-021: invalid type for conversion specified". This error pertains to the "DATA" column, which is of LOB type. Upon debugging, it was identified that the problem arises from the fetchInfo: { DATA: { type: oracledb.STRING }} configuration. This configuration functions correctly in version 5 but leads to errors in version 6.

Any advice is appreciated! Thank you!

sharadraju commented 3 months ago

@ghc Thanks for using node-oracledb. Node-oracledb 6.0 comes with a default 'Thin' mode, which eliminates the need to use Oracle Client libraries to connect to Oracle Database. See https://medium.com/oracledevs/usher-in-a-new-era-with-the-node-oracledb-6-0-pure-javascript-thin-driver-e10e2af693b2 The Thick mode retains the old behavior of pre 6.0 versions and uses Oracle Client libraries to connect to Oracle Database. See How to enable Thick mode. Please check the same application by enabling Thick mode and let us know the results. This will help us in fixing the problem quickly.

ghc20 commented 3 months ago

@sharadraju I enabled the Thick mode with oracledb.initOracleClient({libDir: 'C:\\Oracle\\instantclient_21_10'}) in my code. The same error persists :-(

ghc20 commented 3 months ago

@sharadraju I identified the issue: multiple Node.js libraries in my project are using different versions of oracledb, leading to the problem. Thank you!