node-oracle icon indicating copy to clipboard operation
node-oracle copied to clipboard

reader and stored procedures results in 'connection already closed' error

Open ryanwilliamquinn opened this issue 11 years ago • 1 comments

I have some testcases that I am running - if I run this code to call a stored procedure:

 oracle.connect(connectData, function(err, connection) {
        connection.execute("call my stored procedure",
          ['some', 'inparams', new oracle.OutParam(oracle.OCCICURSOR), new oracle.OutParam(oracle.OCCISTRING, {size: 40})], function(err, results) {
          if (err) {console.log('error', err);}
          else {console.log('results:', results);}
          connection.close();
    })
})

I get results that look like this, as expected:

{ updateCount: 0,
  returnParam: 
   [ {field: value, field: value} ],
  returnParam1: 'SUCCESS' }

If I try to make the same request using the reader, I get an error that says the connection is already closed - even though when I test the connection after that error, it still claims to be open.

Here is the code I tried with the reader and the stored procedure:

oracle.connect(connectData, function(err, connection) {
        connection.setPrefetchRowCount(50);
        var reader = connection.reader("call my stored procedure",
          ['some', 'inparams', new oracle.OutParam(oracle.OCCICURSOR), new oracle.OutParam(oracle.OCCISTRING, {size: 40})]);

        function doRead(cb) {
          reader.nextRow(function(err, row) {
            console.log( connection.isConnected());  // connected
            if (err) return cb(err); // returns here with [Error: Connection already closed]
            if (row) {
              // do something with row
              console.log("got " + JSON.stringify(row));
              // recurse to read next record
              return doRead(cb)
            } else {
              // we are done
              done();
              return cb();
            }
          })
        }

        doRead(function(err) {
          if (err) {
            console.log(connection.isConnected()); // still connected
            connection.close()
            console.log(connection.isConnected()); // finally disconnected
            done();
            return console.log(err);
          } // or log it
          console.log("all records processed");
        });
      });

ryanwilliamquinn avatar Mar 13 '14 22:03 ryanwilliamquinn

Did you ever resolve this? I'm seeing the same thing.

jordabi avatar May 08 '15 14:05 jordabi