Node-oracledb: Problem with INOUT REFCURSOR

Created on 19 Nov 2020  路  2Comments  路  Source: oracle/node-oracledb

node version: v15.2.0
oracledb version: 5.0.0
oracle: 18c

I have a problem with an INOUT cursor you can help me?

I have this code

        const result = await connection.execute(
            `BEGIN LEER_DEPARTAMENTO( :id, :CURSOR_ ); END;`, {
                id: '2',
                CURSOR_: { type: oracledb.CURSOR, dir: oracledb.BIND_INOUT }
            }
        );
        console.log(result);

        const resultSet = result.outBinds.cursor;

        let row;

        while ((row = await resultSet.getRow())) {
            console.log(row);
        }

        res.json(resultSet);

this returns nothing, in "console.log(result)" have this result:

{
  outBinds: {
    CURSOR_: ResultSet {
      _rowCache: [],
      _processingStarted: false,
      _convertedToStream: false,
      _allowGetRowCall: false,
      _parentObj: [Connection]
    }
  }
}
question

All 2 comments

Why are you referencing result.outBinds.cursor when it should be result.outBinds.CURSOR_ -- matching the name of the bind variable you created? You can also change the name of the bind variable in the SQL statement to cursor which should also resolve the issue.

thanks, bro! its work for me!

Was this page helpful?
0 / 5 - 0 ratings