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

What am I doing wrong with setPrefetchRowCount?

Open RobertZito opened this issue 12 years ago • 3 comments

I really can not make sense of this, if you look through the code below, if I place close connection the prefetch does not work. Once I take I get 90 rows but never make it to all records processed so I know the connection did not close. What am I doing wrong here?

oracle.connect(connectData, function(err, connection) { if (err) { console.log("Error connecting to db:", err); return; } connection.setPrefetchRowCount(90); var reader = connection.reader("SELECT * FROM CAR", []); function doRead(cb) { reader.nextRow(function(err, row) { if (err) return cb(err); if (row) { // do something with row console.log("got " + JSON.stringify(row)); // recurse to read next record return doRead(cb) } else { // we are done return cb(); } }) } doRead(function(err) { if (err) throw err; // or log it
console.log("all records processed"); //connection.close(); If this is not commentted out the //connection.setPrefetchRowCount(90); does not work. }); });

RobertZito avatar Mar 14 '14 00:03 RobertZito

There has to be a semicolon missing in the Basic example with setPrefetchRowCount(90), test it yourself you will not get to console.log("all records processed");

RobertZito avatar Mar 14 '14 01:03 RobertZito

I have a similar issue using the basic example querying large table, only goes through the prefetch row count i specify and after that i get a segmenation fault (core dumped)

ninetwentyone avatar Aug 12 '14 14:08 ninetwentyone

figured it out, had to add a connection.close() inside the else before return cb();

ninetwentyone avatar Aug 12 '14 15:08 ninetwentyone