How to use the oracledb.BIND_IN 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 / dmlReturning.js View on Github external
it('6.2.9 Negative test - bind value and type mismatch', function(done) {
      var wrongSQL = "UPDATE " + tableName + " SET content = :c WHERE num = :n RETURNING num, content INTO :rnum, :rcontent";
      var bindVar =
        {
          n: 0,
          c: { type: oracledb.STRING, dir: oracledb.BIND_IN, val: new Date(2003, 9, 23, 11, 50, 30, 123) },
          rnum: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT },
          rcontent: { type: oracledb.DATE, dir: oracledb.BIND_OUT }
        };

      connection.execute(
        wrongSQL,
        bindVar,
        function(err, result) {
          should.exist(err);
          // console.log(err.message);
          // NJS-011: encountered bind value and type mismatch
          (err.message).should.startWith('NJS-011:');

          should.not.exist(result);
          done();
        }
github oracle / node-oracledb / test / binding_functionBindOut.js View on Github external
function(cb) {
        var bind = {
          c1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
          c2: { val: inserted[0], type: inserted[1], dir: oracledb.BIND_IN }
        };
        // console.log(insertSql);
        connection.execute(
          insertSql,
          bind,
          function(err, result) {
            should.not.exist(err);
            should.strictEqual(result.rowsAffected, 1);
            cb();
          });
      },
      function(cb) {
github oracle / node-oracledb / test / plsqlBindIndexedTable2.js View on Github external
function(callback) {
        connection.execute(
          "BEGIN nodb_beachpkg.array_in(:beach_in, :depth_in); END;",
          {
            beach_in: { type: oracledb.STRING,
              dir:  oracledb.BIND_IN,
              val:  ["Malibu Beach", "Bondi Beach", "Waikiki Beach"] },
            depth_in: { type: oracledb.NUMBER,
              dir:  oracledb.BIND_IN,
              val:  [45, 30, 67]
            }
          },
          function(err) {
            should.not.exist(err);
            callback();
          }
        );
      },
      // Fetch arrays of values from a PL/SQL procedure
github oracle / node-oracledb / test / fetchClobAsString4.js View on Github external
function(cb) {
          connection.execute(
            sqlRun,
            {
              i1: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
              i2: { val: null, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
              c: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN },
              output: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }
            },
            function(err, result) {
              should.not.exist(err);
              var resultVal = result.outBinds.output;
              verifyResult(resultVal, specialStr, clobStr);
              cb();
            }
          );
        }
      ], done);
github oracle / node-oracledb / test / urowidFunctionBindAsString1.js View on Github external
var funBindOut = function(fun_exec, content_in, expected, callback) {
    var bindVar_in = {
      i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
      c: { val: content_in, type: oracledb.STRING, dir: oracledb.BIND_IN },
      o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
    };
    connection.execute(
      fun_exec,
      bindVar_in,
      function(err, result) {
        should.not.exist(err);
        var resultVal = result.outBinds.o;
        should.strictEqual(resultVal, expected);
        callback();
      }
    );
  };
github oracle / node-oracledb / test / urowidFunctionBindAsString4.js View on Github external
function(cb) {
        var bindVar_in = {
          i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
          c: { val: urowid, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 5000 },
          o: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 5000 }
        };
        connection.execute(
          fun_execute,
          bindVar_in,
          function(err, result) {
            should.not.exist(err);
            var resultVal_1 = result.outBinds.c;
            var resultVal_2 = result.outBinds.o;
            should.strictEqual(resultVal_1.length, urowidLen);
            should.strictEqual(resultVal_2.length, urowidLen);
            should.strictEqual(resultVal_1, urowid);
            should.strictEqual(resultVal_2, urowid);
            cb();
          }
github oracle / node-oracledb / test / fetchArraySize3.js View on Github external
function(callback) {
          connection.execute(
            "select * from " + tableName + " where id > :num order by id",
            { num: { val: affectedRowId, dir: oracledb.BIND_IN, type: oracledb.NUMBER } },
            function(err, result) {
              should.not.exist(err);
              should.strictEqual(result.rows.length, tableSize - affectedRowId);
              verifyResult(result.rows, affectedRowId);
              callback();
            }
          );
        }
      ], cb);
github oracle / node-oracledb / test / longProcedureBind_inout.js View on Github external
var long_bindinout = function(insertContent, proc_bindinout_exec, callback) {
    var bind_in_var  = {
      i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
      c: { val: insertContent, dir: oracledb.BIND_INOUT, type: oracledb.STRING }
    };
    connection.execute(
      proc_bindinout_exec,
      bind_in_var,
      function(err, result) {
        should.not.exist(err);
        var expected = insertContent;
        if(insertContent == "" || insertContent == undefined) {
          expected = null;
        }
        should.strictEqual(result.outBinds.c, expected);
        callback();
      }
    );
  };
github oracle / node-oracledb / test / longrawProcedureBind_out.js View on Github external
var insert = function(insertStr, callback) {
    connection.execute(
      "insert into " + tableName + " values (:i, :c)",
      {
        i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
        c: { val: insertStr, type: oracledb.BUFFER, dir: oracledb.BIND_IN }
      },
      function(err, result) {
        should.not.exist(err);
        should.strictEqual(result.rowsAffected, 1);
        callback();
      }
    );
  };
github danilohgds / graphql-oracle / src / managers / country.manager.ts View on Github external
return this.oraclePool.getConnection().then((connection:any) => {
            connection.clientIdentifier = 'addCountry';
            const params = {
                id: { type: oracleI.STRING, dir: oracleI.BIND_IN, val: countryId },
                name: { type: oracleI.STRING, dir: oracleI.BIND_IN, val: countryName }
            };
            return connection.execute(countryQuery,params).then((result: any) =>{
                    console.log(result.rows[0]);
                    let cList:CountryList = {
                            countryId: result.rows[0][0],
                            countryName:  result.rows[0][1],
                            regionId:  result.rows[0][2]
                    }
                    doRelease(connection);
                    return cList;
                }
            );
        });
    }