node.js - NodeJs + OracleDB + load sql file -
the problem simple, cant load sql file using oracledb connector. seems doesn´t supoport more 1 sentence.
any idea how load sql file?
var oracledb = require('oracledb'); var fs = require('fs'); fs.readfile("test.sql", function(err, data) { if (err) { throw err; } connect(data.tostring()); }); function connect(sql) { oracledb.getconnection({ user: "****", password: "***", connectstring: "****" }, function(err, connection) { if (err) { console.error(err.message); return; } connection.execute( sql, [], function(err, result) { if (err) { console.error(err.message); dorelease(connection); return; } console.log(result.metadata); console.log(result.rows); dorelease(connection); }); }); } function dorelease(connection) { connection.release( function(err) { if (err) { console.error(err.message); } }); }
it throws error:
ora-00911: invalid character
the sql here:
select * defecto; select * esquema;
battled long time before realizing it's semicolon connection.execute() method doesn't like. long sql statement doesn't conclude one, reading file works.
Comments
Post a Comment