node-oracle
node-oracle copied to clipboard
reader and stored procedures results in 'connection already closed' error
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");
});
});
Did you ever resolve this? I'm seeing the same thing.