Forum Stats

  • 3,826,609 Users
  • 2,260,677 Discussions
  • 7,897,029 Comments

Discussions

SYS_REFCURSOR

user13423260
user13423260 Member Posts: 1
edited Apr 21, 2015 11:22AM in Node.js

HI,

Have node-oracledb support for sys_refcursor?


example:

oracledb.getConnection(
  {
       user : dbConfig.user,
       password : dbConfig.password,
       connectString : dbConfig.connectString
  },
  function(err, connection) {
   if (err) { console.log("Error connecting to db:", err); return; }
   var bindvars = {
      ???
  }
   connection.execute(
   "BEGIN " +
        "getDBUSERCursor('mkyong',:c_dbuser); " +
        "LOOP " +
             "ETCH :c_dbuser INTO :temp_dbuser; " +
             "EXIT WHEN c_dbuser%NOTFOUND; " +
             "dbms_output.put_line(:temp_dbuser.username); " +
        "END LOOP; " +
   "CLOSE c_dbuser; " +
   "END;",
   bindvars,

  function(err, results) {
        if (err) { console.log("Error executing query:", err); return; }
        console.log(results.outBinds);
   });
});  


CREATE OR REPLACE PROCEDURE getDBUSERCursor(

p_username IN DBUSER.USERNAME%TYPE,

c_dbuser OUT SYS_REFCURSOR)

IS

BEGIN

  OPEN c_dbuser FOR

  SELECT * FROM DBUSER WHERE USERNAME LIKE p_username || '%';

END;

/

Thanks!

Tagged:

Answers