diff --git a/javascript/node-oracledb/README.md b/javascript/node-oracledb/README.md index a15f648e..a0827cb5 100644 --- a/javascript/node-oracledb/README.md +++ b/javascript/node-oracledb/README.md @@ -1,8 +1,8 @@ # Node-oracledb Examples This directory contains [node-oracledb](https://www.npmjs.com/package/oracledb) -examples. Documentation is [here -](https://oracle.github.io/node-oracledb/doc/api.html). +examples. Documentation is +[here](https://oracle.github.io/node-oracledb/doc/api.html). To run the examples: @@ -23,13 +23,15 @@ for example: - In a terminal window, set the environment variable `NODE_ORACLEDB_PASSWORD` to the value of your database password. -- Review the samples and then run them like: +- Review the samples and then run them individually. For example, to see what + the file `example.js` does, use: ``` node example.js ``` -- After running example, the demonstration objects can be dropped with `demodrop.js`: +- After running examples, the demonstration objects can be dropped with + `demodrop.js`: ``` node demodrop.js diff --git a/javascript/node-oracledb/aqmulti.js b/javascript/node-oracledb/aqmulti.js index ede8ee89..1c6571c4 100644 --- a/javascript/node-oracledb/aqmulti.js +++ b/javascript/node-oracledb/aqmulti.js @@ -30,6 +30,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -38,10 +39,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const queueName = "DEMO_RAW_QUEUE"; diff --git a/javascript/node-oracledb/aqobject.js b/javascript/node-oracledb/aqobject.js index d2b6aa3b..f0575ac2 100644 --- a/javascript/node-oracledb/aqobject.js +++ b/javascript/node-oracledb/aqobject.js @@ -31,6 +31,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -39,10 +40,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const queueName = "ADDR_QUEUE"; diff --git a/javascript/node-oracledb/aqoptions.js b/javascript/node-oracledb/aqoptions.js index d6ce3ff1..fa2668e0 100644 --- a/javascript/node-oracledb/aqoptions.js +++ b/javascript/node-oracledb/aqoptions.js @@ -30,6 +30,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -38,10 +39,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const queueName = "DEMO_RAW_QUEUE"; diff --git a/javascript/node-oracledb/aqraw.js b/javascript/node-oracledb/aqraw.js index d617c324..ecc8b5a0 100644 --- a/javascript/node-oracledb/aqraw.js +++ b/javascript/node-oracledb/aqraw.js @@ -30,6 +30,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -38,10 +39,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const queueName = "DEMO_RAW_QUEUE"; diff --git a/javascript/node-oracledb/blobhttp.js b/javascript/node-oracledb/blobhttp.js index 13a26afe..67700186 100644 --- a/javascript/node-oracledb/blobhttp.js +++ b/javascript/node-oracledb/blobhttp.js @@ -29,6 +29,7 @@ * *****************************************************************************/ +const fs = require('fs'); const url = require('url'); const http = require('http'); const oracledb = require('oracledb'); @@ -40,10 +41,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const httpPort = 7000; diff --git a/javascript/node-oracledb/calltimeout.js b/javascript/node-oracledb/calltimeout.js index d464e4dc..1bc6f905 100755 --- a/javascript/node-oracledb/calltimeout.js +++ b/javascript/node-oracledb/calltimeout.js @@ -29,6 +29,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require("oracledb"); const dbConfig = require('./dbconfig.js'); @@ -37,10 +38,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const dboptime = 4; // seconds the simulated database operation will take diff --git a/javascript/node-oracledb/connect.js b/javascript/node-oracledb/connect.js index 92b59070..b202d31e 100644 --- a/javascript/node-oracledb/connect.js +++ b/javascript/node-oracledb/connect.js @@ -30,6 +30,7 @@ 'use strict'; +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -38,10 +39,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/connectionpool.js b/javascript/node-oracledb/connectionpool.js index 5482c146..4040710d 100644 --- a/javascript/node-oracledb/connectionpool.js +++ b/javascript/node-oracledb/connectionpool.js @@ -42,6 +42,7 @@ // running your application. // process.env.UV_THREADPOOL_SIZE = 4; +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -50,10 +51,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function init() { diff --git a/javascript/node-oracledb/cqn1.js b/javascript/node-oracledb/cqn1.js index 79580f47..32263ca9 100644 --- a/javascript/node-oracledb/cqn1.js +++ b/javascript/node-oracledb/cqn1.js @@ -36,6 +36,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require("oracledb"); const dbConfig = require('./dbconfig.js'); @@ -44,10 +45,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } dbConfig.events = true; // CQN needs events mode diff --git a/javascript/node-oracledb/cqn2.js b/javascript/node-oracledb/cqn2.js index aab21cd1..ecf6a5ba 100644 --- a/javascript/node-oracledb/cqn2.js +++ b/javascript/node-oracledb/cqn2.js @@ -37,6 +37,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require("oracledb"); const dbConfig = require('./dbconfig.js'); @@ -45,10 +46,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } dbConfig.events = true; // CQN needs events mode diff --git a/javascript/node-oracledb/date.js b/javascript/node-oracledb/date.js index dfd11bf8..f2f25c2e 100644 --- a/javascript/node-oracledb/date.js +++ b/javascript/node-oracledb/date.js @@ -32,6 +32,7 @@ // Using a fixed Oracle time zone helps avoid machine and deployment differences process.env.ORA_SDTZ = 'UTC'; +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -40,10 +41,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT; diff --git a/javascript/node-oracledb/dbmsoutputgetline.js b/javascript/node-oracledb/dbmsoutputgetline.js index 89e4d8a7..e1688771 100644 --- a/javascript/node-oracledb/dbmsoutputgetline.js +++ b/javascript/node-oracledb/dbmsoutputgetline.js @@ -27,6 +27,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -35,10 +36,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/dbmsoutputpipe.js b/javascript/node-oracledb/dbmsoutputpipe.js index 700b906a..2b6a0060 100644 --- a/javascript/node-oracledb/dbmsoutputpipe.js +++ b/javascript/node-oracledb/dbmsoutputpipe.js @@ -25,6 +25,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -33,10 +34,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/demodrop.js b/javascript/node-oracledb/demodrop.js index f649eb93..ecccd8cb 100644 --- a/javascript/node-oracledb/demodrop.js +++ b/javascript/node-oracledb/demodrop.js @@ -23,6 +23,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -31,10 +32,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/dmlrupd.js b/javascript/node-oracledb/dmlrupd.js index 4097456e..89988135 100644 --- a/javascript/node-oracledb/dmlrupd.js +++ b/javascript/node-oracledb/dmlrupd.js @@ -27,6 +27,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -35,10 +36,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/em_batcherrors.js b/javascript/node-oracledb/em_batcherrors.js index 70328894..8fe0561b 100644 --- a/javascript/node-oracledb/em_batcherrors.js +++ b/javascript/node-oracledb/em_batcherrors.js @@ -31,6 +31,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -40,10 +41,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const sql = "INSERT INTO no_em_childtab VALUES (:1, :2, :3)"; diff --git a/javascript/node-oracledb/em_dmlreturn1.js b/javascript/node-oracledb/em_dmlreturn1.js index 1cd85a16..ef37f1c2 100644 --- a/javascript/node-oracledb/em_dmlreturn1.js +++ b/javascript/node-oracledb/em_dmlreturn1.js @@ -27,6 +27,7 @@ * x *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -36,10 +37,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const sql = "INSERT INTO no_em_tab VALUES (:1, :2) RETURNING ROWID, id, val INTO :3, :4, :5"; diff --git a/javascript/node-oracledb/em_dmlreturn2.js b/javascript/node-oracledb/em_dmlreturn2.js index 5cdb9419..c7c3184d 100644 --- a/javascript/node-oracledb/em_dmlreturn2.js +++ b/javascript/node-oracledb/em_dmlreturn2.js @@ -27,6 +27,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -36,10 +37,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const insertSql = "INSERT INTO no_em_tab VALUES (:1, :2)"; diff --git a/javascript/node-oracledb/em_insert1.js b/javascript/node-oracledb/em_insert1.js index b090067f..bea8b2b4 100644 --- a/javascript/node-oracledb/em_insert1.js +++ b/javascript/node-oracledb/em_insert1.js @@ -27,6 +27,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -36,10 +37,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const sql = "INSERT INTO no_em_tab values (:a, :b)"; diff --git a/javascript/node-oracledb/em_insert2.js b/javascript/node-oracledb/em_insert2.js index f21b8c57..9101f09d 100644 --- a/javascript/node-oracledb/em_insert2.js +++ b/javascript/node-oracledb/em_insert2.js @@ -27,6 +27,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -36,10 +37,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const sql = "INSERT INTO no_em_tab values (:1, :2)"; diff --git a/javascript/node-oracledb/em_plsql.js b/javascript/node-oracledb/em_plsql.js index b5bf171d..9ff308d6 100644 --- a/javascript/node-oracledb/em_plsql.js +++ b/javascript/node-oracledb/em_plsql.js @@ -30,6 +30,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -39,10 +40,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const sql = "BEGIN no_em_proc(:1, :2, :3); END;"; diff --git a/javascript/node-oracledb/em_rowcounts.js b/javascript/node-oracledb/em_rowcounts.js index 101a3c88..3ed1fb01 100644 --- a/javascript/node-oracledb/em_rowcounts.js +++ b/javascript/node-oracledb/em_rowcounts.js @@ -28,6 +28,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -37,10 +38,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const sql = "DELETE FROM no_em_childtab WHERE parentid = :1"; diff --git a/javascript/node-oracledb/endtoend.js b/javascript/node-oracledb/endtoend.js index 001ec5db..7f3463eb 100644 --- a/javascript/node-oracledb/endtoend.js +++ b/javascript/node-oracledb/endtoend.js @@ -29,6 +29,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -37,10 +38,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/example.js b/javascript/node-oracledb/example.js index f809720e..b1b4061e 100644 --- a/javascript/node-oracledb/example.js +++ b/javascript/node-oracledb/example.js @@ -32,6 +32,7 @@ // Using a fixed Oracle time zone helps avoid machine and deployment differences process.env.ORA_SDTZ = 'UTC'; +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -40,10 +41,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/fetchinfo.js b/javascript/node-oracledb/fetchinfo.js index 452ddf27..6e37d127 100644 --- a/javascript/node-oracledb/fetchinfo.js +++ b/javascript/node-oracledb/fetchinfo.js @@ -26,6 +26,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -35,10 +36,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } oracledb.fetchAsString = [ oracledb.NUMBER ]; // any number queried will be returned as a string diff --git a/javascript/node-oracledb/impres.js b/javascript/node-oracledb/impres.js index c6a3a006..eb529df3 100644 --- a/javascript/node-oracledb/impres.js +++ b/javascript/node-oracledb/impres.js @@ -29,6 +29,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -38,10 +39,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT; diff --git a/javascript/node-oracledb/insert1.js b/javascript/node-oracledb/insert1.js index dd62557b..dd92ae37 100644 --- a/javascript/node-oracledb/insert1.js +++ b/javascript/node-oracledb/insert1.js @@ -28,6 +28,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -36,10 +37,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/insert2.js b/javascript/node-oracledb/insert2.js index 37e3d1bd..e6e32dd5 100644 --- a/javascript/node-oracledb/insert2.js +++ b/javascript/node-oracledb/insert2.js @@ -31,6 +31,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -39,10 +40,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/lastinsertid.js b/javascript/node-oracledb/lastinsertid.js index 37349e5d..e35baa05 100644 --- a/javascript/node-oracledb/lastinsertid.js +++ b/javascript/node-oracledb/lastinsertid.js @@ -26,6 +26,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -34,10 +35,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/lobbinds.js b/javascript/node-oracledb/lobbinds.js index 50ce62ed..a9bb26d1 100644 --- a/javascript/node-oracledb/lobbinds.js +++ b/javascript/node-oracledb/lobbinds.js @@ -42,10 +42,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const clobOutFileName1 = 'lobbindsout1.txt'; diff --git a/javascript/node-oracledb/lobinsert1.js b/javascript/node-oracledb/lobinsert1.js index 52d1b6d4..0771a3bf 100644 --- a/javascript/node-oracledb/lobinsert1.js +++ b/javascript/node-oracledb/lobinsert1.js @@ -45,10 +45,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } oracledb.autoCommit = true; // for ease of demonstration only diff --git a/javascript/node-oracledb/lobinsert2.js b/javascript/node-oracledb/lobinsert2.js index b8fb5955..1876e0c2 100644 --- a/javascript/node-oracledb/lobinsert2.js +++ b/javascript/node-oracledb/lobinsert2.js @@ -37,10 +37,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const inFileName = 'clobexample.txt'; // the file with text to be inserted into the database diff --git a/javascript/node-oracledb/lobinserttemp.js b/javascript/node-oracledb/lobinserttemp.js index 561ed526..67fbe117 100644 --- a/javascript/node-oracledb/lobinserttemp.js +++ b/javascript/node-oracledb/lobinserttemp.js @@ -41,10 +41,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const inFileName = 'clobexample.txt'; // the file with text to be inserted into the database diff --git a/javascript/node-oracledb/lobplsqltemp.js b/javascript/node-oracledb/lobplsqltemp.js index 3ea9a232..476c1c49 100644 --- a/javascript/node-oracledb/lobplsqltemp.js +++ b/javascript/node-oracledb/lobplsqltemp.js @@ -41,10 +41,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const inFileName = 'clobexample.txt'; // the file with text to be inserted into the database diff --git a/javascript/node-oracledb/lobselect.js b/javascript/node-oracledb/lobselect.js index 83586994..98b67300 100644 --- a/javascript/node-oracledb/lobselect.js +++ b/javascript/node-oracledb/lobselect.js @@ -40,10 +40,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const blobOutFileName = 'lobselectout.jpg'; // file to write the BLOB to diff --git a/javascript/node-oracledb/lobstream1.js b/javascript/node-oracledb/lobstream1.js index 822e16ba..3fe98f55 100644 --- a/javascript/node-oracledb/lobstream1.js +++ b/javascript/node-oracledb/lobstream1.js @@ -37,10 +37,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } // Stream a LOB to a file diff --git a/javascript/node-oracledb/lobstream2.js b/javascript/node-oracledb/lobstream2.js index d8023adf..0dd1beec 100644 --- a/javascript/node-oracledb/lobstream2.js +++ b/javascript/node-oracledb/lobstream2.js @@ -27,6 +27,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -36,10 +37,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/metadata.js b/javascript/node-oracledb/metadata.js index 9c6a42db..875a9981 100644 --- a/javascript/node-oracledb/metadata.js +++ b/javascript/node-oracledb/metadata.js @@ -27,6 +27,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -36,10 +37,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/plsqlarray.js b/javascript/node-oracledb/plsqlarray.js index 1f0a131a..0b236dc7 100644 --- a/javascript/node-oracledb/plsqlarray.js +++ b/javascript/node-oracledb/plsqlarray.js @@ -31,6 +31,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -39,10 +40,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/plsqlfunc.js b/javascript/node-oracledb/plsqlfunc.js index edd83f27..59ec7493 100644 --- a/javascript/node-oracledb/plsqlfunc.js +++ b/javascript/node-oracledb/plsqlfunc.js @@ -25,6 +25,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -33,10 +34,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/plsqlproc.js b/javascript/node-oracledb/plsqlproc.js index 3e541a27..71ca9908 100644 --- a/javascript/node-oracledb/plsqlproc.js +++ b/javascript/node-oracledb/plsqlproc.js @@ -25,6 +25,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -33,10 +34,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/plsqlrecord.js b/javascript/node-oracledb/plsqlrecord.js index 457e24e1..5265926d 100644 --- a/javascript/node-oracledb/plsqlrecord.js +++ b/javascript/node-oracledb/plsqlrecord.js @@ -29,6 +29,7 @@ 'use strict'; +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -37,10 +38,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/plsqlvarrayrecord.js b/javascript/node-oracledb/plsqlvarrayrecord.js index a27014fe..bc34cbfb 100644 --- a/javascript/node-oracledb/plsqlvarrayrecord.js +++ b/javascript/node-oracledb/plsqlvarrayrecord.js @@ -29,6 +29,7 @@ 'use strict'; +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -37,10 +38,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/raw.js b/javascript/node-oracledb/raw.js index 150cb674..31949ea1 100644 --- a/javascript/node-oracledb/raw.js +++ b/javascript/node-oracledb/raw.js @@ -27,6 +27,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -35,10 +36,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/refcursor.js b/javascript/node-oracledb/refcursor.js index a1c52409..2823a95f 100644 --- a/javascript/node-oracledb/refcursor.js +++ b/javascript/node-oracledb/refcursor.js @@ -26,6 +26,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -35,10 +36,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/refcursortoquerystream.js b/javascript/node-oracledb/refcursortoquerystream.js index e69bdb5a..e3ff969e 100644 --- a/javascript/node-oracledb/refcursortoquerystream.js +++ b/javascript/node-oracledb/refcursortoquerystream.js @@ -29,6 +29,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -38,10 +39,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/resultset1.js b/javascript/node-oracledb/resultset1.js index d78b912e..f318ddab 100644 --- a/javascript/node-oracledb/resultset1.js +++ b/javascript/node-oracledb/resultset1.js @@ -27,6 +27,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -36,10 +37,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/resultset2.js b/javascript/node-oracledb/resultset2.js index b591dd21..2b8e2642 100644 --- a/javascript/node-oracledb/resultset2.js +++ b/javascript/node-oracledb/resultset2.js @@ -26,6 +26,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -35,10 +36,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } // Number of rows to return from each call to getRows() diff --git a/javascript/node-oracledb/resultsettoquerystream.js b/javascript/node-oracledb/resultsettoquerystream.js index 9cbcbeb6..590b952b 100644 --- a/javascript/node-oracledb/resultsettoquerystream.js +++ b/javascript/node-oracledb/resultsettoquerystream.js @@ -26,6 +26,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -35,10 +36,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/rowlimit.js b/javascript/node-oracledb/rowlimit.js index c5faaac8..6a51cfd1 100644 --- a/javascript/node-oracledb/rowlimit.js +++ b/javascript/node-oracledb/rowlimit.js @@ -31,6 +31,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -40,10 +41,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const myoffset = 1; // number of rows to skip diff --git a/javascript/node-oracledb/select1.js b/javascript/node-oracledb/select1.js index 67a4bad9..76b7906d 100644 --- a/javascript/node-oracledb/select1.js +++ b/javascript/node-oracledb/select1.js @@ -31,6 +31,7 @@ 'use strict'; +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -40,10 +41,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/select2.js b/javascript/node-oracledb/select2.js index d7a1e0e9..b64711ca 100644 --- a/javascript/node-oracledb/select2.js +++ b/javascript/node-oracledb/select2.js @@ -28,6 +28,7 @@ 'use strict'; +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -37,10 +38,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } // Oracledb properties are applicable to all connections and SQL diff --git a/javascript/node-oracledb/selectgeometry.js b/javascript/node-oracledb/selectgeometry.js index f632344a..aa79f51b 100644 --- a/javascript/node-oracledb/selectgeometry.js +++ b/javascript/node-oracledb/selectgeometry.js @@ -29,6 +29,7 @@ 'use strict'; +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -37,10 +38,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } // If each object's attributes are accessed multiple times, it may be more diff --git a/javascript/node-oracledb/selectjson.js b/javascript/node-oracledb/selectjson.js index 714d43c5..6a52fb6b 100644 --- a/javascript/node-oracledb/selectjson.js +++ b/javascript/node-oracledb/selectjson.js @@ -30,6 +30,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -38,10 +39,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } oracledb.extendedMetaData = true; diff --git a/javascript/node-oracledb/selectjsonblob.js b/javascript/node-oracledb/selectjsonblob.js index 35ce953d..8e7c96f2 100644 --- a/javascript/node-oracledb/selectjsonblob.js +++ b/javascript/node-oracledb/selectjsonblob.js @@ -31,6 +31,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -39,10 +40,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } oracledb.extendedMetaData = true; diff --git a/javascript/node-oracledb/selectnestedcursor.js b/javascript/node-oracledb/selectnestedcursor.js index 2959315a..d640cea5 100644 --- a/javascript/node-oracledb/selectnestedcursor.js +++ b/javascript/node-oracledb/selectnestedcursor.js @@ -26,6 +26,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -34,10 +35,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/selectobject.js b/javascript/node-oracledb/selectobject.js index 5c326545..2c46e74a 100644 --- a/javascript/node-oracledb/selectobject.js +++ b/javascript/node-oracledb/selectobject.js @@ -30,6 +30,7 @@ 'use strict'; +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -38,10 +39,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } // If each object's attributes are accessed multiple times, it may be more diff --git a/javascript/node-oracledb/selectstream.js b/javascript/node-oracledb/selectstream.js index 171fcdec..bf18c6eb 100644 --- a/javascript/node-oracledb/selectstream.js +++ b/javascript/node-oracledb/selectstream.js @@ -27,6 +27,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); const demoSetup = require('./demosetup.js'); @@ -36,10 +37,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/selectvarray.js b/javascript/node-oracledb/selectvarray.js index 8b7d0b45..8fb19706 100644 --- a/javascript/node-oracledb/selectvarray.js +++ b/javascript/node-oracledb/selectvarray.js @@ -29,6 +29,7 @@ 'use strict'; +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -37,10 +38,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } async function run() { diff --git a/javascript/node-oracledb/sessionfixup.js b/javascript/node-oracledb/sessionfixup.js index 3bb2aa30..8cb13155 100644 --- a/javascript/node-oracledb/sessionfixup.js +++ b/javascript/node-oracledb/sessionfixup.js @@ -41,6 +41,7 @@ * *****************************************************************************/ +const fs = require('fs'); const http = require('http'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -51,10 +52,14 @@ const httpPort = 7000; // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } // initSession() will be invoked internally when each brand new pooled diff --git a/javascript/node-oracledb/sessiontagging1.js b/javascript/node-oracledb/sessiontagging1.js index ae7b9452..d016c16a 100644 --- a/javascript/node-oracledb/sessiontagging1.js +++ b/javascript/node-oracledb/sessiontagging1.js @@ -44,6 +44,7 @@ * *****************************************************************************/ +const fs = require('fs'); const http = require('http'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -54,10 +55,14 @@ const httpPort = 7000; // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } // initSession() will be invoked internally when each brand new pooled diff --git a/javascript/node-oracledb/sessiontagging2.js b/javascript/node-oracledb/sessiontagging2.js index 1ec2f106..3daf3c93 100644 --- a/javascript/node-oracledb/sessiontagging2.js +++ b/javascript/node-oracledb/sessiontagging2.js @@ -44,6 +44,7 @@ * *****************************************************************************/ +const fs = require('fs'); const http = require('http'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -54,10 +55,14 @@ const httpPort = 7000; // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } // initSession() will be invoked internally when each brand new pooled diff --git a/javascript/node-oracledb/soda1.js b/javascript/node-oracledb/soda1.js index 3172d8ad..08599e65 100644 --- a/javascript/node-oracledb/soda1.js +++ b/javascript/node-oracledb/soda1.js @@ -31,6 +31,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -39,10 +40,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } // The general recommendation for simple SODA usage is to enable autocommit diff --git a/javascript/node-oracledb/version.js b/javascript/node-oracledb/version.js index 873ffff3..5f63a3f3 100644 --- a/javascript/node-oracledb/version.js +++ b/javascript/node-oracledb/version.js @@ -27,6 +27,7 @@ * *****************************************************************************/ +const fs = require('fs'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -35,10 +36,14 @@ const dbConfig = require('./dbconfig.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } console.log("Run at: " + new Date()); diff --git a/javascript/node-oracledb/webapp.js b/javascript/node-oracledb/webapp.js index a5dc88ab..647bf3b6 100644 --- a/javascript/node-oracledb/webapp.js +++ b/javascript/node-oracledb/webapp.js @@ -44,6 +44,7 @@ // Note on Windows you must set the UV_THREADPOOL_SIZE environment variable before // running your application. +const fs = require('fs'); const http = require('http'); const oracledb = require('oracledb'); const dbConfig = require('./dbconfig.js'); @@ -54,10 +55,14 @@ const demoSetup = require('./demosetup.js'); // the system library search path must always be set before Node.js is started. // See the node-oracledb installation documentation. // If the search path is not correct, you will get a DPI-1047 error. -if (process.platform === 'win32') { // Windows - oracledb.initOracleClient({ libDir: 'C:\\oracle\\instantclient_19_11' }); -} else if (process.platform === 'darwin') { // macOS - oracledb.initOracleClient({ libDir: process.env.HOME + '/Downloads/instantclient_19_8' }); +let libPath; +if (process.platform === 'win32') { // Windows + libPath = 'C:\\oracle\\instantclient_19_12'; +} else if (process.platform === 'darwin') { // macOS + libPath = process.env.HOME + '/Downloads/instantclient_19_8'; +} +if (libPath && fs.existsSync(libPath)) { + oracledb.initOracleClient({ libDir: libPath }); } const httpPort = 7000;