Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. var oracledb = require('oracledb');
  2.  
  3. dbquery = function(user, pass, db, query, callback) {
  4. oracledb.getConnection({ user : user, password : pass, connectString : db }, function(err, connection) {
  5. if (err) {
  6. callback("Couldn't connect to db " + db + " got an error " + err, null);
  7. }
  8. connection.execute(query, function(err, result) {
  9. if (err) {
  10. callback("Couldn't execute query in db " + db + " got an error " + err, null);
  11. }
  12. callback(null, result.rows);
  13. });
  14. });
  15. }
  16.  
  17. dbquery("oracledb", "oraclepass", "localhost:1521/oracledbs", "SELECT * FROM Users", function(err, res) {
  18. if (err) {
  19. console.log(err);
  20. } else {
  21. console.log(res);
  22. }
  23. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement