How to use the oracledb.STRING function in oracledb

To help you get started, we’ve selected a few oracledb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oracle / node-oracledb / test / connection.js View on Github external
it('1.2.1 bind parameters in various ways', function(done){
      var bindValues = {
        i: 'Alan', // default is type STRING and direction Infinity
        io: { val: 'Turing', type: oracledb.STRING, dir: oracledb.BIND_INOUT },
        o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
      };
      connection.should.be.ok();
      connection.execute(
        "BEGIN nodb_bindingtest(:i, :io, :o); END;",
        bindValues,
        function(err, result){
          should.not.exist(err);
          (result.outBinds.io).should.equal('Turing');
          (result.outBinds.o).should.equal('Alan Turing');
          done();
        }
      );
    });
  });
github oracle / oracle-db-examples / javascript / node-oracledb / dbmsoutputgetline.js View on Github external
var fetchDbmsOutputLine = function (conn, cb) {
  conn.execute(
    "BEGIN DBMS_OUTPUT.GET_LINE(:ln, :st); END;",
    { ln: { dir: oracledb.BIND_OUT, type: oracledb.STRING, maxSize: 32767 },
      st: { dir: oracledb.BIND_OUT, type: oracledb.NUMBER } },
    function(err, result) {
      if (err) {
        return cb(err, conn);
      } else if (result.outBinds.st == 1) {
        return cb(null, conn);  // no more output
      } else {
        console.log(result.outBinds.ln);
        return fetchDbmsOutputLine(conn, cb);
      }
    });
};
github oracle / node-oracledb / test / binding_procedureBindOut.js View on Github external
it('96.1.1 oracledb.STRING <--> DB: NUMBER', function(done) {
      index++;
      var table_name = tableNamePre + index;
      var proc_name = procPre + index;
      var content = "small string";
      var bindType = oracledb.STRING;
      var dbColType = "NUMBER";
      var nullBind = false;
      doTest(table_name, proc_name, bindType, dbColType, content, index, nullBind, done);
    });
github oracle / node-oracledb / test / rowidDMLBindAsString.js View on Github external
it('107.1.1 works with null', function(done) {
      var content = null;
      var bindVar = {
        i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
        c: { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING }
      };
      dmlInsert(bindVar, content, done);
    });
github oracle / node-oracledb / test / rowidProcedureBindAsString_bindout.js View on Github external
it('110.1.4 works with NaN', function(done) {
      var content = NaN;
      var bindVar = {
        i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
        c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_IN },
        o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
      };
      sql.executeSqlWithErr(connection, proc_execute, bindVar, {}, function(err) {
        should.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
        done();
      });
    });
github oracle / node-oracledb / test / fetchClobAsString3.js View on Github external
function() {
          oracledb.fetchAsString = [ oracledb.STRING ];
        },
        /NJS-021: invalid type for conversion specified/
github oracle / node-oracledb / test / urowidProcedureBindAsString1.js View on Github external
var procedureBindIn_update = function(proc_execute, content_1, content_2, expected, callback) {
    var bindVar_in = {
      i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
      c1: { val: content_1, type: oracledb.STRING, dir: oracledb.BIND_IN },
      c2: { val: content_2, type: oracledb.STRING, dir: oracledb.BIND_IN }
    };
    var option_in = { autoCommit: true };
    async.series([
      function(cb) {
        sql.executeSql(connection, proc_execute, bindVar_in, option_in, cb);
      },
      function(cb) {
        var sql = "select * from " + tableName + " where id = " + insertID;
        connection.execute(
          sql,
          function(err, result) {
            should.not.exist(err);
            var resultVal = result.rows[0][1];
            should.strictEqual(resultVal, expected);
            cb();
github oracle / node-oracledb / test / urowidProcedureBindAsString6.js View on Github external
function(cb) {
        var bindVar_inout = {
          i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
          c: { val: urowid, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 5000 }
        };
        connection.execute(
          proc_execute,
          bindVar_inout,
          function(err, result) {
            should.not.exist(err);
            var resultVal = result.outBinds.c;
            should.strictEqual(resultVal, urowid);
            cb();
          }
        );
      }
    ], callback);
github oracle / node-oracledb / test / nclobDMLBindAsString.js View on Github external
var bind_where = function(tableName, insertStr, callback) {
    var sql = "select * from " + tableName + " where dbms_lob.compare(content, TO_NCLOB(:c)) = 0";
    var bindVar = {
      c: { val: insertStr, type: oracledb.STRING, dir: oracledb.BIND_IN}
    };
    connection.execute(
      sql,
      bindVar,
      {
        fetchInfo : { CONTENT : { type : oracledb.STRING } }
      },
      function(err, result) {
        should.not.exist(err);
        should.strictEqual(result.rows[0][0], insertID);
        should.strictEqual(result.rows[0][1], insertStr);
        callback();
      }
    );
  };
github oracle / node-oracledb / examples / em_dmlreturn1_aa.js View on Github external
const binds = [
  [1, "Test 1 (One)"],
  [2, "Test 2 (Two)"],
  [3, "Test 3 (Three)"],
  [4, null],
  [5, "Test 5 (Five)"]
];

const options = {
  bindDefs: [
    { type: oracledb.NUMBER },
    { type: oracledb.STRING, maxSize: 20 },
    { type: oracledb.STRING, maxSize: 18, dir: oracledb.BIND_OUT },
    { type: oracledb.NUMBER, dir: oracledb.BIND_OUT },
    { type: oracledb.STRING, maxSize: 25, dir: oracledb.BIND_OUT }
  ]
};

async function run() {
  let conn;
  let result;

  try {
    conn = await oracledb.getConnection(dbConfig);

    await conn.execute(truncateSql);

    result = await conn.executeMany(insertSql, binds, options);

    console.log("rowsAffected is:", result.rowsAffected);
    console.log("Out binds:");