Beispiel #1
0
exports.callProcedures = function(schema, procedure, array, cb){
  db2client.open(connString , function(err){
    if(err){
      cb(err, undefined);
    } else {
      db2client.query("call "+schema+"."+procedure+"("+"?".concat(Array(array.length).join(",?"))+")", array, function (err, rows) {
        if(err){
          cb(err, undefined);
        } else {
          db2client.close(function () {
            cb(null, rows);
          });
        }
      })
    }
  })
}
Beispiel #2
0
exports.selectDataFromTable = function(tableName, colName, options, cb){
  db2client.open(connString , function(err){
    if(err){
      cb(err, undefined);
    } else {
      var colStrList = "*";
      var conditions = "";
      if(colName)
        colStrList = generateCol(colName);
      if(options)
        conditions = generateConditions(options);
      db2client.query("select "+colStrList+" from "+ tableName+conditions, function (err, rows) {
        if(err){
          cb(err, undefined);
        } else {
          db2client.close(function () {
            cb(null, rows);
          });
        }
      })
    }
  })
}
/*
 * oracle test
 */

var odbc = require("odbc");

var db = new odbc.Database();
var cs = "DSN=<DataSourceName>;UID=<UserName>;PWD=<Password>";
db.open(cs, function(err){
	var sql = "select foo, bar from HOGE order by foo";
	db.query(sql, function(err, rows, rs){
		//console.log(rows);
		var i=0;
		for (i=0; i<rows.length; i++) {
			console.log([
				i,
				rows[i]["foo"],
				rows[i]["bar"]
			].join(", "));
		}

		db.close(function(){
			console.log("close.");
		});
	});
});
Beispiel #4
0
// database using an integer id, get a "handle" in response and then to get result of the run using that
// "handle" passed to a separate http get

var express = require('express');
var util = require('util');
var odbc = require("odbc");
var uuid = require('node-uuid');
var db = new odbc.Database();
var fs = require('fs');
var spawn = require('child_process').spawn;
var config = require('./config');

db.open(config.connection_string, function(err)
{
    if (err) {
      console.log(err);
      process.exit(1);
    } 
});


var app = express();
 
app.get('/samples/:id', function(req, res) {
    db.query("select meta from Samples where sample_id = ?", [req.params.id], function(err, rows, moreResultSets)
    {
        res.header("Content-Type", "text/xml"); 
        res.send(rows[0].meta);
        util.debug(util.inspect(rows));
    });
});