Skip to content

Instantly share code, notes, and snippets.

@aldomendez
Forked from isabolic/exec_orafn.js
Created October 18, 2016 11:19
Show Gist options
  • Save aldomendez/1cd24c6ccf2db9663084e45d64811078 to your computer and use it in GitHub Desktop.
Save aldomendez/1cd24c6ccf2db9663084e45d64811078 to your computer and use it in GitHub Desktop.
node js execute oracle pl sql stored function on database
(function() {
var db = require('oracledb');
var plSQLFun = "begin " +
" :ret := pkb_demo.f_get_price(:p1); " +
"end; ";
var executeOnDb = function() {
var bindvars = {
ret: { dir: oracledb.BIND_OUT, type: oracledb.NUMBER },
p1: 'Y'
};
db.execute(
plSQLFun,
bindvars,
function(err, result) {
if (err) {
console.log(err);
} else {
console.log("ret : " + result.outBinds.ret);
if (result.outBinds.ret === 1) {
console.log("is OK");
}
}
}
);
};
db.getConnection({
user: 'xxx',
password: 'xxx',
connectString: 'localhost:1521/XE'
}, executeOnDb);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment