alexa
Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry

Oracle DB Result not printing in Node.js ?

Oracle DB  Result not printing in Node.js ?

Try This 

 'use strict';

process.env.ORA_SDTZ = 'UTC';

const oracledb = require('oracledb');

const dbConfig = { user: 'cj', password: process.env.NODE_ORACLEDB_PASSWORD, connectString: 'localhost/orclpdb1' };

let libPath;
if (process.platform === 'win32') {           // Windows
  libPath = 'C:\\oracle\\instantclient_19_14';
} else if (process.platform === 'darwin') {   // macOS
  libPath = process.env.HOME + '/Downloads/instantclient_19_8';
}
if (libPath && fs.existsSync(libPath)) {
  oracledb.initOracleClient({ libDir: libPath });
}

let sql, binds, options, result;
sql = `select * from merchant_accounts`;
binds = [];
options = { outFormat: oracledb.OUT_FORMAT_OBJECT };

async function run() {
  let connection;

  try {
    connection = await oracledb.getConnection(dbConfig);

    result = await connection.execute(sql, binds, options);
    console.dir(result, { depth: null });

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

run();

98 0
7

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online