Can anyone assist with letting me know where I need to define the connection because I keep on getting an error. This is my first stab at this and have been at it for some time now so any help would greatly be appreciated.
var Oracle = require('oracle');
var connectData = {
hostname: "127.0.0.1",
port: 1521,
database: "hr", // System ID (SID)
user: "user",
password: "password"
}
Oracle.connect = function(callback) {
oracle_driver.connect(connectData, function(err, connection) {
if (err) {
console.log(err);
} else {
callback(err, connection);
}
connection.close();
});
}
var statement = connection.prepare("SELECT * FROM HR where rownum < :1");
function runQuery(stmt, row_num, cb) {
stmt.execute([row_num], function(err, count) {
if (err) return cb(err);
if (count !== 1) return cb(new Error("bad count: " + count));
// We are done
return cb();
});
}
runQuery(statement, 90, function(err) {
if (err) {
console.log("Error executing query:", err);
return;
}
console.log(results);
connection.close(); // call only when query is finished executing
});