Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
}
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) {
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
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);
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();
}
);
};
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();
}
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);
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();
}
);
};
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();
}
);
};
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;
}
);
});
}