-
-
Save aldomendez/1cd24c6ccf2db9663084e45d64811078 to your computer and use it in GitHub Desktop.
node js execute oracle pl sql stored function on database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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