Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('76.1.11 works with undefined and maxSize set to 1', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: undefined, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 1 }
};
plsqlBindInOut(sqlRun, bindVar, undefined, null, done);
}); // 76.1.11
it('86.2.5 Number supported in fetchAsString', function(done) {
should.doesNotThrow(
function() {
oracledb.fetchAsString = [ oracledb.NUMBER ];
}
);
should.strictEqual(oracledb.fetchAsString.length, 1);
should.strictEqual(oracledb.fetchAsString[0], oracledb.NUMBER);
done();
}); // 86.2.5
await testsUtil.assertThrowsAsync(async () => {
await bindNumberListByPosition(conn, [
[],
{ type: oracledb.NUMBER, dir: oracledb.BIND_OUT },
]);
// PLS-00418: array bind type must match PL/SQL table row type
}, /PLS-00418:/);
} catch (err) {
const sql = "INSERT INTO no_em_tab VALUES (:1, :2) RETURNING ROWID, id, val INTO :3, :4, :5";
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 connection;
try {
connection = await oracledb.getConnection(dbConfig);
await demoSetup.setupEm(connection); // create the demo tables
const result = await connection.executeMany(sql, binds, options);
console.log("rowsAffected is:", result.rowsAffected);
console.log("Out binds:");
const sql = "INSERT INTO no_em_tab values (:1, :2)";
const binds = [
[1, "Test 1 (One)"],
[2, "Test 2 (Two)"],
[3, "Test 3 (Three)"],
[4, null],
[5, "Test 5 (Five)"]
];
// bindDefs is optional for IN binds but it is generally recommended.
// Without it the data must be scanned to find sizes and types.
const options = {
autoCommit: true,
bindDefs: [
{ type: oracledb.NUMBER },
{ type: oracledb.STRING, maxSize: 15 }
]
};
async function run() {
let connection;
try {
connection = await oracledb.getConnection(dbConfig);
await demoSetup.setupEm(connection); // create the demo tables
const result = await connection.executeMany(sql, binds, options);
console.log("Result is:", result);
} catch (err) {
function(cb) {
var bindVar_in = {
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: urowid, type: oracledb.STRING, dir: oracledb.BIND_IN }
};
var option_in = { autoCommit: true };
sql.executeSql(connection, proc_execute, bindVar_in, option_in, cb);
},
function(cb) {
function(cb) {
var sql = "INSERT INTO nodb_tab_clob1 VALUES(:i, :d)";
var bindVar = {
i: { val: seq, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
d: { val: lobData, dir: oracledb.BIND_IN, type: oracledb.STRING }
};
connection.execute(
sql,
bindVar,
{ autoCommit: true },
function(err, result) {
should.not.exist(err);
should.strictEqual(result.rowsAffected, 1);
cb();
}
);
},
function bindCLOB(cb) {
function(err, result) {
should.not.exist(err);
(result.metaData[0]).should.deepEqual(
{ name: 'NUM',
fetchType: oracledb.NUMBER,
dbType: oracledb.DB_TYPE_NUMBER,
dbTypeName: "NUMBER",
precision: 0,
scale: -127,
nullable: true }
);
(result.metaData[1]).should.deepEqual(
{ name: 'VCH',
fetchType: oracledb.STRING,
dbType: oracledb.DB_TYPE_VARCHAR,
dbTypeName: "VARCHAR2",
byteSize: 1000,
nullable: true }
);
(result.metaData[2]).should.deepEqual(
{ name: 'DT',
var procedureBindOut = function(proc_execute, content_in, expected, callback) {
var bindVar_out = {
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(
proc_execute,
bindVar_out,
function(err, result) {
should.not.exist(err);
var resultVal = result.outBinds.o;
should.strictEqual(resultVal, expected);
callback();
}
);
};
END;`);
await connection.execute(
`BEGIN
DBMS_OUTPUT.PUT_LINE('Hello, Oracle!');
DBMS_OUTPUT.PUT_LINE('Hello, Node!');
END;`);
let result;
do {
result = await connection.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 } });
if (result.outBinds.st === 0)
console.log(result.outBinds.ln);
} while (result.outBinds.st === 0);
} catch (err) {
console.error(err);
} finally {
if (connection) {
try {
await connection.close();
} catch (err) {
console.error(err);
}
}
}
}