问题
I am using db-oracle module (node.js) to query the tables (SEARCH command). I am able to fetch the records successfully.
I need to execute the stored procedure. Any idea how to execute a oracle stored procedure from node js code ? Can i execute through db-oracle module ? Or anyother module is available ?
Note: The stored procedure returns multiple values, I need to capture that too.
回答1:
You should be able to call that procedure from the .query
method, like:
var oracle = require('db-oracle');
new oracle.Database({
hostname: 'localhost', user: 'root',
password: 'password', database: 'node'
}).connect(function(error) {
if (error) { return console.log("CONNECTION ERROR: " + error); }
this.query("BEGIN SOME_PROC(); END;").execute(function(error, rows) {
if (error) {
return console.log('ERROR: ' + error);
}
/* Do something with rows here */
});
});
来源:https://stackoverflow.com/questions/13350401/how-to-execute-stored-procedure-through-node-js