FAQ
Is anyone familiar with this package
  https://github.com/joeferner/node-oracle<https://github.com/joeferner/node-oracle>? It is the plugin that allows you to interact with oracle. On the website
it provides an example for you to connect to a database and set the rownum
with setPrefetchRowCount. So I took the example filled in my database
connection and it works but I never make it to console.log("all records
processed"). The second you add any other console.log to the code it will
make it to "all records processed" BUT the setPrefetchRowCount no longer
works it pulls every record out. I am convinced there is a semi colon
missing somewhere in the example but my debugging skill are limited at
best, I have only been working with node for about a week now.

Thanks for the help!



var oracle = require('oracle');
var connectData = {
     hostname: "127.0.0.1",
     port: 1521,
     database: "xe", // System ID (SID)
     user: "user",
     password: "password"};

oracle.connect(connectData, function(err, connection) {
     if (err) {
         console.log("Error connecting to db:", err);
         return;
     }
     connection.setPrefetchRowCount(50);
     var reader = connection.reader("SELECT * FROM CARS", []);
     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");
     });

});

--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Bruno Jouhier at Mar 14, 2014 at 10:11 pm
    Hi Bob,

    setPrefetchRowCount(50) is only a hint. It tells the driver to fetch 50
    records at a time instead of fetching them 1 by 1. It should only impact
    performance, not the actual result set that you get.

    I saw your message on GitHub. I added the reader API to the driver and I
    may be able to help you but only after March 25 because I'm taking a break
    and I won't have my computer.

    Bruno.
    On Friday, March 14, 2014 10:10:36 AM UTC+1, Bob Spero wrote:

    Is anyone familiar with this package
    https://github.com/joeferner/node-oracle<https://github.com/joeferner/node-oracle>? It is the plugin that allows you to interact with oracle. On the website
    it provides an example for you to connect to a database and set the rownum
    with setPrefetchRowCount. So I took the example filled in my database
    connection and it works but I never make it to console.log("all records
    processed"). The second you add any other console.log to the code it will
    make it to "all records processed" BUT the setPrefetchRowCount no longer
    works it pulls every record out. I am convinced there is a semi colon
    missing somewhere in the example but my debugging skill are limited at
    best, I have only been working with node for about a week now.

    Thanks for the help!



    var oracle = require('oracle');
    var connectData = {
    hostname: "127.0.0.1",
    port: 1521,
    database: "xe", // System ID (SID)
    user: "user",
    password: "password"};

    oracle.connect(connectData, function(err, connection) {
    if (err) {
    console.log("Error connecting to db:", err);
    return;
    }
    connection.setPrefetchRowCount(50);
    var reader = connection.reader("SELECT * FROM CARS", []);
    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");
    });

    });
    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Bob Spero at Mar 14, 2014 at 10:30 pm
    Bruno, you enjoy the break! It is more of an exercise for me to learn node
    but I do see the potential with this package. Again you enjoy yourself!!!!!


    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Bruno Jouhier at Mar 14, 2014 at 10:55 pm
    Thanks Bob. I'll enjoy for sure. Beach time :-)

    The oracle driver is used by a smaller community than some other drivers
    (mongodb for ex) so you are more likely to run into bugs, and maybe
    platform specific bugs too because it is implemented with a binary module.
    Don't hesitate to report the problems though. There are some good souls who
    are around to help.
    On Friday, March 14, 2014 11:30:42 PM UTC+1, Bob Spero wrote:

    Bruno, you enjoy the break! It is more of an exercise for me to learn node
    but I do see the potential with this package. Again you enjoy yourself!!!!!

    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Shubhra Kar at Mar 14, 2014 at 10:50 pm
    Have you checked out StrongLoop's Loopback-Oracle connector ? Open source
    module for Node-Oracle connection mgmt, transaction mgmt, object discovery
    and ORM. Eventually lets you generate JSON APIs in Node against an Oracle
    Database.

    http://docs.strongloop.com/display/DOC/Oracle+connector

    http://strongloop.com/mobile-application-development/loopback/

    Please contact me skar@strongloop.com, if this solves your problem

    --
    Shubhra

    On Friday, March 14, 2014 2:10:36 AM UTC-7, Bob Spero wrote:

    Is anyone familiar with this package
    https://github.com/joeferner/node-oracle<https://github.com/joeferner/node-oracle>? It is the plugin that allows you to interact with oracle. On the website
    it provides an example for you to connect to a database and set the rownum
    with setPrefetchRowCount. So I took the example filled in my database
    connection and it works but I never make it to console.log("all records
    processed"). The second you add any other console.log to the code it will
    make it to "all records processed" BUT the setPrefetchRowCount no longer
    works it pulls every record out. I am convinced there is a semi colon
    missing somewhere in the example but my debugging skill are limited at
    best, I have only been working with node for about a week now.

    Thanks for the help!



    var oracle = require('oracle');
    var connectData = {
    hostname: "127.0.0.1",
    port: 1521,
    database: "xe", // System ID (SID)
    user: "user",
    password: "password"};

    oracle.connect(connectData, function(err, connection) {
    if (err) {
    console.log("Error connecting to db:", err);
    return;
    }
    connection.setPrefetchRowCount(50);
    var reader = connection.reader("SELECT * FROM CARS", []);
    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");
    });

    });
    --
    --
    Job Board: http://jobs.nodejs.org/
    Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
    You received this message because you are subscribed to the Google
    Groups "nodejs" group.
    To post to this group, send email to nodejs@googlegroups.com
    To unsubscribe from this group, send email to
    nodejs+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/nodejs?hl=en?hl=en

    ---
    You received this message because you are subscribed to the Google Groups "nodejs" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnodejs @
categoriesnodejs
postedMar 14, '14 at 9:10a
activeMar 14, '14 at 10:55p
posts5
users3
websitenodejs.org
irc#node.js

People

Translate

site design / logo © 2022 Grokbase