mariano / node-db-oracle

Oracle database bindings for Node.js
http://nodejsdb.org
141 stars 34 forks source link

Oracle stored procedure with OUT parameters #33

Open shuracwf opened 12 years ago

shuracwf commented 12 years ago

I have an Oracle stored procedure like this:

CREATE OR REPLACE PROCEDURE Sp_CheckName(in_Name IN VARCHAR2, out_Ret OUT VARCHAR2) IS cnt NUMBER; BEGIN SELECT COUNT(1) INTO cnt FROM Person WHERE NAME = in_Name; out_Ret := cnt; END Sp_CheckName;

Is any idea for me to get out_Ret value in javascript by node-db-oracle? Thanks.

jlubean commented 11 years ago

There is an alternative to calling a stored procedure. You can convert the stored procedure to a function that returns a Table object containing the rows from the cursor. Now you can do a normal select against the table returned from the function!

If your function is called "my_function" and returns a table object, you can do something like this:

db.query("select * from table(my_function(?, ?))",[12345, 67890]).execute(function(error,rows) {...});