Skip to content

Instantly share code, notes, and snippets.

@isabolic
Last active August 23, 2022 10:46
Show Gist options
  • Save isabolic/c4318ae271663c8d22b2184e7a852c10 to your computer and use it in GitHub Desktop.
Save isabolic/c4318ae271663c8d22b2184e7a852c10 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);
})();
@isabolic
Copy link
Author

-execute plsql stored function on oracle from node.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment