Below...
On Thu, Mar 6, 2014 at 4:50 PM, Bob Spero <bobsp...@gmail.com> wrote: > I am using node oracle to* connection.execute("SELECT alot of stuff FROM > inventory")*. So I took all my original sql files and I put them in a > folder. Now I want to use node to read the file contents and do * > connection.execute(function(inventory.sql)) > *where in the sql file is my select. Some of the queries have three table > joins so it make the code look messy and it just seems more organize. Below > is what I have so far but I just can not get it working! Thanks > > > fs = require('fs'); > var select_statement = ""; > var sql_file = function(value) { > fs.readFile('./SQLs/inventory.sql', 'utf8', function(err, data) { > if (err) { > return console.log(err); > }; > return data.toString(); > }); > //return value //+ select_statement; > }; > module.exports.select_statement = select_statement; > module.exports.sql_file = sql_file; > fs.readFile is async, so you need to send along a callback to handle the results of the read: var fs = require('fs'); var sql_file = function(value, callback) { fs.readFile('./SQLs/inventory.sql', 'utf8', function(err, data) { if (err) { return console.log(err); }; callback(data.toString()); }); }; module.exports.sql_file = sql_file; Rick -- -- 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+unsubscr...@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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.