how to execute stored procedure through node js

北城以北 提交于 2021-02-10 05:31:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!