It looks like you need to use readFileSync<http://nodejs.org/api/fs.html#fs_fs_readfilesync_filename_options> rather than readFile (which is asynchronous). Otherwise you won't be able to return the contents of your file in the manner in which you've described (synchronous).
Colin On Thu, Mar 6, 2014 at 1: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; > > -- > -- > 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. > -- -- 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.