More test refactoring
This commit is contained in:
parent
8c38fd6542
commit
a87c25cc9a
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017, 2022, Oracle and/or its affiliates. */
|
||||
/* Copyright (c) 2017, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
|
@ -41,7 +41,7 @@ describe('102. bindTimestamp.js', function() {
|
|||
|
||||
before(async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
var sql = "alter session set nls_timestamp_format = 'YYYY-MM-DD HH24:MI:SS.FF'";
|
||||
let sql = "alter session set nls_timestamp_format = 'YYYY-MM-DD HH24:MI:SS.FF'";
|
||||
await runSQL(sql);
|
||||
sql = "alter session set nls_timestamp_tz_format = 'YYYY-MM-DD HH24:MI:SS.FF'";
|
||||
await runSQL(sql);
|
||||
|
|
|
@ -74,7 +74,7 @@ describe('82.blobDMLBindAsBuffer.js', function() {
|
|||
|
||||
let insertIntoBlobTable1 = async function(id, content) {
|
||||
let result = null;
|
||||
if (content == "EMPTY_BLOB") {
|
||||
if (content === "EMPTY_BLOB") {
|
||||
result = await connection.execute(
|
||||
"INSERT INTO nodb_dml_blob_1 VALUES (:ID, EMPTY_BLOB())",
|
||||
[ id ]);
|
||||
|
@ -92,7 +92,7 @@ describe('82.blobDMLBindAsBuffer.js', function() {
|
|||
|
||||
let updateBlobTable1 = async function(id, content) {
|
||||
let result = null;
|
||||
if (content == "EMPTY_BLOB") {
|
||||
if (content === "EMPTY_BLOB") {
|
||||
result = await connection.execute(
|
||||
"UPDATE nodb_dml_blob_1 set blob = EMPTY_BLOB() where id = :ID",
|
||||
{ ID: id });
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -32,20 +32,17 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const file = require('./file.js');
|
||||
const sql = require('./sql.js');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
|
||||
describe('127.blobStream.js', function() {
|
||||
let connection = null;
|
||||
var fileRoot = ".";
|
||||
var insertID = 1;
|
||||
var inFileName;
|
||||
const fileRoot = ".";
|
||||
let insertID = 1;
|
||||
|
||||
var proc_blob_prepare_tab = "BEGIN \n" +
|
||||
const proc_blob_prepare_tab = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
|
@ -63,149 +60,86 @@ describe('127.blobStream.js', function() {
|
|||
" '); \n" +
|
||||
"END; ";
|
||||
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function(cb) {
|
||||
setupAllTable(cb);
|
||||
}
|
||||
], done);
|
||||
before(async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
await setupAllTable();
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
dropAllTable(cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
after(async function() {
|
||||
await dropAllTable();
|
||||
await connection.close();
|
||||
}); // after
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function() {
|
||||
insertID++;
|
||||
done();
|
||||
});
|
||||
|
||||
describe('127.1 stream txt file into BLOB column', function() {
|
||||
it('127.1.1 works with 64K txt file', function(done) {
|
||||
inFileName = fileRoot + '/smallString.txt';
|
||||
var selectID = insertID + 100;
|
||||
var fileSize = 64 * 1024;
|
||||
var specialStr = '127.1.1';
|
||||
|
||||
bindSmallFile(inFileName, fileSize, selectID, insertID, specialStr, done);
|
||||
it('127.1.1 works with 64K txt file', async function() {
|
||||
const fileName = fileRoot + '/smallString.txt';
|
||||
const selectID = insertID + 100;
|
||||
const fileSize = 64 * 1024;
|
||||
const specialStr = '127.1.1';
|
||||
await bindSmallFile(fileName, fileSize, selectID, insertID, specialStr);
|
||||
});
|
||||
|
||||
it('127.1.2 works with 64K+1 txt file', function(done) {
|
||||
inFileName = fileRoot + '/smallString.txt';
|
||||
var selectID = insertID + 100;
|
||||
var fileSize = 64 * 1024 + 1;
|
||||
var specialStr = '127.1.2';
|
||||
|
||||
bindSmallFile(inFileName, fileSize, selectID, insertID, specialStr, done);
|
||||
it('127.1.2 works with 64K+1 txt file', async function() {
|
||||
const fileName = fileRoot + '/smallString.txt';
|
||||
const selectID = insertID + 100;
|
||||
const fileSize = 64 * 1024 + 1;
|
||||
const specialStr = '127.1.2';
|
||||
await bindSmallFile(fileName, fileSize, selectID, insertID, specialStr);
|
||||
});
|
||||
|
||||
it('127.1.3 works with 1MB+1 txt file', function(done) {
|
||||
inFileName = fileRoot + '/smallString.txt';
|
||||
var selectID = insertID + 100;
|
||||
var fileSize = 1 * 1024 * 1024 + 1;
|
||||
var specialStr = '127.1.3';
|
||||
|
||||
bindSmallFile(inFileName, fileSize, selectID, insertID, specialStr, done);
|
||||
it('127.1.3 works with 1MB+1 txt file', async function() {
|
||||
const fileName = fileRoot + '/smallString.txt';
|
||||
const selectID = insertID + 100;
|
||||
const fileSize = 1 * 1024 * 1024 + 1;
|
||||
const specialStr = '127.1.3';
|
||||
await bindSmallFile(fileName, fileSize, selectID, insertID, specialStr);
|
||||
});
|
||||
|
||||
}); // 1.1
|
||||
|
||||
var bindSmallFile = function(inFileName, fileSize, selectID, insertID, specialStr, callback) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
file.createFileInKB(inFileName, fileSize, specialStr);
|
||||
cb();
|
||||
},
|
||||
function(cb) {
|
||||
insetTableWithBlob(selectID, inFileName, cb);
|
||||
},
|
||||
function(cb) {
|
||||
verifyBlob(selectID, insertID, fileSize, cb);
|
||||
},
|
||||
function(cb) {
|
||||
file.delete(inFileName);
|
||||
cb();
|
||||
}
|
||||
], callback);
|
||||
const bindSmallFile = async function(fileName, fileSize, selectID, insertID, specialStr) {
|
||||
const bigStr = random.getRandomString(fileSize, specialStr);
|
||||
await fs.promises.writeFile(fileName, bigStr);
|
||||
await insetTableWithBlob(selectID, fileName);
|
||||
await verifyBlob(selectID, insertID, fileSize);
|
||||
await fs.promises.unlink(fileName);
|
||||
};
|
||||
|
||||
var setupAllTable = function(callback) {
|
||||
connection.execute(
|
||||
proc_blob_prepare_tab,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
const setupAllTable = async function() {
|
||||
await connection.execute(proc_blob_prepare_tab);
|
||||
};
|
||||
|
||||
var dropAllTable = function(callback) {
|
||||
connection.execute(
|
||||
"DROP TABLE nodb_tab_lobs_pre PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
const dropAllTable = async function() {
|
||||
await connection.execute("DROP TABLE nodb_tab_lobs_pre PURGE");
|
||||
};
|
||||
|
||||
var insetTableWithBlob = function(id, inFileName, callback) {
|
||||
var sql = "INSERT INTO nodb_tab_lobs_pre (id, blob) VALUES (:i, EMPTY_BLOB()) RETURNING blob INTO :lobbv";
|
||||
var bindVar = { i: id, lobbv: { type: oracledb.BLOB, dir: oracledb.BIND_OUT } };
|
||||
const insetTableWithBlob = async function(id, fileName) {
|
||||
const sql = `INSERT INTO nodb_tab_lobs_pre (id, blob) VALUES (:i, EMPTY_BLOB())
|
||||
RETURNING blob INTO :lobbv`;
|
||||
const bindVar = { i: id, lobbv: { type: oracledb.BLOB, dir: oracledb.BIND_OUT } };
|
||||
|
||||
connection.execute(
|
||||
sql,
|
||||
bindVar,
|
||||
{ autoCommit: false }, // a transaction needs to span the INSERT and pipe()
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
(result.outBinds.lobbv.length).should.be.exactly(1);
|
||||
|
||||
var inStream = fs.createReadStream(inFileName);
|
||||
var lob = result.outBinds.lobbv[0];
|
||||
|
||||
lob.on('error', function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
|
||||
inStream.on('error', function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
|
||||
lob.on('finish', function() {
|
||||
connection.commit(function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
});
|
||||
|
||||
inStream.pipe(lob); // copies the text to the BLOB
|
||||
}
|
||||
);
|
||||
const result = await connection.execute(sql, bindVar, { autoCommit: false });
|
||||
assert.strictEqual(result.rowsAffected, 1);
|
||||
assert.strictEqual(result.outBinds.lobbv.length, 1);
|
||||
const inStream = fs.createReadStream(fileName);
|
||||
const lob = result.outBinds.lobbv[0];
|
||||
await new Promise((resolve, reject)=>{
|
||||
inStream.on('error', reject);
|
||||
lob.on('error', reject);
|
||||
lob.on('finish', resolve);
|
||||
inStream.pipe(lob);
|
||||
});
|
||||
await connection.commit();
|
||||
};
|
||||
|
||||
var verifyBlob = function(selectID, insertID, lenExpected, callback) {
|
||||
var lob = {};
|
||||
var selectSql = "select blob from nodb_tab_lobs_pre where id = " + selectID;
|
||||
var insetSql = "INSERT INTO nodb_tab_lobs_pre (id, blob) VALUES (:i, :c)";
|
||||
var proc_compare_blob = "CREATE OR REPLACE PROCEDURE nodb_blob_compare(result OUT NUMBER, len OUT NUMBER) \n" +
|
||||
const verifyBlob = async function(selectID, insertID, lenExpected) {
|
||||
const selectSql = "select blob from nodb_tab_lobs_pre where id = " + selectID;
|
||||
const insetSql = "INSERT INTO nodb_tab_lobs_pre (id, blob) VALUES (:i, :c)";
|
||||
const proc_compare_blob = "CREATE OR REPLACE PROCEDURE nodb_blob_compare(result OUT NUMBER, len OUT NUMBER) \n" +
|
||||
"IS \n" +
|
||||
" blob1 BLOB; \n" +
|
||||
" blob2 BLOB; \n" +
|
||||
|
@ -215,56 +149,24 @@ describe('127.blobStream.js', function() {
|
|||
" result := DBMS_LOB.COMPARE(blob1, blob2); \n" + // Zero if the comparison succeeds, nonzero if not.
|
||||
" len := length(blob1); \n" +
|
||||
"END nodb_blob_compare;";
|
||||
var sqlRunComparePorc = "begin nodb_blob_compare(:r, :l); end;";
|
||||
var sqlDropComparePorc = "DROP PROCEDURE nodb_blob_compare";
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
selectSql,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
lob = result.rows[0][0];
|
||||
should.exist(lob);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
var bindVar = { i: insertID, c: { val: lob, type: oracledb.BLOB, dir: oracledb.BIND_IN } };
|
||||
connection.execute(
|
||||
insetSql,
|
||||
bindVar,
|
||||
{ autoCommit: true },
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
lob.close(cb);
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
sql.executeSql(connection, proc_compare_blob, {}, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
var bindVar = {
|
||||
r: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT },
|
||||
l: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
connection.execute(
|
||||
sqlRunComparePorc,
|
||||
bindVar,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
result.outBinds.r.should.eql(0);
|
||||
should.strictEqual(result.outBinds.l, lenExpected);
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function(cb) {
|
||||
sql.executeSql(connection, sqlDropComparePorc, {}, {}, cb);
|
||||
}
|
||||
], callback);
|
||||
const sqlRunCompareProc = "begin nodb_blob_compare(:r, :l); end;";
|
||||
const sqlDropCompareProc = "DROP PROCEDURE nodb_blob_compare";
|
||||
|
||||
let result = await connection.execute(selectSql);
|
||||
const lob = result.rows[0][0];
|
||||
assert(lob);
|
||||
let bindVar = { i: insertID, c: { val: lob, type: oracledb.BLOB, dir: oracledb.BIND_IN } };
|
||||
await connection.execute(insetSql, bindVar, { autoCommit: true });
|
||||
await lob.close();
|
||||
await connection.execute(proc_compare_blob);
|
||||
bindVar = {
|
||||
r: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT },
|
||||
l: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
result = await connection.execute(sqlRunCompareProc, bindVar);
|
||||
assert.strictEqual(result.outBinds.r, 0);
|
||||
assert.strictEqual(result.outBinds.l, lenExpected);
|
||||
await connection.execute(sqlDropCompareProc);
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2018, 2022, Oracle and/or its affiliates. */
|
||||
/* Copyright (c) 2018, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
|
@ -51,7 +51,6 @@ describe('222. callTimeout.js', function() {
|
|||
isRunnable = isQA && prep;
|
||||
if (!isRunnable) {
|
||||
this.skip();
|
||||
return;
|
||||
} else {
|
||||
conn = await oracledb.getConnection(dbConfig);
|
||||
}
|
||||
|
|
|
@ -29,18 +29,17 @@
|
|||
* Testing CLOB DML returning multiple rows as stream.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sql.js');
|
||||
const assert = require('assert');
|
||||
|
||||
describe('135. clobDMLReturningMultipleRowsAsStream.js', function() {
|
||||
|
||||
let connection = null;
|
||||
let tableName = "nodb_dml_clob_135";
|
||||
const tableName = "nodb_dml_clob_135";
|
||||
|
||||
const clob_table_create = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
|
@ -67,83 +66,50 @@ describe('135. clobDMLReturningMultipleRowsAsStream.js', function() {
|
|||
"END; ";
|
||||
const clob_table_drop = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
before(function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
before(async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
after(async function() {
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
describe('135.1 CLOB DML returning multiple rows as stream', function() {
|
||||
before(function(done) {
|
||||
sql.executeSql(connection, clob_table_create, {}, {}, done);
|
||||
before(async function() {
|
||||
await connection.execute(clob_table_create);
|
||||
});
|
||||
after(function(done) {
|
||||
sql.executeSql(connection, clob_table_drop, {}, {}, done);
|
||||
after(async function() {
|
||||
await connection.execute(clob_table_drop);
|
||||
});
|
||||
|
||||
it('135.1.1 CLOB DML returning multiple rows as stream', function(done) {
|
||||
updateReturning_stream(done);
|
||||
it('135.1.1 CLOB DML returning multiple rows as stream', async function() {
|
||||
await updateReturning_stream();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
var updateReturning_stream = function(callback) {
|
||||
var sql_update = "UPDATE " + tableName + " set num = num+10 RETURNING num, clob into :num, :lobou";
|
||||
connection.execute(
|
||||
const updateReturning_stream = async function() {
|
||||
const sql_update = "UPDATE " + tableName + " set num = num+10 RETURNING num, clob into :num, :lobou";
|
||||
const result = await connection.execute(
|
||||
sql_update,
|
||||
{
|
||||
num: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT },
|
||||
lobou: { type: oracledb.CLOB, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var numLobs = result.outBinds.lobou.length;
|
||||
should.strictEqual(numLobs, 10);
|
||||
async.times(
|
||||
numLobs,
|
||||
function(n, next) {
|
||||
verifyLob(n, result, function(err, result) {
|
||||
next(err, result);
|
||||
});
|
||||
},
|
||||
callback
|
||||
);
|
||||
}
|
||||
);
|
||||
const numLobs = result.outBinds.lobou.length;
|
||||
assert.strictEqual(numLobs, 10);
|
||||
for (let n = 0; n < numLobs; n++) {
|
||||
await verifyLob(n, result);
|
||||
}
|
||||
};
|
||||
|
||||
var verifyLob = function(n, result, cb) {
|
||||
var lob = result.outBinds.lobou[n];
|
||||
var id = result.outBinds.num[n];
|
||||
should.exist(lob);
|
||||
lob.setEncoding('utf8');
|
||||
var clobData = '';
|
||||
|
||||
lob.on('data', function(chunk) {
|
||||
clobData += chunk;
|
||||
});
|
||||
|
||||
lob.on('error', function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
|
||||
lob.on('end', function(err) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(clobData, (id - 10).toString());
|
||||
});
|
||||
lob.on('close', function(err) {
|
||||
should.not.exist(err);
|
||||
cb(err, result);
|
||||
});
|
||||
const verifyLob = async function(n, result) {
|
||||
const lob = result.outBinds.lobou[n];
|
||||
const id = result.outBinds.num[n];
|
||||
const clobData = await lob.getData();
|
||||
assert.strictEqual(clobData, (id - 10).toString());
|
||||
await lob.close();
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -29,17 +29,17 @@
|
|||
* Testing CLOB DML returning multiple rows as String.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sqlClone.js');
|
||||
|
||||
describe('136. clobDMLReturningMultipleRowsAsString.js', function() {
|
||||
|
||||
let connection = null;
|
||||
let tableName = "nodb_dml_clob_136";
|
||||
const tableName = "nodb_dml_clob_136";
|
||||
|
||||
const clob_table_create = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
|
@ -77,11 +77,11 @@ describe('136. clobDMLReturningMultipleRowsAsString.js', function() {
|
|||
describe('136.1 CLOB DML returning multiple rows as String', function() {
|
||||
|
||||
before(async function() {
|
||||
await sql.executeSql(connection, clob_table_create, {}, {});
|
||||
await connection.execute(clob_table_create);
|
||||
});
|
||||
|
||||
after(async function() {
|
||||
await sql.executeSql(connection, clob_table_drop, {}, {});
|
||||
await connection.execute(clob_table_drop);
|
||||
});
|
||||
|
||||
it('136.1.1 CLOB DML returning multiple rows as String', async function() {
|
||||
|
@ -98,7 +98,6 @@ describe('136. clobDMLReturningMultipleRowsAsString.js', function() {
|
|||
num: { type: oracledb.NUMBER, dir: oracledb.BIND_OUT },
|
||||
lobou: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
});
|
||||
assert(result);
|
||||
const numLobs = result.outBinds.lobou.length;
|
||||
assert.strictEqual(numLobs, 10);
|
||||
for (let index = 0; index < result.outBinds.lobou.length; index++) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2016, 2022, Oracle and/or its affiliates. */
|
||||
/* Copyright (c) 2016, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
|
@ -34,9 +34,7 @@
|
|||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const fsPromises = require('fs/promises');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const file = require('./file.js');
|
||||
const random = require('./random.js');
|
||||
|
||||
describe('75. clobPlsqlBindAsString_bindout.js', function() {
|
||||
|
@ -90,7 +88,6 @@ describe('75. clobPlsqlBindAsString_bindout.js', function() {
|
|||
await connection.execute("DROP TABLE nodb_tab_clob_in PURGE");
|
||||
await connection.execute("DROP TABLE nodb_tab_lobs_in PURGE");
|
||||
await connection.close();
|
||||
file.delete(inFileStreamed);
|
||||
});
|
||||
|
||||
const insertClobWithString = async function(id, insertStr) {
|
||||
|
@ -110,8 +107,6 @@ describe('75. clobPlsqlBindAsString_bindout.js', function() {
|
|||
assert.strictEqual(result.rowsAffected, 1);
|
||||
};
|
||||
|
||||
const inFileStreamed = './test/clobTmpFile.txt';
|
||||
|
||||
const preparedInFileName = './test/clobexample.txt';
|
||||
|
||||
const prepareTableWithClob = async function(sql, id) {
|
||||
|
@ -134,16 +129,8 @@ describe('75. clobPlsqlBindAsString_bindout.js', function() {
|
|||
const verifyClobValueWithFileData = async function(selectSql) {
|
||||
const result = await connection.execute(selectSql);
|
||||
const lob = result.rows[0][0];
|
||||
lob.setEncoding('utf8');
|
||||
let clobData = '';
|
||||
await new Promise((resolve, reject) => {
|
||||
lob.on("error", reject);
|
||||
lob.on('data', function(chunk) {
|
||||
clobData += chunk;
|
||||
});
|
||||
lob.on("end", resolve);
|
||||
});
|
||||
const data = await fsPromises.readFile(preparedInFileName,
|
||||
const clobData = await lob.getData();
|
||||
const data = await fs.promises.readFile(preparedInFileName,
|
||||
{encoding: "utf8"});
|
||||
assert.strictEqual(clobData, data);
|
||||
};
|
||||
|
@ -159,7 +146,7 @@ describe('75. clobPlsqlBindAsString_bindout.js', function() {
|
|||
|
||||
const verifyBindOutResult = async function(sqlRun, bindVar, originalStr, specialStr) {
|
||||
const result = await connection.execute(sqlRun, bindVar);
|
||||
if (originalStr == "EMPTY_LOB" || originalStr == undefined || originalStr == null || originalStr == "") {
|
||||
if (originalStr === "EMPTY_LOB" || originalStr == undefined || originalStr == null || originalStr === "") {
|
||||
assert.strictEqual(result.outBinds.c, null);
|
||||
} else {
|
||||
const resultVal = result.outBinds.c;
|
||||
|
@ -372,7 +359,6 @@ describe('75. clobPlsqlBindAsString_bindout.js', function() {
|
|||
};
|
||||
await insertClobWithString(sequence, clobStr);
|
||||
await verifyBindOutResult(sqlRun, bindVar, clobStr, specialStr);
|
||||
file.delete(inFileStreamed);
|
||||
}); // 75.1.17
|
||||
|
||||
it('75.1.18 works with String length (1MB + 1)', async function() {
|
||||
|
@ -386,7 +372,6 @@ describe('75. clobPlsqlBindAsString_bindout.js', function() {
|
|||
};
|
||||
await insertClobWithString(sequence, clobStr);
|
||||
await verifyBindOutResult(sqlRun, bindVar, clobStr, specialStr);
|
||||
file.delete(inFileStreamed);
|
||||
}); // 75.1.18
|
||||
|
||||
it('75.1.19 works with bind value and type mismatch', async function() {
|
||||
|
@ -818,7 +803,8 @@ describe('75. clobPlsqlBindAsString_bindout.js', function() {
|
|||
const result = await connection.execute(sqlRun_7519, bindVar);
|
||||
const resultVal = result.outBinds.co;
|
||||
// PLSQL substr function: the position starts from zero(0).
|
||||
// The substring method extracts the characters in a string between "start" and "end", not including "end" itself.
|
||||
// The substring method extracts the characters in a string between
|
||||
// "start" and "end", not including "end" itself.
|
||||
clobStr = clobStr.substring(0, 3);
|
||||
assert.strictEqual(resultVal.length, 3);
|
||||
assert.strictEqual(resultVal, clobStr);
|
||||
|
@ -902,15 +888,8 @@ describe('75. clobPlsqlBindAsString_bindout.js', function() {
|
|||
compareResultStrAndOriginal(resultVal, clobStr_1, specialStr);
|
||||
const lob = result.outBinds.c2;
|
||||
lob.setEncoding("utf8");
|
||||
let clobData = '';
|
||||
await new Promise((resolve, reject) => {
|
||||
lob.on("error", reject);
|
||||
lob.on("end", resolve);
|
||||
lob.on('data', function(chunk) {
|
||||
clobData += chunk;
|
||||
});
|
||||
});
|
||||
const data = await fsPromises.readFile(preparedInFileName,
|
||||
const clobData = await lob.getData();
|
||||
const data = await fs.promises.readFile(preparedInFileName,
|
||||
{encoding: "utf8"});
|
||||
assert.strictEqual(clobData, data);
|
||||
}); // 75.3.2
|
||||
|
|
|
@ -79,7 +79,7 @@ describe('32. dataTypeDate.js', function() {
|
|||
});
|
||||
|
||||
it('32.1.4 columns fetched from REF CURSORS can be mapped by fetchInfo settings', async function() {
|
||||
await await assist.verifyRefCursorWithFetchInfo(connection, tableName, dates);
|
||||
await assist.verifyRefCursorWithFetchInfo(connection, tableName, dates);
|
||||
});
|
||||
|
||||
it('32.1.5 columns fetched from REF CURSORS can be mapped by oracledb.fetchAsString', async function() {
|
||||
|
|
|
@ -30,11 +30,12 @@
|
|||
* To fetch BLOB columns as buffer by setting oracledb.fetchAsBuffer.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const file = require('./file.js');
|
||||
const fs = require('fs');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
@ -43,10 +44,10 @@ describe('87. fetchBlobAsBuffer1.js', function() {
|
|||
|
||||
let connection = null;
|
||||
let insertID = 1; // assume id for insert into db starts from 1
|
||||
let inFileName = './test/blobTmpFile.txt';
|
||||
let defaultStmtCache = oracledb.stmtCacheSize;
|
||||
const inFileName = './test/blobTmpFile.txt';
|
||||
const defaultStmtCache = oracledb.stmtCacheSize;
|
||||
|
||||
let proc_create_table1 = "BEGIN \n" +
|
||||
const proc_create_table1 = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n" +
|
||||
|
@ -63,25 +64,23 @@ describe('87. fetchBlobAsBuffer1.js', function() {
|
|||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
let drop_table1 = "DROP TABLE nodb_blob1 PURGE";
|
||||
const drop_table1 = "DROP TABLE nodb_blob1 PURGE";
|
||||
|
||||
before('get one connection', async function() {
|
||||
|
||||
oracledb.stmtCacheSize = 0;
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
await file.create(inFileName);
|
||||
|
||||
await fs.promises.writeFile(inFileName, '');
|
||||
}); // before
|
||||
|
||||
after('release connection', async function() {
|
||||
oracledb.stmtCacheSize = defaultStmtCache;
|
||||
await connection.close();
|
||||
await file.delete(inFileName);
|
||||
await fs.promises.unlink(inFileName);
|
||||
}); // after
|
||||
|
||||
// Generic function to insert a single row given ID, and data
|
||||
let insertIntoBlobTable1 = async function(id, content) {
|
||||
let result = null;
|
||||
const insertIntoBlobTable1 = async function(id, content) {
|
||||
let result;
|
||||
if (content == "EMPTY_BLOB") {
|
||||
result = await connection.execute(
|
||||
"INSERT INTO nodb_blob1 VALUES (:ID, EMPTY_BLOB())",
|
||||
|
@ -98,23 +97,22 @@ describe('87. fetchBlobAsBuffer1.js', function() {
|
|||
}
|
||||
};
|
||||
|
||||
let updateBlobTable1 = async function(id, content) {
|
||||
let result = null;
|
||||
result = await connection.execute(
|
||||
const updateBlobTable1 = async function(id, content) {
|
||||
const result = await connection.execute(
|
||||
"UPDATE nodb_blob1 set B = :B where ID = :ID",
|
||||
{ ID: id, B: content });
|
||||
assert.strictEqual(result.rowsAffected, 1);
|
||||
};
|
||||
|
||||
// compare fetch result
|
||||
let compareClientFetchResult = async function(resultVal, specialStr, content, contentLength) {
|
||||
const compareClientFetchResult = async function(resultVal, specialStr, content, contentLength) {
|
||||
await compareBuffers(resultVal, specialStr, content, contentLength);
|
||||
};
|
||||
|
||||
// compare two buffers
|
||||
let compareBuffers = function(resultVal, specialStr, content, contentLength) {
|
||||
const compareBuffers = function(resultVal, specialStr, content, contentLength) {
|
||||
assert.equal(resultVal.length, contentLength);
|
||||
let compareBuffer = assist.compare2Buffers(resultVal, content);
|
||||
const compareBuffer = assist.compare2Buffers(resultVal, content);
|
||||
assert.strictEqual(compareBuffer, true);
|
||||
};
|
||||
|
||||
|
@ -128,13 +126,12 @@ describe('87. fetchBlobAsBuffer1.js', function() {
|
|||
await connection.execute(drop_table1);
|
||||
}); // after
|
||||
|
||||
let insertAndFetch = async function(id, specialStr, insertContent, insertContentLength) {
|
||||
let result = null;
|
||||
const insertAndFetch = async function(id, specialStr, insertContent, insertContentLength) {
|
||||
await insertIntoBlobTable1(id, insertContent);
|
||||
result = await connection.execute(
|
||||
const result = await connection.execute(
|
||||
"SELECT ID, B from nodb_blob1 WHERE ID = :id",
|
||||
{ id : id });
|
||||
let resultVal = result.rows[0][1];
|
||||
const resultVal = result.rows[0][1];
|
||||
if (specialStr === null) {
|
||||
assert.equal(resultVal, null);
|
||||
} else {
|
||||
|
@ -144,109 +141,96 @@ describe('87. fetchBlobAsBuffer1.js', function() {
|
|||
|
||||
beforeEach('set oracledb.fetchAsBuffer', function() {
|
||||
oracledb.fetchAsBuffer = [ oracledb.BLOB ];
|
||||
|
||||
}); // beforeEach
|
||||
|
||||
afterEach('clear the by-type specification', function() {
|
||||
oracledb.fetchAsBuffer = [];
|
||||
|
||||
}); // afterEach
|
||||
|
||||
it('87.1.1 works with NULL value', async function() {
|
||||
let id = insertID++;
|
||||
let content = null;
|
||||
|
||||
const id = insertID++;
|
||||
const content = null;
|
||||
await insertAndFetch(id, null, content, null);
|
||||
}); // 87.1.1
|
||||
|
||||
it('87.1.2 works with empty Buffer', async function() {
|
||||
let id = insertID++;
|
||||
let content = Buffer.from("", "utf-8");
|
||||
|
||||
const id = insertID++;
|
||||
const content = Buffer.from("", "utf-8");
|
||||
await insertAndFetch(id, null, content, null);
|
||||
}); // 87.1.2
|
||||
|
||||
it('87.1.3 works with small value', async function() {
|
||||
let id = insertID++;
|
||||
let specialStr = '87.1.3';
|
||||
let contentLength = 20;
|
||||
let strBuf = random.getRandomString(contentLength, specialStr);
|
||||
let content = Buffer.from(strBuf, "utf-8");
|
||||
|
||||
const id = insertID++;
|
||||
const specialStr = '87.1.3';
|
||||
const contentLength = 20;
|
||||
const strBuf = random.getRandomString(contentLength, specialStr);
|
||||
const content = Buffer.from(strBuf, "utf-8");
|
||||
await insertAndFetch(id, specialStr, content, contentLength);
|
||||
}); // 87.1.3
|
||||
|
||||
it('87.1.4 works with (64K - 1) value', async function() {
|
||||
let id = insertID++;
|
||||
let specialStr = '87.1.4';
|
||||
let contentLength = 65535;
|
||||
let strBuf = random.getRandomString(contentLength, specialStr);
|
||||
let content = Buffer.from(strBuf, "utf-8");
|
||||
|
||||
const id = insertID++;
|
||||
const specialStr = '87.1.4';
|
||||
const contentLength = 65535;
|
||||
const strBuf = random.getRandomString(contentLength, specialStr);
|
||||
const content = Buffer.from(strBuf, "utf-8");
|
||||
await insertAndFetch(id, specialStr, content, contentLength);
|
||||
}); // 87.1.4
|
||||
|
||||
it('87.1.5 works with (64K + 1) value', async function() {
|
||||
let id = insertID++;
|
||||
let specialStr = '87.1.5';
|
||||
let contentLength = 65537;
|
||||
let strBuf = random.getRandomString(contentLength, specialStr);
|
||||
let content = Buffer.from(strBuf, "utf-8");
|
||||
|
||||
const id = insertID++;
|
||||
const specialStr = '87.1.5';
|
||||
const contentLength = 65537;
|
||||
const strBuf = random.getRandomString(contentLength, specialStr);
|
||||
const content = Buffer.from(strBuf, "utf-8");
|
||||
await insertAndFetch(id, specialStr, content, contentLength);
|
||||
}); // 87.1.5
|
||||
|
||||
it('87.1.6 works with (1MB + 1) data', async function() {
|
||||
let id = insertID++;
|
||||
let specialStr = '87.1.6';
|
||||
let contentLength = 1048577; // 1MB + 1
|
||||
let strBuf = random.getRandomString(contentLength, specialStr);
|
||||
let content = Buffer.from(strBuf, "utf-8");
|
||||
|
||||
const id = insertID++;
|
||||
const specialStr = '87.1.6';
|
||||
const contentLength = 1048577; // 1MB + 1
|
||||
const strBuf = random.getRandomString(contentLength, specialStr);
|
||||
const content = Buffer.from(strBuf, "utf-8");
|
||||
await insertAndFetch(id, specialStr, content, contentLength);
|
||||
}); // 87.1.6
|
||||
|
||||
it('87.1.7 works with dbms_lob.substr()', async function() {
|
||||
let id = insertID++;
|
||||
let specialStr = '87.1.7';
|
||||
let contentLength = 200;
|
||||
let specialStrLength = specialStr.length;
|
||||
let strBuf = random.getRandomString(contentLength, specialStr);
|
||||
let content = Buffer.from(strBuf, "utf-8");
|
||||
let result = null;
|
||||
const id = insertID++;
|
||||
const specialStr = '87.1.7';
|
||||
const contentLength = 200;
|
||||
const specialStrLength = specialStr.length;
|
||||
const strBuf = random.getRandomString(contentLength, specialStr);
|
||||
const content = Buffer.from(strBuf, "utf-8");
|
||||
await insertIntoBlobTable1(id, content);
|
||||
result = await connection.execute(
|
||||
const result = await connection.execute(
|
||||
"SELECT dbms_lob.substr(B, " + specialStrLength + ", 1) from nodb_blob1 WHERE ID = :id",
|
||||
{ id : id });
|
||||
let resultVal = result.rows[0][0];
|
||||
let buffer2Compare = Buffer.from(specialStr, "utf-8");
|
||||
const resultVal = result.rows[0][0];
|
||||
const buffer2Compare = Buffer.from(specialStr, "utf-8");
|
||||
await compareClientFetchResult(resultVal, specialStr, buffer2Compare, specialStrLength);
|
||||
}); // 87.1.7
|
||||
|
||||
it('87.1.8 works with EMPTY_BLOB()', async function() {
|
||||
let id = insertID++;
|
||||
let content = "EMPTY_BLOB";
|
||||
|
||||
const id = insertID++;
|
||||
const content = "EMPTY_BLOB";
|
||||
await insertAndFetch(id, null, content, null);
|
||||
}); // 87.1.8
|
||||
|
||||
it('87.1.9 fetch multiple BLOB rows as Buffer', async function() {
|
||||
let id_1 = insertID++;
|
||||
let specialStr_1 = '87.1.9_1';
|
||||
let contentLength_1 = 200;
|
||||
let strBuf_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
let content_1 = Buffer.from(strBuf_1, "utf-8");
|
||||
let id_2 = insertID++;
|
||||
let specialStr_2 = '87.1.9_2';
|
||||
let contentLength_2 = 100;
|
||||
let strBuf_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
let content_2 = Buffer.from(strBuf_2, "utf-8");
|
||||
let result = null;
|
||||
const id_1 = insertID++;
|
||||
const specialStr_1 = '87.1.9_1';
|
||||
const contentLength_1 = 200;
|
||||
const strBuf_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
const content_1 = Buffer.from(strBuf_1, "utf-8");
|
||||
const id_2 = insertID++;
|
||||
const specialStr_2 = '87.1.9_2';
|
||||
const contentLength_2 = 100;
|
||||
const strBuf_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
const content_2 = Buffer.from(strBuf_2, "utf-8");
|
||||
await insertIntoBlobTable1(id_1, content_1);
|
||||
|
||||
await insertIntoBlobTable1(id_2, content_2);
|
||||
|
||||
result = await connection.execute(
|
||||
const result = await connection.execute(
|
||||
"SELECT ID, B from nodb_blob1 WHERE ID = " + id_1 + " or id = " + id_2);
|
||||
|
||||
let resultVal = result.rows[0][1];
|
||||
|
@ -256,15 +240,13 @@ describe('87. fetchBlobAsBuffer1.js', function() {
|
|||
}); // 87.1.9
|
||||
|
||||
it('87.1.10 fetch the same BLOB column multiple times', async function() {
|
||||
let id = insertID++;
|
||||
let specialStr = '87.1.10';
|
||||
let contentLength = 200;
|
||||
let strBuf = random.getRandomString(contentLength, specialStr);
|
||||
let content = Buffer.from(strBuf, "utf-8");
|
||||
let result = null;
|
||||
|
||||
const id = insertID++;
|
||||
const specialStr = '87.1.10';
|
||||
const contentLength = 200;
|
||||
const strBuf = random.getRandomString(contentLength, specialStr);
|
||||
const content = Buffer.from(strBuf, "utf-8");
|
||||
await insertIntoBlobTable1(id, content);
|
||||
result = await connection.execute(
|
||||
const result = await connection.execute(
|
||||
"SELECT ID, B AS B1, B AS B2 from nodb_blob1 WHERE ID = " + id);
|
||||
let resultVal = result.rows[0][1];
|
||||
await compareClientFetchResult(resultVal, specialStr, content, contentLength);
|
||||
|
@ -274,149 +256,113 @@ describe('87. fetchBlobAsBuffer1.js', function() {
|
|||
}); // 87.1.10
|
||||
|
||||
it('87.1.11 works with update statement', async function() {
|
||||
let id = insertID++;
|
||||
let specialStr_1 = '87.1.11_1';
|
||||
let contentLength_1 = 208;
|
||||
let strBuf_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
let content_1 = Buffer.from(strBuf_1, "utf-8");
|
||||
let specialStr_2 = '87.1.11_2';
|
||||
let contentLength_2 = 200;
|
||||
let strBuf_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
let content_2 = Buffer.from(strBuf_2, "utf-8");
|
||||
let result = null;
|
||||
|
||||
const id = insertID++;
|
||||
const specialStr_1 = '87.1.11_1';
|
||||
const contentLength_1 = 208;
|
||||
const strBuf_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
const content_1 = Buffer.from(strBuf_1, "utf-8");
|
||||
const specialStr_2 = '87.1.11_2';
|
||||
const contentLength_2 = 200;
|
||||
const strBuf_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
const content_2 = Buffer.from(strBuf_2, "utf-8");
|
||||
await insertAndFetch(id, specialStr_1, content_1, contentLength_1);
|
||||
|
||||
updateBlobTable1(id, content_2);
|
||||
|
||||
result = await connection.execute("SELECT ID, B from nodb_blob1 WHERE ID = " + id);
|
||||
let resultVal = result.rows[0][1];
|
||||
await updateBlobTable1(id, content_2);
|
||||
const result = await connection.execute("SELECT ID, B from nodb_blob1 WHERE ID = " + id);
|
||||
const resultVal = result.rows[0][1];
|
||||
await compareClientFetchResult(resultVal, specialStr_2, content_2, contentLength_2);
|
||||
}); // 87.1.11
|
||||
|
||||
it('87.1.12 works with REF CURSOR', async function() {
|
||||
let id = insertID++;
|
||||
let specialStr = '87.1.12';
|
||||
let contentLength = 100;
|
||||
let strBuf = random.getRandomString(contentLength, specialStr);
|
||||
let content = Buffer.from(strBuf, "utf-8");
|
||||
|
||||
const id = insertID++;
|
||||
const specialStr = '87.1.12';
|
||||
const contentLength = 100;
|
||||
const strBuf = random.getRandomString(contentLength, specialStr);
|
||||
const content = Buffer.from(strBuf, "utf-8");
|
||||
await insertIntoBlobTable1(id, content);
|
||||
|
||||
let ref_proc = "CREATE OR REPLACE PROCEDURE nodb_ref(blob_cursor OUT SYS_REFCURSOR)\n" +
|
||||
const ref_proc = "CREATE OR REPLACE PROCEDURE nodb_ref(blob_cursor OUT SYS_REFCURSOR)\n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" OPEN blob_cursor FOR \n" +
|
||||
" SELECT B from nodb_blob1 WHERE ID = " + id + "; \n" +
|
||||
"END;";
|
||||
let result = null;
|
||||
await connection.execute(ref_proc);
|
||||
let sql = "BEGIN nodb_ref(:b); END;";
|
||||
let bindVar = {
|
||||
const sql = "BEGIN nodb_ref(:b); END;";
|
||||
const bindVar = {
|
||||
b: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
result = await connection.execute(
|
||||
sql,
|
||||
bindVar);
|
||||
|
||||
let rows = await result.outBinds.b.getRows(3);
|
||||
|
||||
let resultVal = rows[0][0];
|
||||
const result = await connection.execute(sql, bindVar);
|
||||
const rows = await result.outBinds.b.getRows(3);
|
||||
const resultVal = rows[0][0];
|
||||
await compareClientFetchResult(resultVal, specialStr, content, contentLength);
|
||||
await result.outBinds.b.close();
|
||||
let ref_proc_drop = "DROP PROCEDURE nodb_ref";
|
||||
const ref_proc_drop = "DROP PROCEDURE nodb_ref";
|
||||
await connection.execute(ref_proc_drop);
|
||||
}); // 87.1.12
|
||||
|
||||
it('87.1.13 fetch BLOB with stream', async function() {
|
||||
let id = insertID++;
|
||||
let specialStr = '87.1.13';
|
||||
let contentLength = 200;
|
||||
let strBuf = random.getRandomString(contentLength, specialStr);
|
||||
let content = Buffer.from(strBuf, "utf-8");
|
||||
let result = null;
|
||||
|
||||
const id = insertID++;
|
||||
const specialStr = '87.1.13';
|
||||
const contentLength = 200;
|
||||
const strBuf = random.getRandomString(contentLength, specialStr);
|
||||
const content = Buffer.from(strBuf, "utf-8");
|
||||
await insertIntoBlobTable1(id, content);
|
||||
|
||||
oracledb.fetchAsBuffer = [];
|
||||
result = await connection.execute(
|
||||
const result = await connection.execute(
|
||||
"SELECT B from nodb_blob1 WHERE ID = " + id);
|
||||
|
||||
let lob = result.rows[0][0];
|
||||
assert(lob);
|
||||
const lob = result.rows[0][0];
|
||||
let blobData = Buffer.alloc(0);
|
||||
await new Promise((resolve, reject) => {
|
||||
let blobData = Buffer.alloc(0);
|
||||
let totalLength = 0;
|
||||
|
||||
lob.on('data', function(chunk) {
|
||||
totalLength = totalLength + chunk.length;
|
||||
blobData = Buffer.concat([blobData, chunk], totalLength);
|
||||
});
|
||||
|
||||
lob.on('error', function(err) {
|
||||
assert.ifError(err, "lob.on 'error' event.");
|
||||
reject();
|
||||
});
|
||||
|
||||
lob.on('end', async function() {
|
||||
await compareClientFetchResult(blobData, specialStr, content, contentLength);
|
||||
lob.destroy();
|
||||
});
|
||||
|
||||
lob.on('close', function() {
|
||||
resolve();
|
||||
blobData = Buffer.concat([blobData, chunk]);
|
||||
});
|
||||
lob.on('error', reject);
|
||||
lob.on('end', lob.destroy);
|
||||
lob.on('close', resolve);
|
||||
});
|
||||
await compareClientFetchResult(blobData, specialStr, content, contentLength);
|
||||
}); // 87.1.13
|
||||
|
||||
it('87.1.14 works with setting oracledb.maxRows < actual number of rows in the table', async function() {
|
||||
let id_1 = insertID++;
|
||||
let specialStr_1 = '87.1.14_1';
|
||||
let contentLength_1 = 200;
|
||||
let strBuf_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
let content_1 = Buffer.from(strBuf_1, "utf-8");
|
||||
let id_2 = insertID++;
|
||||
let specialStr_2 = '87.1.14_2';
|
||||
let contentLength_2 = 100;
|
||||
let strBuf_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
let content_2 = Buffer.from(strBuf_2, "utf-8");
|
||||
let maxRowsBak = oracledb.maxRows;
|
||||
const id_1 = insertID++;
|
||||
const specialStr_1 = '87.1.14_1';
|
||||
const contentLength_1 = 200;
|
||||
const strBuf_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
const content_1 = Buffer.from(strBuf_1, "utf-8");
|
||||
const id_2 = insertID++;
|
||||
const specialStr_2 = '87.1.14_2';
|
||||
const contentLength_2 = 100;
|
||||
const strBuf_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
const content_2 = Buffer.from(strBuf_2, "utf-8");
|
||||
const maxRowsBak = oracledb.maxRows;
|
||||
oracledb.maxRows = 1;
|
||||
|
||||
let result = null;
|
||||
await insertIntoBlobTable1(id_1, content_1);
|
||||
|
||||
await insertIntoBlobTable1(id_2, content_2);
|
||||
|
||||
result = await connection.execute(
|
||||
const result = await connection.execute(
|
||||
"SELECT ID, B from nodb_blob1 WHERE id = " + id_1 + " or id = " + id_2);
|
||||
assert.strictEqual(result.rows.length, 1);
|
||||
let resultVal = result.rows[0][1];
|
||||
const resultVal = result.rows[0][1];
|
||||
await compareClientFetchResult(resultVal, specialStr_1, content_1, contentLength_1);
|
||||
oracledb.maxRows = maxRowsBak;
|
||||
}); // 87.1.14
|
||||
|
||||
it('87.1.15 works with setting oracledb.maxRows > actual number of rows in the table', async function() {
|
||||
let id_1 = insertID++;
|
||||
let specialStr_1 = '87.1.15_1';
|
||||
let contentLength_1 = 200;
|
||||
let strBuf_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
let content_1 = Buffer.from(strBuf_1, "utf-8");
|
||||
let id_2 = insertID++;
|
||||
let specialStr_2 = '87.1.15_2';
|
||||
let contentLength_2 = 100;
|
||||
let strBuf_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
let content_2 = Buffer.from(strBuf_2, "utf-8");
|
||||
let maxRowsBak = oracledb.maxRows;
|
||||
const id_1 = insertID++;
|
||||
const specialStr_1 = '87.1.15_1';
|
||||
const contentLength_1 = 200;
|
||||
const strBuf_1 = random.getRandomString(contentLength_1, specialStr_1);
|
||||
const content_1 = Buffer.from(strBuf_1, "utf-8");
|
||||
const id_2 = insertID++;
|
||||
const specialStr_2 = '87.1.15_2';
|
||||
const contentLength_2 = 100;
|
||||
const strBuf_2 = random.getRandomString(contentLength_2, specialStr_2);
|
||||
const content_2 = Buffer.from(strBuf_2, "utf-8");
|
||||
const maxRowsBak = oracledb.maxRows;
|
||||
oracledb.maxRows = 10;
|
||||
let result = null;
|
||||
await insertIntoBlobTable1(id_1, content_1);
|
||||
|
||||
await insertIntoBlobTable1(id_2, content_2);
|
||||
|
||||
result = await connection.execute(
|
||||
const result = await connection.execute(
|
||||
"SELECT ID, B from nodb_blob1 WHERE id = " + id_1 + " or id = " + id_2);
|
||||
|
||||
assert.strictEqual(result.rows.length, 2);
|
||||
let resultVal = result.rows[0][1];
|
||||
await compareClientFetchResult(resultVal, specialStr_1, content_1, contentLength_1);
|
||||
|
@ -426,83 +372,46 @@ describe('87. fetchBlobAsBuffer1.js', function() {
|
|||
}); // 87.1.15
|
||||
|
||||
it('87.1.16 override oracledb.fetchAsBuffer with fetchInfo set to oracledb.DEFAULT', async function() {
|
||||
let id = insertID++;
|
||||
let specialStr = '87.1.16';
|
||||
let contentLength = 20;
|
||||
let strBuf = random.getRandomString(contentLength, specialStr);
|
||||
let content = Buffer.from(strBuf, "utf-8");
|
||||
let result = null;
|
||||
|
||||
const id = insertID++;
|
||||
const specialStr = '87.1.16';
|
||||
const contentLength = 20;
|
||||
const strBuf = random.getRandomString(contentLength, specialStr);
|
||||
const content = Buffer.from(strBuf, "utf-8");
|
||||
await insertIntoBlobTable1(id, content);
|
||||
|
||||
result = await connection.execute(
|
||||
const result = await connection.execute(
|
||||
"SELECT ID, B from nodb_blob1 WHERE ID = :id",
|
||||
{ id : id },
|
||||
{
|
||||
fetchInfo : { B : { type : oracledb.DEFAULT } }
|
||||
});
|
||||
|
||||
let lob = result.rows[0][1];
|
||||
assert(lob);
|
||||
let blobData = Buffer.alloc(0);
|
||||
let totalLength = 0;
|
||||
await new Promise((resolve, reject) => {
|
||||
lob.on('data', function(chunk) {
|
||||
totalLength = totalLength + chunk.length;
|
||||
blobData = Buffer.concat([blobData, chunk], totalLength);
|
||||
});
|
||||
|
||||
lob.on('error', function(err) {
|
||||
assert.ifError(err, "lob.on 'error' event.");
|
||||
reject();
|
||||
});
|
||||
|
||||
lob.on('end', async function() {
|
||||
await compareClientFetchResult(blobData, specialStr, content, contentLength);
|
||||
lob.destroy();
|
||||
});
|
||||
|
||||
lob.on('close', function() {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
const lob = result.rows[0][1];
|
||||
const blobData = await lob.getData();
|
||||
await compareClientFetchResult(blobData, specialStr, content, contentLength);
|
||||
lob.destroy();
|
||||
}); // 87.1.16
|
||||
|
||||
it('87.1.17 works with await connection.queryStream()', async function() {
|
||||
let id = insertID++;
|
||||
const id = insertID++;
|
||||
const specialStr = '87.1.17';
|
||||
const contentLength = 200;
|
||||
const strBuf = random.getRandomString(contentLength, specialStr);
|
||||
const content = Buffer.from(strBuf, "utf-8");
|
||||
|
||||
|
||||
await insertIntoBlobTable1(id, content);
|
||||
const sql = "SELECT ID, B from nodb_blob1 WHERE ID = " + id;
|
||||
const stream = await connection.queryStream(sql);
|
||||
let counter = 0;
|
||||
await new Promise((resolve, reject) => {
|
||||
stream.on('error', function(error) {
|
||||
assert.ifError(error, null, 'Error event should not be triggered');
|
||||
reject();
|
||||
});
|
||||
|
||||
let counter = 0;
|
||||
|
||||
stream.on('error', reject);
|
||||
stream.on('end', stream.destroy);
|
||||
stream.on('close', resolve);
|
||||
stream.on('data', function(data) {
|
||||
assert(data);
|
||||
let result = data[1];
|
||||
compareBuffers(result, specialStr, content, contentLength);
|
||||
compareBuffers(data[1], specialStr, content, contentLength);
|
||||
counter++;
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
assert.equal(counter, 1);
|
||||
stream.destroy();
|
||||
});
|
||||
|
||||
stream.on('close', function() {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
assert.strictEqual(counter, 1);
|
||||
}); // 87.1.17
|
||||
|
||||
it('87.1.18 works with await connection.queryStream() and oracledb.maxRows > actual number of rows in the table', async function() {
|
||||
|
@ -519,22 +428,16 @@ describe('87. fetchBlobAsBuffer1.js', function() {
|
|||
const maxRowsBak = oracledb.maxRows;
|
||||
oracledb.maxRows = 20;
|
||||
|
||||
|
||||
await insertIntoBlobTable1(id_1, content_1);
|
||||
|
||||
await insertIntoBlobTable1(id_2, content_2);
|
||||
|
||||
const sql = "SELECT ID, B from nodb_blob1 WHERE ID = " + id_1 + " or id = " + id_2;
|
||||
const stream = await connection.queryStream(sql);
|
||||
let counter = 0;
|
||||
await new Promise((resolve, reject) => {
|
||||
stream.on('error', function(error) {
|
||||
assert.ifError(error, null, 'Error event should not be triggered');
|
||||
reject();
|
||||
});
|
||||
|
||||
let counter = 0;
|
||||
stream.on('error', reject);
|
||||
stream.on('end', stream.destroy);
|
||||
stream.on('close', resolve);
|
||||
stream.on('data', function(data) {
|
||||
assert(data);
|
||||
const result = data[1];
|
||||
counter++;
|
||||
if (counter == 1) {
|
||||
|
@ -543,17 +446,9 @@ describe('87. fetchBlobAsBuffer1.js', function() {
|
|||
compareBuffers(result, specialStr_2, content_2, contentLength_2);
|
||||
}
|
||||
});
|
||||
|
||||
stream.on('end', function() {
|
||||
assert.equal(counter, 2);
|
||||
oracledb.maxRows = maxRowsBak;
|
||||
stream.destroy();
|
||||
});
|
||||
|
||||
stream.on('close', function() {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
oracledb.maxRows = maxRowsBak;
|
||||
assert.equal(counter, 2);
|
||||
}); // 87.1.18
|
||||
|
||||
it('87.1.19 works with await connection.queryStream() and oracledb.maxRows = actual number of rows in the table', async function() {
|
||||
|
@ -834,7 +729,7 @@ describe('87. fetchBlobAsBuffer1.js', function() {
|
|||
|
||||
await insertAndFetch(id, specialStr_1, content_1, contentLength_1);
|
||||
|
||||
updateBlobTable1(id, content_2);
|
||||
await updateBlobTable1(id, content_2);
|
||||
|
||||
result = await connection.execute(
|
||||
"SELECT ID, B from nodb_blob1 WHERE ID = " + id,
|
||||
|
@ -1220,7 +1115,7 @@ describe('87. fetchBlobAsBuffer1.js', function() {
|
|||
|
||||
await insertAndFetch(id, specialStr_1, content_1, contentLength_1);
|
||||
|
||||
updateBlobTable1(id, content_2);
|
||||
await updateBlobTable1(id, content_2);
|
||||
result = await connection.execute(
|
||||
"SELECT ID, B from nodb_blob1 WHERE ID = " + id,
|
||||
{ },
|
||||
|
@ -1610,7 +1505,7 @@ describe('87. fetchBlobAsBuffer1.js', function() {
|
|||
|
||||
await insertAndFetch(id, specialStr_1, content_1, contentLength_1);
|
||||
|
||||
updateBlobTable1(id, content_2);
|
||||
await updateBlobTable1(id, content_2);
|
||||
|
||||
result = await connection.execute(
|
||||
"SELECT ID, B from nodb_blob1 WHERE ID = " + id,
|
||||
|
@ -2007,7 +1902,7 @@ describe('87. fetchBlobAsBuffer1.js', function() {
|
|||
|
||||
await insertAndFetch(id, specialStr_1, content_1, contentLength_1);
|
||||
|
||||
updateBlobTable1(id, content_2);
|
||||
await updateBlobTable1(id, content_2);
|
||||
|
||||
result = await connection.execute(
|
||||
"SELECT ID, B from nodb_blob1 WHERE ID = " + id,
|
||||
|
@ -2218,4 +2113,5 @@ describe('87. fetchBlobAsBuffer1.js', function() {
|
|||
}); // 87.5.16
|
||||
|
||||
}); // 87.5
|
||||
|
||||
});
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -31,11 +31,12 @@
|
|||
* This could be very useful for smaller CLOB size as it can be fetched as string and processed in memory itself.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const file = require('./file.js');
|
||||
const fs = require('fs');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
|
||||
|
@ -67,13 +68,13 @@ describe('84. fetchClobAsString1.js', function() {
|
|||
before('get one connection', async function() {
|
||||
oracledb.stmtCacheSize = 0;
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
file.create(inFileName);
|
||||
await fs.promises.writeFile(inFileName, '');
|
||||
}); // before
|
||||
|
||||
after('release connection', async function() {
|
||||
oracledb.stmtCacheSize = defaultStmtCache;
|
||||
await connection.close();
|
||||
file.delete(inFileName);
|
||||
await fs.promises.unlink(inFileName);
|
||||
}); // after
|
||||
|
||||
const insertIntoClobTable1 = async function(id, content) {
|
||||
|
@ -1561,4 +1562,5 @@ describe('84. fetchClobAsString1.js', function() {
|
|||
}); // 84.5.16
|
||||
|
||||
}); // 84.5
|
||||
|
||||
});
|
||||
|
|
|
@ -31,21 +31,22 @@
|
|||
* This could be very useful for smaller CLOB size as it can be fetched as string and processed in memory itself.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const async = require('async');
|
||||
const should = require('should');
|
||||
const file = require('./file.js');
|
||||
const fsPromises = require('fs/promises');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
|
||||
describe('85. fetchClobAsString2.js', function() {
|
||||
|
||||
let connection = null;
|
||||
var insertID = 1; // assume id for insert into db starts from 1
|
||||
var inFileName = './test/clobTmpFile.txt';
|
||||
var proc_create_table1 = "BEGIN \n" +
|
||||
let insertID = 1; // assume id for insert into db starts from 1
|
||||
const inFileName = './test/clobTmpFile.txt';
|
||||
const proc_create_table1 = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
|
@ -62,44 +63,22 @@ describe('85. fetchClobAsString2.js', function() {
|
|||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
var drop_table1 = "DROP TABLE nodb_clob1 PURGE";
|
||||
var defaultStmtCache = oracledb.stmtCacheSize;
|
||||
|
||||
before('get one connection', function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
oracledb.stmtCacheSize = 0;
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function(cb) {
|
||||
file.create(inFileName);
|
||||
cb();
|
||||
}
|
||||
], done);
|
||||
const drop_table1 = "DROP TABLE nodb_clob1 PURGE";
|
||||
const defaultStmtCache = oracledb.stmtCacheSize;
|
||||
|
||||
before('get one connection', async function() {
|
||||
oracledb.stmtCacheSize = 0;
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
await fsPromises.writeFile(inFileName, '');
|
||||
}); // before
|
||||
|
||||
after('release connection', function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
oracledb.stmtCacheSize = defaultStmtCache;
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function(cb) {
|
||||
file.delete(inFileName);
|
||||
cb();
|
||||
}
|
||||
], done);
|
||||
}); // after
|
||||
after('release connection', async function() {
|
||||
oracledb.stmtCacheSize = defaultStmtCache;
|
||||
await connection.close();
|
||||
await fsPromises.unlink(inFileName);
|
||||
}); // after
|
||||
|
||||
var insertIntoClobTable1 = function(id, content, callback) {
|
||||
const insertIntoClobTable1 = function(id, content, callback) {
|
||||
if (content == "EMPTY_CLOB") {
|
||||
connection.execute(
|
||||
"INSERT INTO nodb_clob1 VALUES (:ID, EMPTY_CLOB())",
|
||||
|
@ -2300,4 +2279,5 @@ describe('85. fetchClobAsString2.js', function() {
|
|||
}); // 85.5.13
|
||||
|
||||
}); // 85.5
|
||||
|
||||
});
|
||||
|
|
|
@ -37,15 +37,14 @@ const oracledb = require('oracledb');
|
|||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
const sql = require('./sql.js');
|
||||
const testsUtil = require('./testsUtil.js');
|
||||
|
||||
describe('117. fetchUrowidAsString_indexed.js', function() {
|
||||
let connection = null;
|
||||
let insertID = 1;
|
||||
let tableName_indexed = "nodb_urowid_fsi";
|
||||
let tableName_normal = "nodb_urowid_fsn";
|
||||
let table_indexed = "BEGIN \n" +
|
||||
const tableName_indexed = "nodb_urowid_fsi";
|
||||
const tableName_normal = "nodb_urowid_fsn";
|
||||
const table_indexed = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n" +
|
||||
|
@ -64,7 +63,7 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
" '); \n" +
|
||||
"END; ";
|
||||
|
||||
let table_normal = "BEGIN \n" +
|
||||
const table_normal = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n" +
|
||||
|
@ -82,8 +81,8 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
" '); \n" +
|
||||
"END; ";
|
||||
|
||||
let drop_table_indexed = "DROP TABLE " + tableName_indexed + " PURGE";
|
||||
let drop_table_normal = "DROP TABLE " + tableName_normal + " PURGE";
|
||||
const drop_table_indexed = "DROP TABLE " + tableName_indexed + " PURGE";
|
||||
const drop_table_normal = "DROP TABLE " + tableName_normal + " PURGE";
|
||||
|
||||
before('get connection and create table', async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
|
@ -98,33 +97,21 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
});
|
||||
|
||||
describe('117.1 works with fetchInfo option and urowid length > 200/500', function() {
|
||||
let option = { fetchInfo: { "content": { type: oracledb.STRING } } };
|
||||
let maxRowBak;
|
||||
const option = { fetchInfo: { "content": { type: oracledb.STRING } } };
|
||||
const maxRowBak = oracledb.maxRows;
|
||||
|
||||
before('get connection and create table', async function() {
|
||||
|
||||
await sql.executeSql(connection, table_indexed, {}, {});
|
||||
|
||||
await sql.executeSql(connection, table_normal, {}, {});
|
||||
|
||||
await connection.execute(table_indexed);
|
||||
await connection.execute(table_normal);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
|
||||
await sql.executeSql(connection, drop_table_indexed, {}, {});
|
||||
|
||||
await sql.executeSql(connection, drop_table_normal, {}, {});
|
||||
|
||||
});
|
||||
|
||||
beforeEach(function() {
|
||||
maxRowBak = oracledb.maxRows;
|
||||
|
||||
await connection.execute(drop_table_indexed);
|
||||
await connection.execute(drop_table_normal);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
oracledb.maxRows = maxRowBak;
|
||||
|
||||
});
|
||||
|
||||
it('117.1.1 fetchInfo', async function() {
|
||||
|
@ -147,7 +134,7 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
});
|
||||
|
||||
it('117.1.5 resultSet = true', async function() {
|
||||
let option_rs = {
|
||||
const option_rs = {
|
||||
resultSet: true,
|
||||
fetchInfo: { "content": { type: oracledb.STRING } }
|
||||
};
|
||||
|
@ -172,36 +159,24 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
});
|
||||
|
||||
describe('117.2 works with fetchInfo and outFormat = OBJECT, urowid length > 200/500', function() {
|
||||
let option = {
|
||||
const option = {
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
fetchInfo: { "content": { type: oracledb.STRING } }
|
||||
};
|
||||
let maxRowBak;
|
||||
const maxRowBak = oracledb.maxRows;
|
||||
|
||||
before('get connection and create table', async function() {
|
||||
|
||||
await sql.executeSql(connection, table_indexed, {}, {});
|
||||
|
||||
await sql.executeSql(connection, table_normal, {}, {});
|
||||
|
||||
await connection.execute(table_indexed);
|
||||
await connection.execute(table_normal);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
|
||||
await sql.executeSql(connection, drop_table_indexed, {}, {});
|
||||
|
||||
await sql.executeSql(connection, drop_table_normal, {}, {});
|
||||
|
||||
});
|
||||
|
||||
beforeEach(function() {
|
||||
maxRowBak = oracledb.maxRows;
|
||||
|
||||
await connection.execute(drop_table_indexed);
|
||||
await connection.execute(drop_table_normal);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
oracledb.maxRows = maxRowBak;
|
||||
|
||||
});
|
||||
|
||||
it('117.2.1 fetchInfo', async function() {
|
||||
|
@ -224,7 +199,7 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
});
|
||||
|
||||
it('117.2.5 resultSet = true', async function() {
|
||||
let option_rs = {
|
||||
const option_rs = {
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
resultSet: true,
|
||||
fetchInfo: { "content": { type: oracledb.STRING } }
|
||||
|
@ -250,36 +225,24 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
});
|
||||
|
||||
describe('117.3 works with fetchInfo and outFormat = ARRAY, urowid length > 200/500', function() {
|
||||
let option = {
|
||||
const option = {
|
||||
outFormat: oracledb.OUT_FORMAT_ARRAY,
|
||||
fetchInfo: { "content": { type: oracledb.STRING } }
|
||||
};
|
||||
let maxRowBak;
|
||||
const maxRowBak = oracledb.maxRows;
|
||||
|
||||
before('get connection and create table', async function() {
|
||||
|
||||
await sql.executeSql(connection, table_indexed, {}, {});
|
||||
|
||||
await sql.executeSql(connection, table_normal, {}, {});
|
||||
|
||||
await connection.execute(table_indexed);
|
||||
await connection.execute(table_normal);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
|
||||
await sql.executeSql(connection, drop_table_indexed, {}, {});
|
||||
|
||||
await sql.executeSql(connection, drop_table_normal, {}, {});
|
||||
|
||||
});
|
||||
|
||||
beforeEach(function() {
|
||||
maxRowBak = oracledb.maxRows;
|
||||
|
||||
await connection.execute(drop_table_indexed);
|
||||
await connection.execute(drop_table_normal);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
oracledb.maxRows = maxRowBak;
|
||||
|
||||
});
|
||||
|
||||
it('117.3.1 fetchInfo', async function() {
|
||||
|
@ -302,7 +265,7 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
});
|
||||
|
||||
it('117.3.5 resultSet = true', async function() {
|
||||
let option_rs = {
|
||||
const option_rs = {
|
||||
outFormat: oracledb.OUT_FORMAT_ARRAY,
|
||||
resultSet: true,
|
||||
fetchInfo: { "content": { type: oracledb.STRING } }
|
||||
|
@ -328,33 +291,21 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
});
|
||||
|
||||
describe('117.4 fetch as string by default, urowid length > 200/500', function() {
|
||||
let option = {};
|
||||
let maxRowBak;
|
||||
const option = {};
|
||||
const maxRowBak = oracledb.maxRows;
|
||||
|
||||
before('get connection and create table', async function() {
|
||||
|
||||
await sql.executeSql(connection, table_indexed, {}, {});
|
||||
|
||||
await sql.executeSql(connection, table_normal, {}, {});
|
||||
|
||||
await connection.execute(table_indexed);
|
||||
await connection.execute(table_normal);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
|
||||
await sql.executeSql(connection, drop_table_indexed, {}, {});
|
||||
|
||||
await sql.executeSql(connection, drop_table_normal, {}, {});
|
||||
|
||||
});
|
||||
|
||||
beforeEach(function() {
|
||||
maxRowBak = oracledb.maxRows;
|
||||
|
||||
await connection.execute(drop_table_indexed);
|
||||
await connection.execute(drop_table_normal);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
oracledb.maxRows = maxRowBak;
|
||||
|
||||
});
|
||||
|
||||
it('117.4.1 fetchInfo', async function() {
|
||||
|
@ -377,7 +328,7 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
});
|
||||
|
||||
it('117.4.5 resultSet = true', async function() {
|
||||
let option_rs = {
|
||||
const option_rs = {
|
||||
resultSet: true,
|
||||
};
|
||||
await test1(option_rs, false, true);
|
||||
|
@ -401,33 +352,21 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
});
|
||||
|
||||
describe('117.5 fetch as string by default with outFormat = OBJECT, urowid length > 200/500', function() {
|
||||
let option = { outFormat: oracledb.OUT_FORMAT_OBJECT };
|
||||
let maxRowBak;
|
||||
const option = { outFormat: oracledb.OUT_FORMAT_OBJECT };
|
||||
const maxRowBak = oracledb.maxRows;
|
||||
|
||||
before('get connection and create table', async function() {
|
||||
|
||||
await sql.executeSql(connection, table_indexed, {}, {});
|
||||
|
||||
await sql.executeSql(connection, table_normal, {}, {});
|
||||
|
||||
await connection.execute(table_indexed);
|
||||
await connection.execute(table_normal);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
|
||||
await sql.executeSql(connection, drop_table_indexed, {}, {});
|
||||
|
||||
await sql.executeSql(connection, drop_table_normal, {}, {});
|
||||
|
||||
});
|
||||
|
||||
beforeEach(function() {
|
||||
maxRowBak = oracledb.maxRows;
|
||||
|
||||
await connection.execute(drop_table_indexed);
|
||||
await connection.execute(drop_table_normal);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
oracledb.maxRows = maxRowBak;
|
||||
|
||||
});
|
||||
|
||||
it('117.5.1 fetchInfo', async function() {
|
||||
|
@ -450,7 +389,7 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
});
|
||||
|
||||
it('117.5.5 resultSet = true', async function() {
|
||||
let option_rs = {
|
||||
const option_rs = {
|
||||
resultSet: true,
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT
|
||||
};
|
||||
|
@ -475,33 +414,21 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
});
|
||||
|
||||
describe('117.6 fetch as string by default with outFormat = ARRAY, urowid length > 200/500', function() {
|
||||
let option = { outFormat: oracledb.OUT_FORMAT_ARRAY };
|
||||
let maxRowBak;
|
||||
const option = { outFormat: oracledb.OUT_FORMAT_ARRAY };
|
||||
const maxRowBak = oracledb.maxRows;
|
||||
|
||||
before('get connection and create table', async function() {
|
||||
|
||||
await sql.executeSql(connection, table_indexed, {}, {});
|
||||
|
||||
await sql.executeSql(connection, table_normal, {}, {});
|
||||
|
||||
await connection.execute(table_indexed);
|
||||
await connection.execute(table_normal);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
|
||||
await sql.executeSql(connection, drop_table_indexed, {}, {});
|
||||
|
||||
await sql.executeSql(connection, drop_table_normal, {}, {});
|
||||
|
||||
});
|
||||
|
||||
beforeEach(function() {
|
||||
maxRowBak = oracledb.maxRows;
|
||||
|
||||
await connection.execute(drop_table_indexed);
|
||||
await connection.execute(drop_table_normal);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
oracledb.maxRows = maxRowBak;
|
||||
|
||||
});
|
||||
|
||||
it('117.6.1 fetchInfo', async function() {
|
||||
|
@ -524,7 +451,7 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
});
|
||||
|
||||
it('117.6.5 resultSet = true', async function() {
|
||||
let option_rs = {
|
||||
const option_rs = {
|
||||
resultSet: true,
|
||||
outFormat: oracledb.OUT_FORMAT_ARRAY
|
||||
};
|
||||
|
@ -549,7 +476,6 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
});
|
||||
|
||||
async function test1(option, object, rsFlag) {
|
||||
|
||||
let strLength = 200;
|
||||
let rowidLenExpected = 200;
|
||||
let id = insertID++;
|
||||
|
@ -565,20 +491,14 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
}
|
||||
|
||||
async function fetchRowid(id, strLength, rowidLenExpected, option, object) {
|
||||
let urowid_1, urowid_2;
|
||||
|
||||
await prepareData(id, strLength, rowidLenExpected);
|
||||
|
||||
let sqlQuery = "select ROWID from " + tableName_indexed + " where c1 = " + id;
|
||||
let result = await connection.execute(sqlQuery);
|
||||
urowid_1 = result.rows[0][0];
|
||||
const urowid_1 = result.rows[0][0];
|
||||
assert.strictEqual(typeof urowid_1, "string");
|
||||
sqlQuery = "select content from " + tableName_normal + " where id = " + id;
|
||||
result = await connection.execute(
|
||||
sqlQuery,
|
||||
[],
|
||||
option);
|
||||
urowid_2 = result.rows[0][0];
|
||||
result = await connection.execute(sqlQuery, [], option);
|
||||
let urowid_2 = result.rows[0][0];
|
||||
if (object === true) {
|
||||
urowid_2 = result.rows[0].CONTENT;
|
||||
}
|
||||
|
@ -590,23 +510,18 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
}
|
||||
|
||||
async function fetchRowid_rs(id, strLength, rowidLenExpected, option, object) {
|
||||
let urowid_1, urowid_2;
|
||||
|
||||
await prepareData(id, strLength, rowidLenExpected);
|
||||
|
||||
let sqlQuery = "select ROWID from " + tableName_indexed + " where c1 = " + id;
|
||||
let result = await connection.execute(
|
||||
sqlQuery);
|
||||
urowid_1 = result.rows[0][0];
|
||||
const urowid_1 = result.rows[0][0];
|
||||
assert.strictEqual(typeof urowid_1, "string");
|
||||
|
||||
sqlQuery = "select content from " + tableName_normal + " where id = " + id;
|
||||
result = await connection.execute(
|
||||
sqlQuery,
|
||||
[],
|
||||
option);
|
||||
let row = await result.resultSet.getRow();
|
||||
urowid_2 = row[0];
|
||||
result = await connection.execute(sqlQuery, [], option);
|
||||
const row = await result.resultSet.getRow();
|
||||
let urowid_2 = row[0];
|
||||
if (object === true) {
|
||||
urowid_2 = row.CONTENT;
|
||||
}
|
||||
|
@ -618,9 +533,9 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
}
|
||||
|
||||
async function testMaxRow(option, rsFlag) {
|
||||
let id_1 = insertID++;
|
||||
let id_2 = insertID++;
|
||||
let rowExpected, rowid_1, rowid_2, sqlQuery;
|
||||
const id_1 = insertID++;
|
||||
const id_2 = insertID++;
|
||||
let rowid_2;
|
||||
|
||||
let strLength = 200;
|
||||
let rowidLenExpected = 200;
|
||||
|
@ -633,17 +548,17 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
let result = await connection.execute(
|
||||
"select * from " + tableName_normal + " where id = " + id_1 + " or id = " + id_2);
|
||||
|
||||
rowExpected = (oracledb.maxRows >= 2) ? 2 : oracledb.maxRows;
|
||||
let rowExpected = (oracledb.maxRows >= 2) ? 2 : oracledb.maxRows;
|
||||
if (rsFlag === true) {
|
||||
rowExpected = 2;
|
||||
}
|
||||
assert.strictEqual(result.rows.length, rowExpected);
|
||||
rowid_1 = result.rows[0][1];
|
||||
const rowid_1 = result.rows[0][1];
|
||||
if (rowExpected === 2) {
|
||||
rowid_2 = result.rows[1][1];
|
||||
}
|
||||
|
||||
sqlQuery = "select ROWID from " + tableName_indexed + " where c1 = " + id_1;
|
||||
let sqlQuery = "select ROWID from " + tableName_indexed + " where c1 = " + id_1;
|
||||
result = await connection.execute(sqlQuery);
|
||||
let resultVal = result.rows[0][0];
|
||||
assert.strictEqual(typeof resultVal, "string");
|
||||
|
@ -672,37 +587,29 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
await prepareData(id_2, strLength, rowidLenExpected);
|
||||
|
||||
let sqlQuery = "select content from " + tableName_normal + " where id = " + id_1 + " or id = " + id_2;
|
||||
let stream = await connection.queryStream(
|
||||
sqlQuery,
|
||||
[],
|
||||
option
|
||||
);
|
||||
const stream = await connection.queryStream(sqlQuery, [], option);
|
||||
|
||||
let result = [];
|
||||
await new Promise((resolve, reject) => {
|
||||
stream.on('error', reject);
|
||||
stream.on('close', resolve);
|
||||
stream.on('data', function(data) {
|
||||
assert(data);
|
||||
result.push(data);
|
||||
});
|
||||
|
||||
stream.on('error', function(error) {
|
||||
reject(error);
|
||||
});
|
||||
stream.on('end', function() {
|
||||
assert.strictEqual(result.length, 2);
|
||||
rowid_1 = result[0][0];
|
||||
rowid_2 = result[1][0];
|
||||
if (object === true) {
|
||||
rowid_1 = result[0].CONTENT;
|
||||
rowid_2 = result[1].CONTENT;
|
||||
} else {
|
||||
rowid_1 = result[0][0];
|
||||
rowid_2 = result[1][0];
|
||||
}
|
||||
stream.destroy();
|
||||
});
|
||||
|
||||
stream.on('close', function() {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
sqlQuery = "select ROWID from " + tableName_indexed + " where c1 = " + id_1;
|
||||
result = await connection.execute(
|
||||
sqlQuery);
|
||||
|
@ -719,17 +626,16 @@ describe('117. fetchUrowidAsString_indexed.js', function() {
|
|||
}
|
||||
|
||||
async function prepareData(id, strLength, rowidLenExpected) {
|
||||
let str = random.getRandomLengthString(strLength);
|
||||
let urowid, urowidLen;
|
||||
const str = random.getRandomLengthString(strLength);
|
||||
|
||||
let sql_insert = "insert into " + tableName_indexed + " values (" + id + ", '" + str + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
const sql_insert = "insert into " + tableName_indexed + " values (" + id + ", '" + str + "')";
|
||||
await connection.execute(sql_insert);
|
||||
|
||||
let result = await connection.execute(
|
||||
"select ROWID from " + tableName_indexed + " where c1 = " + id);
|
||||
|
||||
urowid = result.rows[0][0];
|
||||
urowidLen = urowid.length;
|
||||
const urowid = result.rows[0][0];
|
||||
const urowidLen = urowid.length;
|
||||
testsUtil.checkUrowidLength(urowidLen, rowidLenExpected);
|
||||
|
||||
result = await connection.execute(
|
||||
|
|
62
test/file.js
62
test/file.js
|
@ -1,62 +0,0 @@
|
|||
/* Copyright (c) 2017, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This software is dual-licensed to you under the Universal Permissive License
|
||||
* (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
|
||||
* 2.0 as shown at https://www.apache.org/licenses/LICENSE-2.0. You may choose
|
||||
* either license.
|
||||
*
|
||||
* If you elect to accept the software under the Apache License, Version 2.0,
|
||||
* the following applies:
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* NAME
|
||||
* file.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* file manipulate
|
||||
*****************************************************************************/
|
||||
'use strict';
|
||||
const should = require('should');
|
||||
const fs = require('fs');
|
||||
const random = require('./random.js');
|
||||
|
||||
var file = exports;
|
||||
module.exports = file;
|
||||
|
||||
file.create = function(filePath) {
|
||||
fs.closeSync(fs.openSync(filePath, 'w'));
|
||||
};
|
||||
|
||||
file.write = function(filePath, content) {
|
||||
var stream = fs.createWriteStream(filePath, { flags: 'w', defaultEncoding: 'utf8', autoClose: true });
|
||||
stream.write(content);
|
||||
stream.end();
|
||||
};
|
||||
|
||||
file.delete = function(filePath) {
|
||||
if (fs.existsSync(filePath) === true) {
|
||||
fs.unlink(filePath, function(err) {
|
||||
should.not.exist(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
file.createFileInKB = function(fileName, length, specialStr) {
|
||||
var bigStr = random.getRandomString(length, specialStr);
|
||||
var stream = fs.createWriteStream(fileName, { flags: 'w', defaultEncoding: 'utf8', autoClose: true });
|
||||
stream.write(bigStr);
|
||||
stream.end();
|
||||
};
|
1729
test/lobBind1.js
1729
test/lobBind1.js
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2016, 2022, Oracle and/or its affiliates. */
|
||||
/* Copyright (c) 2016, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
|
|
|
@ -33,235 +33,189 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
const testsUtil = require('./testsUtil.js');
|
||||
const sql = require('./sql.js');
|
||||
|
||||
describe('131. longProcedureBind_in.js', function() {
|
||||
|
||||
let connection = null;
|
||||
const tableName = "nodb_long_128";
|
||||
var insertID = 0;
|
||||
let insertID = 0;
|
||||
|
||||
before(function(done) {
|
||||
before(async function() {
|
||||
const sqlCreate = `
|
||||
CREATE TABLE ${tableName} (
|
||||
id NUMBER,
|
||||
content LONG
|
||||
)`;
|
||||
const sqlCreateTbl = testsUtil.sqlCreateTable(tableName, sqlCreate);
|
||||
async.series([
|
||||
function(cb) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function(cb) {
|
||||
sql.executeSql(connection, sqlCreateTbl, {}, {}, cb);
|
||||
}
|
||||
], done);
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
await connection.execute(sqlCreateTbl);
|
||||
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
after(async function() {
|
||||
const sqlDropTbl = testsUtil.sqlDropTable(tableName);
|
||||
async.series([
|
||||
function(cb) {
|
||||
sql.executeSql(connection, sqlDropTbl, {}, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
|
||||
await connection.execute(sqlDropTbl);
|
||||
|
||||
await connection.close();
|
||||
}); // after
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function() {
|
||||
insertID++;
|
||||
done();
|
||||
});
|
||||
|
||||
describe('131.1 PLSQL PROCEDURE BIND IN AS LONG', function() {
|
||||
var proc_bindin_name = "nodb_long_bindin_proc_1";
|
||||
var proc_bindin_create = "CREATE OR REPLACE PROCEDURE " + proc_bindin_name + " (ID IN NUMBER, CONTENT IN LONG) \n" +
|
||||
const proc_bindin_name = "nodb_long_bindin_proc_1";
|
||||
const proc_bindin_create = "CREATE OR REPLACE PROCEDURE " + proc_bindin_name + " (ID IN NUMBER, CONTENT IN LONG) \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " values (ID, CONTENT); \n" +
|
||||
"END " + proc_bindin_name + ";";
|
||||
var proc_bindin_exec = "BEGIN " + proc_bindin_name + " (:i, :c); END;";
|
||||
var proc_bindin_drop = "DROP PROCEDURE " + proc_bindin_name;
|
||||
const proc_bindin_exec = "BEGIN " + proc_bindin_name + " (:i, :c); END;";
|
||||
const proc_bindin_drop = "DROP PROCEDURE " + proc_bindin_name;
|
||||
|
||||
before(function(done) {
|
||||
sql.executeSql(connection, proc_bindin_create, {}, {}, done);
|
||||
before(async function() {
|
||||
await connection.execute(proc_bindin_create);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
sql.executeSql(connection, proc_bindin_drop, {}, {}, done);
|
||||
after(async function() {
|
||||
await connection.execute(proc_bindin_drop);
|
||||
});
|
||||
|
||||
it('131.1.1 works with NULL', function(done) {
|
||||
var insertedStr = null;
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('131.1.1 works with NULL', async function() {
|
||||
const insertedStr = null;
|
||||
await long_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('131.1.2 works with undefined', function(done) {
|
||||
var insertedStr = undefined;
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('131.1.2 works with undefined', async function() {
|
||||
const insertedStr = undefined;
|
||||
await long_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('131.1.3 works with empty string', function(done) {
|
||||
var insertedStr = "";
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('131.1.3 works with empty string', async function() {
|
||||
const insertedStr = "";
|
||||
await long_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('131.1.4 works with data size 4000', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(4000);
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('131.1.4 works with data size 4000', async function() {
|
||||
const insertedStr = random.getRandomLengthString(4000);
|
||||
await long_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('131.1.5 works with data size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(32767);
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('131.1.5 works with data size (32K - 1)', async function() {
|
||||
const insertedStr = random.getRandomLengthString(32767);
|
||||
await long_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('131.1.6 set maxSize to size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
long_bindin_maxSize(insertedStr, proc_bindin_exec, 32767, done);
|
||||
it('131.1.6 set maxSize to size (32K - 1)', async function() {
|
||||
const insertedStr = random.getRandomLengthString(100);
|
||||
await long_bindin_maxSize(insertedStr, proc_bindin_exec, 32767);
|
||||
});
|
||||
|
||||
it('131.1.7 set maxSize to size 1GB', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
var maxsize = 1 * 1024 * 1024 * 1024;
|
||||
long_bindin_maxSize(insertedStr, proc_bindin_exec, maxsize, done);
|
||||
it('131.1.7 set maxSize to size 1GB', async function() {
|
||||
const insertedStr = random.getRandomLengthString(100);
|
||||
const maxsize = 1 * 1024 * 1024 * 1024;
|
||||
await long_bindin_maxSize(insertedStr, proc_bindin_exec, maxsize);
|
||||
});
|
||||
|
||||
}); // 131.1
|
||||
|
||||
describe('131.2 PLSQL PROCEDURE BIND IN AS STRING', function() {
|
||||
var proc_bindin_name = "nodb_long_bindin_proc_2";
|
||||
var proc_bindin_create = "CREATE OR REPLACE PROCEDURE " + proc_bindin_name + " (ID IN NUMBER, CONTENT IN VARCHAR2) \n" +
|
||||
const proc_bindin_name = "nodb_long_bindin_proc_2";
|
||||
const proc_bindin_create = "CREATE OR REPLACE PROCEDURE " + proc_bindin_name + " (ID IN NUMBER, CONTENT IN VARCHAR2) \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " values (ID, CONTENT); \n" +
|
||||
"END " + proc_bindin_name + ";";
|
||||
var proc_bindin_exec = "BEGIN " + proc_bindin_name + " (:i, :c); END;";
|
||||
var proc_bindin_drop = "DROP PROCEDURE " + proc_bindin_name;
|
||||
const proc_bindin_exec = "BEGIN " + proc_bindin_name + " (:i, :c); END;";
|
||||
const proc_bindin_drop = "DROP PROCEDURE " + proc_bindin_name;
|
||||
|
||||
before(function(done) {
|
||||
sql.executeSql(connection, proc_bindin_create, {}, {}, done);
|
||||
before(async function() {
|
||||
await connection.execute(proc_bindin_create);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
sql.executeSql(connection, proc_bindin_drop, {}, {}, done);
|
||||
after(async function() {
|
||||
await connection.execute(proc_bindin_drop);
|
||||
});
|
||||
|
||||
it('131.2.1 works with NULL', function(done) {
|
||||
var insertedStr = null;
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('131.2.1 works with NULL', async function() {
|
||||
const insertedStr = null;
|
||||
await long_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('131.2.2 works with undefined', function(done) {
|
||||
var insertedStr = undefined;
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('131.2.2 works with undefined', async function() {
|
||||
const insertedStr = undefined;
|
||||
await long_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('131.2.3 works with empty string', function(done) {
|
||||
var insertedStr = "";
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('131.2.3 works with empty string', async function() {
|
||||
const insertedStr = "";
|
||||
await long_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('131.2.4 works with data size 4000', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(4000);
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('131.2.4 works with data size 4000', async function() {
|
||||
const insertedStr = random.getRandomLengthString(4000);
|
||||
await long_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('131.2.5 works with data size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(32767);
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('131.2.5 works with data size (32K - 1)', async function() {
|
||||
const insertedStr = random.getRandomLengthString(32767);
|
||||
await long_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('131.2.6 set maxSize to size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
long_bindin_maxSize(insertedStr, proc_bindin_exec, 32767, done);
|
||||
it('131.2.6 set maxSize to size (32K - 1)', async function() {
|
||||
const insertedStr = random.getRandomLengthString(100);
|
||||
await long_bindin_maxSize(insertedStr, proc_bindin_exec, 32767);
|
||||
});
|
||||
|
||||
it('131.2.7 set maxSize to size 1GB', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
var maxsize = 1 * 1024 * 1024 * 1024;
|
||||
long_bindin_maxSize(insertedStr, proc_bindin_exec, maxsize, done);
|
||||
it('131.2.7 set maxSize to size 1GB', async function() {
|
||||
const insertedStr = random.getRandomLengthString(100);
|
||||
const maxsize = 1 * 1024 * 1024 * 1024;
|
||||
await long_bindin_maxSize(insertedStr, proc_bindin_exec, maxsize);
|
||||
});
|
||||
|
||||
}); // 131.2
|
||||
|
||||
var long_bindin = function(insertContent, proc_bindin_exec, callback) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
var bind_in_var = {
|
||||
i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { val: insertContent, dir: oracledb.BIND_IN, type: oracledb.STRING }
|
||||
};
|
||||
connection.execute(
|
||||
proc_bindin_exec,
|
||||
bind_in_var,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
var expected = insertContent;
|
||||
if (insertContent == "" || insertContent == undefined) {
|
||||
expected = null;
|
||||
}
|
||||
checkResult(expected, cb);
|
||||
}
|
||||
], callback);
|
||||
const long_bindin = async function(insertContent, proc_bindin_exec) {
|
||||
|
||||
const bind_in_var = {
|
||||
i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { val: insertContent, dir: oracledb.BIND_IN, type: oracledb.STRING }
|
||||
};
|
||||
await connection.execute(
|
||||
proc_bindin_exec,
|
||||
bind_in_var);
|
||||
let expected = insertContent;
|
||||
if (insertContent == "" || insertContent == undefined) {
|
||||
expected = null;
|
||||
}
|
||||
await checkResult(expected);
|
||||
};
|
||||
|
||||
var long_bindin_maxSize = function(insertContent, proc_bindin_exec, maxsize, callback) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
var bind_in_var = {
|
||||
i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { val: insertContent, dir: oracledb.BIND_IN, type: oracledb.STRING, maxSize: maxsize }
|
||||
};
|
||||
connection.execute(
|
||||
proc_bindin_exec,
|
||||
bind_in_var,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
var expected = insertContent;
|
||||
if (insertContent == "" || insertContent == undefined) {
|
||||
expected = null;
|
||||
}
|
||||
checkResult(expected, cb);
|
||||
}
|
||||
], callback);
|
||||
const long_bindin_maxSize = async function(insertContent, proc_bindin_exec, maxsize) {
|
||||
|
||||
const bind_in_var = {
|
||||
i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { val: insertContent, dir: oracledb.BIND_IN, type: oracledb.STRING, maxSize: maxsize }
|
||||
};
|
||||
await connection.execute(
|
||||
proc_bindin_exec,
|
||||
bind_in_var);
|
||||
let expected = insertContent;
|
||||
if (insertContent == "" || insertContent == undefined) {
|
||||
expected = null;
|
||||
}
|
||||
await checkResult(expected);
|
||||
};
|
||||
|
||||
var checkResult = function(expected, callback) {
|
||||
connection.execute(
|
||||
"select * from " + tableName + " where id = " + insertID,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rows[0][0], insertID);
|
||||
should.strictEqual(result.rows[0][1], expected);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
const checkResult = async function(expected) {
|
||||
const result = await connection.execute("select * from " + tableName + " where id = " + insertID);
|
||||
assert.strictEqual(result.rows[0][0], insertID);
|
||||
assert.strictEqual(result.rows[0][1], expected);
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
* Long column restrictions: http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements001.htm#SQLRF00201
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
|
@ -37,7 +38,6 @@ const assert = require('assert');
|
|||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
const testsUtil = require('./testsUtil.js');
|
||||
const sql = require('./sqlClone.js');
|
||||
|
||||
describe('130. longProcedureBind_out.js', function() {
|
||||
|
||||
|
@ -53,12 +53,12 @@ describe('130. longProcedureBind_out.js', function() {
|
|||
content LONG
|
||||
)`;
|
||||
const sqlCreateTbl = testsUtil.sqlCreateTable(tableName, sqlCreate);
|
||||
await sql.executeSql(connection, sqlCreateTbl, {}, {});
|
||||
await connection.execute(sqlCreateTbl);
|
||||
}); // before
|
||||
|
||||
after(async function() {
|
||||
const sqlDropTbl = testsUtil.sqlDropTable(tableName);
|
||||
await sql.executeSql(connection, sqlDropTbl, {}, {});
|
||||
await connection.execute(sqlDropTbl);
|
||||
await connection.close();
|
||||
}); // after
|
||||
|
||||
|
@ -77,11 +77,11 @@ describe('130. longProcedureBind_out.js', function() {
|
|||
const proc_bindout_drop = "DROP PROCEDURE " + proc_bindout_name;
|
||||
|
||||
before(async function() {
|
||||
await sql.executeSql(connection, proc_bindout_create, {}, {});
|
||||
await connection.execute(proc_bindout_create);
|
||||
});
|
||||
|
||||
after(async function() {
|
||||
await sql.executeSql(connection, proc_bindout_drop, {}, {});
|
||||
await connection.execute(proc_bindout_drop);
|
||||
});
|
||||
|
||||
it('130.1.1 works with NULL', async function() {
|
||||
|
@ -126,11 +126,11 @@ describe('130. longProcedureBind_out.js', function() {
|
|||
const proc_bindout_drop = "DROP PROCEDURE " + proc_bindout_name;
|
||||
|
||||
before(async function() {
|
||||
await sql.executeSql(connection, proc_bindout_create, {}, {});
|
||||
await connection.execute(proc_bindout_create);
|
||||
});
|
||||
|
||||
after(async function() {
|
||||
await sql.executeSql(connection, proc_bindout_drop, {}, {});
|
||||
await connection.execute(proc_bindout_drop);
|
||||
});
|
||||
|
||||
it('130.2.1 works with NULL', async function() {
|
||||
|
@ -177,7 +177,6 @@ describe('130. longProcedureBind_out.js', function() {
|
|||
expected = null;
|
||||
}
|
||||
assert.strictEqual(result.outBinds.c, expected);
|
||||
|
||||
};
|
||||
|
||||
const insert = async function(insertStr) {
|
||||
|
@ -187,8 +186,6 @@ describe('130. longProcedureBind_out.js', function() {
|
|||
i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { val: insertStr, type: oracledb.STRING, dir: oracledb.BIND_IN }
|
||||
});
|
||||
|
||||
assert(result);
|
||||
assert.strictEqual(result.rowsAffected, 1);
|
||||
};
|
||||
|
||||
|
|
|
@ -30,178 +30,158 @@
|
|||
* https://docs.oracle.com/cloud/latest/db121/LNPLS/datatypes.htm#LNPLS346
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
const sql = require('./sql.js');
|
||||
const testsUtil = require('./testsUtil.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
||||
describe('132. longrawProcedureBind_in.js', function() {
|
||||
|
||||
var connection = null;
|
||||
let connection = null;
|
||||
const tableName = "nodb_longraw_132";
|
||||
var insertID = 0;
|
||||
let insertID = 0;
|
||||
|
||||
before(function(done) {
|
||||
before(async function() {
|
||||
const sqlCreate = `
|
||||
CREATE TABLE ${tableName} (
|
||||
id NUMBER,
|
||||
content LONG RAW
|
||||
)`;
|
||||
const sqlCreateTbl = testsUtil.sqlCreateTable(tableName, sqlCreate);
|
||||
async.series([
|
||||
function(cb) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function(cb) {
|
||||
sql.executeSql(connection, sqlCreateTbl, {}, {}, cb);
|
||||
}
|
||||
], done);
|
||||
const sqlCreateTbl = await testsUtil.sqlCreateTable(tableName, sqlCreate);
|
||||
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
await connection.execute(sqlCreateTbl);
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
const sqlDropTbl = testsUtil.sqlDropTable(tableName);
|
||||
async.series([
|
||||
function(cb) {
|
||||
sql.executeSql(connection, sqlDropTbl, {}, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
after(async function() {
|
||||
const sqlDropTbl = await testsUtil.sqlDropTable(tableName);
|
||||
await connection.execute(sqlDropTbl);
|
||||
await connection.close();
|
||||
}); // after
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function() {
|
||||
insertID++;
|
||||
done();
|
||||
});
|
||||
|
||||
describe('132.1 PLSQL PROCEDURE BIND IN AS LONG RAW', function() {
|
||||
var proc_bindin_name = "nodb_longraw_bindin_proc_1";
|
||||
var proc_bindin_create = "CREATE OR REPLACE PROCEDURE " + proc_bindin_name + " (NUM IN NUMBER, C IN LONG RAW) \n" +
|
||||
const proc_bindin_name = "nodb_longraw_bindin_proc_1";
|
||||
const proc_bindin_create = "CREATE OR REPLACE PROCEDURE " + proc_bindin_name + " (NUM IN NUMBER, C IN LONG RAW) \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " values (NUM, C); \n" +
|
||||
"END " + proc_bindin_name + ";";
|
||||
var proc_bindin_exec = "BEGIN " + proc_bindin_name + " (:i, :c); END;";
|
||||
var proc_bindin_drop = "DROP PROCEDURE " + proc_bindin_name;
|
||||
const proc_bindin_exec = "BEGIN " + proc_bindin_name + " (:i, :c); END;";
|
||||
const proc_bindin_drop = "DROP PROCEDURE " + proc_bindin_name;
|
||||
|
||||
before(function(done) {
|
||||
sql.executeSql(connection, proc_bindin_create, {}, {}, done);
|
||||
before(async function() {
|
||||
await connection.execute(proc_bindin_create);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
sql.executeSql(connection, proc_bindin_drop, {}, {}, done);
|
||||
after(async function() {
|
||||
await connection.execute(proc_bindin_drop);
|
||||
});
|
||||
|
||||
it('132.1.1 works with NULL', function(done) {
|
||||
var insertedStr = null;
|
||||
longraw_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('132.1.1 works with NULL', async function() {
|
||||
const insertedStr = null;
|
||||
await longraw_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('132.1.2 works with undefined', function(done) {
|
||||
var insertedStr = undefined;
|
||||
longraw_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('132.1.2 works with undefined', async function() {
|
||||
const insertedStr = undefined;
|
||||
await longraw_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('132.1.3 works with empty buffer', function(done) {
|
||||
var insertedBuf = Buffer.from("");
|
||||
longraw_bindin(insertedBuf, proc_bindin_exec, done);
|
||||
it('132.1.3 works with empty buffer', async function() {
|
||||
const insertedBuf = Buffer.from("");
|
||||
await longraw_bindin(insertedBuf, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('132.1.4 works with data size 2000', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(2000);
|
||||
longraw_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('132.1.4 works with data size 2000', async function() {
|
||||
const insertedStr = random.getRandomLengthString(2000);
|
||||
await longraw_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('132.1.5 works with data size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(32767);
|
||||
longraw_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('132.1.5 works with data size (32K - 1)', async function() {
|
||||
const insertedStr = random.getRandomLengthString(32767);
|
||||
await longraw_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('132.1.6 set maxSize to size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
longraw_bindin_maxSize(insertedStr, proc_bindin_exec, 32767, done);
|
||||
it('132.1.6 set maxSize to size (32K - 1)', async function() {
|
||||
const insertedStr = random.getRandomLengthString(100);
|
||||
await longraw_bindin_maxSize(insertedStr, proc_bindin_exec, 32767);
|
||||
});
|
||||
|
||||
it('132.1.7 set maxSize to size 1GB', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
var maxsize = 1 * 1024 * 1024 * 1024;
|
||||
longraw_bindin_maxSize(insertedStr, proc_bindin_exec, maxsize, done);
|
||||
it('132.1.7 set maxSize to size 1GB', async function() {
|
||||
const insertedStr = random.getRandomLengthString(100);
|
||||
const maxsize = 1 * 1024 * 1024 * 1024;
|
||||
await longraw_bindin_maxSize(insertedStr, proc_bindin_exec, maxsize);
|
||||
});
|
||||
|
||||
}); // 132.1
|
||||
|
||||
describe('132.2 PLSQL PROCEDURE BIND IN AS RAW', function() {
|
||||
var proc_bindin_name = "nodb_longraw_bindin_proc_2";
|
||||
var proc_bindin_create = "CREATE OR REPLACE PROCEDURE " + proc_bindin_name + " (NUM IN NUMBER, C IN RAW) \n" +
|
||||
const proc_bindin_name = "nodb_longraw_bindin_proc_2";
|
||||
const proc_bindin_create = "CREATE OR REPLACE PROCEDURE " + proc_bindin_name + " (NUM IN NUMBER, C IN RAW) \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " values (NUM, C); \n" +
|
||||
"END " + proc_bindin_name + ";";
|
||||
var proc_bindin_exec = "BEGIN " + proc_bindin_name + " (:i, :c); END;";
|
||||
var proc_bindin_drop = "DROP PROCEDURE " + proc_bindin_name;
|
||||
const proc_bindin_exec = "BEGIN " + proc_bindin_name + " (:i, :c); END;";
|
||||
const proc_bindin_drop = "DROP PROCEDURE " + proc_bindin_name;
|
||||
|
||||
before(function(done) {
|
||||
sql.executeSql(connection, proc_bindin_create, {}, {}, done);
|
||||
before(async function() {
|
||||
await connection.execute(proc_bindin_create);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
sql.executeSql(connection, proc_bindin_drop, {}, {}, done);
|
||||
after(async function() {
|
||||
await connection.execute(proc_bindin_drop);
|
||||
});
|
||||
|
||||
it('132.2.1 works with NULL', function(done) {
|
||||
var insertedStr = null;
|
||||
longraw_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('132.2.1 works with NULL', async function() {
|
||||
const insertedStr = null;
|
||||
await longraw_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('132.2.2 works with undefined', function(done) {
|
||||
var insertedStr = undefined;
|
||||
longraw_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('132.2.2 works with undefined', async function() {
|
||||
const insertedStr = undefined;
|
||||
await longraw_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('132.2.3 works with empty buffer', function(done) {
|
||||
var insertedStr = Buffer.from("");
|
||||
longraw_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('132.2.3 works with empty buffer', async function() {
|
||||
const insertedStr = Buffer.from("");
|
||||
await longraw_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('132.2.4 works with data size 2000', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(2000);
|
||||
longraw_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('132.2.4 works with data size 2000', async function() {
|
||||
const insertedStr = random.getRandomLengthString(2000);
|
||||
await longraw_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('132.2.5 works with data size 32767', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(32767);
|
||||
longraw_bindin(insertedStr, proc_bindin_exec, done);
|
||||
it('132.2.5 works with data size 32767', async function() {
|
||||
const insertedStr = random.getRandomLengthString(32767);
|
||||
await longraw_bindin(insertedStr, proc_bindin_exec);
|
||||
});
|
||||
|
||||
it('132.2.6 set maxSize to size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
longraw_bindin_maxSize(insertedStr, proc_bindin_exec, 32767, done);
|
||||
it('132.2.6 set maxSize to size (32K - 1)', async function() {
|
||||
const insertedStr = random.getRandomLengthString(100);
|
||||
await longraw_bindin_maxSize(insertedStr, proc_bindin_exec, 32767);
|
||||
});
|
||||
|
||||
it('132.2.7 set maxSize to size 1GB', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
var maxsize = 1 * 1024 * 1024 * 1024;
|
||||
longraw_bindin_maxSize(insertedStr, proc_bindin_exec, maxsize, done);
|
||||
it('132.2.7 set maxSize to size 1GB', async function() {
|
||||
const insertedStr = random.getRandomLengthString(100);
|
||||
const maxsize = 1 * 1024 * 1024 * 1024;
|
||||
await longraw_bindin_maxSize(insertedStr, proc_bindin_exec, maxsize);
|
||||
});
|
||||
|
||||
}); // 132.2
|
||||
|
||||
var longraw_bindin = function(insertContent, proc_bindin_exec, callback) {
|
||||
var insertBuf, expectedBuf;
|
||||
const longraw_bindin = async function(insertContent, proc_bindin_exec) {
|
||||
let insertBuf, expectedBuf;
|
||||
if (insertContent == null || insertContent == undefined || insertContent.length == 0) {
|
||||
insertBuf = insertContent;
|
||||
expectedBuf = null;
|
||||
|
@ -209,29 +189,19 @@ describe('132. longrawProcedureBind_in.js', function() {
|
|||
insertBuf = Buffer.from(insertContent);
|
||||
expectedBuf = insertBuf;
|
||||
}
|
||||
async.series([
|
||||
function(cb) {
|
||||
var bind_in_var = {
|
||||
i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { val: insertBuf, dir: oracledb.BIND_IN, type: oracledb.BUFFER }
|
||||
};
|
||||
connection.execute(
|
||||
proc_bindin_exec,
|
||||
bind_in_var,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
checkResult(expectedBuf, cb);
|
||||
}
|
||||
], callback);
|
||||
|
||||
const bind_in_var = {
|
||||
i: { val: insertID, dir: await oracledb.BIND_IN, type: await oracledb.NUMBER },
|
||||
c: { val: insertBuf, dir: await oracledb.BIND_IN, type: await oracledb.BUFFER }
|
||||
};
|
||||
await connection.execute(
|
||||
proc_bindin_exec,
|
||||
bind_in_var);
|
||||
await checkResult(expectedBuf);
|
||||
};
|
||||
|
||||
var longraw_bindin_maxSize = function(insertContent, proc_bindin_exec, maxsize, callback) {
|
||||
var insertBuf, expectedBuf;
|
||||
const longraw_bindin_maxSize = async function(insertContent, proc_bindin_exec, maxsize) {
|
||||
let insertBuf, expectedBuf;
|
||||
if (insertContent == null || insertContent == undefined) {
|
||||
insertBuf = insertContent;
|
||||
expectedBuf = null;
|
||||
|
@ -239,42 +209,27 @@ describe('132. longrawProcedureBind_in.js', function() {
|
|||
insertBuf = Buffer.from(insertContent);
|
||||
expectedBuf = insertBuf;
|
||||
}
|
||||
async.series([
|
||||
function(cb) {
|
||||
var bind_in_var = {
|
||||
i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { val: insertBuf, dir: oracledb.BIND_IN, type: oracledb.BUFFER, maxSize: maxsize }
|
||||
};
|
||||
connection.execute(
|
||||
proc_bindin_exec,
|
||||
bind_in_var,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
checkResult(expectedBuf, cb);
|
||||
}
|
||||
], callback);
|
||||
|
||||
const bind_in_var = {
|
||||
i: { val: insertID, dir: await oracledb.BIND_IN, type: await oracledb.NUMBER },
|
||||
c: { val: insertBuf, dir: await oracledb.BIND_IN, type: await oracledb.BUFFER, maxSize: maxsize }
|
||||
};
|
||||
await connection.execute(
|
||||
proc_bindin_exec,
|
||||
bind_in_var);
|
||||
await checkResult(expectedBuf);
|
||||
};
|
||||
|
||||
var checkResult = function(expected, callback) {
|
||||
connection.execute(
|
||||
"select * from " + tableName + " where id = " + insertID,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rows[0][0], insertID);
|
||||
if (expected == null) {
|
||||
should.strictEqual(result.rows[0][1], expected);
|
||||
} else {
|
||||
assist.compare2Buffers(result.rows[0][1], expected);
|
||||
}
|
||||
callback();
|
||||
}
|
||||
);
|
||||
};
|
||||
const checkResult = async function(expected) {
|
||||
const result = await connection.execute(
|
||||
"select * from " + tableName + " where id = " + insertID);
|
||||
|
||||
assert.strictEqual(result.rows[0][0], insertID);
|
||||
if (expected == null) {
|
||||
assert.strictEqual(result.rows[0][1], expected);
|
||||
} else {
|
||||
assist.compare2Buffers(result.rows[0][1], expected);
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -33,185 +33,166 @@
|
|||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const should = require('should');
|
||||
const async = require('async');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const random = require('./random.js');
|
||||
const sql = require('./sql.js');
|
||||
const testsUtil = require('./testsUtil.js');
|
||||
const assist = require('./dataTypeAssist.js');
|
||||
|
||||
describe('134. longrawProcedureBind_out.js', function() {
|
||||
|
||||
var connection = null;
|
||||
let connection = null;
|
||||
const tableName = "nodb_longraw_134";
|
||||
var insertID = 0;
|
||||
let insertID = 0;
|
||||
|
||||
before(function(done) {
|
||||
before(async function() {
|
||||
const sqlCreate = `
|
||||
CREATE TABLE ${tableName} (
|
||||
id NUMBER,
|
||||
content LONG RAW
|
||||
)`;
|
||||
const sqlCreateTbl = testsUtil.sqlCreateTable(tableName, sqlCreate);
|
||||
async.series([
|
||||
function(cb) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function(cb) {
|
||||
sql.executeSql(connection, sqlCreateTbl, {}, {}, cb);
|
||||
}
|
||||
], done);
|
||||
const sqlCreateTbl = await testsUtil.sqlCreateTable(tableName, sqlCreate);
|
||||
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
await connection.execute(sqlCreateTbl);
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
const sqlDropTbl = testsUtil.sqlDropTable(tableName);
|
||||
async.series([
|
||||
function(cb) {
|
||||
sql.executeSql(connection, sqlDropTbl, {}, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
after(async function() {
|
||||
const sqlDropTbl = await testsUtil.sqlDropTable(tableName);
|
||||
|
||||
await connection.execute(sqlDropTbl);
|
||||
|
||||
await connection.close();
|
||||
}); // after
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function() {
|
||||
insertID++;
|
||||
done();
|
||||
});
|
||||
|
||||
describe('134.1 PLSQL PROCEDURE BIND OUT AS LONG RAW', function() {
|
||||
var proc_bindout_name = "nodb_longraw_bindout_proc_1";
|
||||
var proc_bindout_create = "CREATE OR REPLACE PROCEDURE " + proc_bindout_name + " (NUM IN NUMBER, C OUT LONG RAW) \n" +
|
||||
const proc_bindout_name = "nodb_longraw_bindout_proc_1";
|
||||
const proc_bindout_create = "CREATE OR REPLACE PROCEDURE " + proc_bindout_name + " (NUM IN NUMBER, C OUT LONG RAW) \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" select content into C from " + tableName + " where id = NUM; \n" +
|
||||
"END " + proc_bindout_name + ";";
|
||||
var proc_bindout_exec = "BEGIN " + proc_bindout_name + " (:i, :c); END;";
|
||||
var proc_bindout_drop = "DROP PROCEDURE " + proc_bindout_name;
|
||||
const proc_bindout_exec = "BEGIN " + proc_bindout_name + " (:i, :c); END;";
|
||||
const proc_bindout_drop = "DROP PROCEDURE " + proc_bindout_name;
|
||||
|
||||
before(function(done) {
|
||||
sql.executeSql(connection, proc_bindout_create, {}, {}, done);
|
||||
before(async function() {
|
||||
await connection.execute(proc_bindout_create);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
sql.executeSql(connection, proc_bindout_drop, {}, {}, done);
|
||||
after(async function() {
|
||||
await connection.execute(proc_bindout_drop);
|
||||
});
|
||||
|
||||
it('134.1.1 works with NULL', function(done) {
|
||||
var insertedStr = null;
|
||||
var maxsize = 10;
|
||||
longraw_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
it('134.1.1 works with NULL', async function() {
|
||||
const insertedStr = null;
|
||||
const maxsize = 10;
|
||||
await longraw_bindout(insertedStr, proc_bindout_exec, maxsize);
|
||||
});
|
||||
|
||||
it('134.1.2 works with undefined', function(done) {
|
||||
var insertedStr = undefined;
|
||||
var maxsize = 10;
|
||||
longraw_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
it('134.1.2 works with undefined', async function() {
|
||||
const insertedStr = undefined;
|
||||
const maxsize = 10;
|
||||
await longraw_bindout(insertedStr, proc_bindout_exec, maxsize);
|
||||
});
|
||||
|
||||
it('134.1.3 works with empty buffer', function(done) {
|
||||
var insertedBuf = Buffer.from("");
|
||||
var maxsize = 10;
|
||||
longraw_bindout(insertedBuf, proc_bindout_exec, maxsize, done);
|
||||
it('134.1.3 works with empty buffer', async function() {
|
||||
const insertedBuf = Buffer.from("");
|
||||
const maxsize = 10;
|
||||
await longraw_bindout(insertedBuf, proc_bindout_exec, maxsize);
|
||||
});
|
||||
|
||||
it('134.1.4 works with data size 2000', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(2000);
|
||||
var maxsize = insertedStr.length;
|
||||
longraw_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
it('134.1.4 works with data size 2000', async function() {
|
||||
const insertedStr = random.getRandomLengthString(2000);
|
||||
const maxsize = insertedStr.length;
|
||||
await longraw_bindout(insertedStr, proc_bindout_exec, maxsize);
|
||||
});
|
||||
|
||||
it('134.1.5 works with data size 32760', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(32760);
|
||||
var maxsize = insertedStr.length;
|
||||
longraw_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
it('134.1.5 works with data size 32760', async function() {
|
||||
const insertedStr = random.getRandomLengthString(32760);
|
||||
const maxsize = insertedStr.length;
|
||||
await longraw_bindout(insertedStr, proc_bindout_exec, maxsize);
|
||||
});
|
||||
|
||||
it('134.1.6 set maxSize to size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
longraw_bindout(insertedStr, proc_bindout_exec, 32767, done);
|
||||
it('134.1.6 set maxSize to size (32K - 1)', async function() {
|
||||
const insertedStr = random.getRandomLengthString(100);
|
||||
await longraw_bindout(insertedStr, proc_bindout_exec, 32767);
|
||||
});
|
||||
|
||||
it('134.1.7 set maxSize to size 1GB', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
var maxsize = 1 * 1024 * 1024 * 1024;
|
||||
longraw_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
it('134.1.7 set maxSize to size 1GB', async function() {
|
||||
const insertedStr = random.getRandomLengthString(100);
|
||||
const maxsize = 1 * 1024 * 1024 * 1024;
|
||||
await longraw_bindout(insertedStr, proc_bindout_exec, maxsize);
|
||||
});
|
||||
|
||||
}); // 134.1
|
||||
|
||||
describe('134.2 PLSQL PROCEDURE BIND OUT AS RAW', function() {
|
||||
var proc_bindout_name = "nodb_longraw_bindout_proc_2";
|
||||
var proc_bindout_create = "CREATE OR REPLACE PROCEDURE " + proc_bindout_name + " (NUM IN NUMBER, C OUT RAW) \n" +
|
||||
const proc_bindout_name = "nodb_longraw_bindout_proc_2";
|
||||
const proc_bindout_create = "CREATE OR REPLACE PROCEDURE " + proc_bindout_name + " (NUM IN NUMBER, C OUT RAW) \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" select content into C from " + tableName + " where id = NUM; \n" +
|
||||
"END " + proc_bindout_name + ";";
|
||||
var proc_bindout_exec = "BEGIN " + proc_bindout_name + " (:i, :c); END;";
|
||||
var proc_bindout_drop = "DROP PROCEDURE " + proc_bindout_name;
|
||||
const proc_bindout_exec = "BEGIN " + proc_bindout_name + " (:i, :c); END;";
|
||||
const proc_bindout_drop = "DROP PROCEDURE " + proc_bindout_name;
|
||||
|
||||
before(function(done) {
|
||||
sql.executeSql(connection, proc_bindout_create, {}, {}, done);
|
||||
before(async function() {
|
||||
await connection.execute(proc_bindout_create);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
sql.executeSql(connection, proc_bindout_drop, {}, {}, done);
|
||||
after(async function() {
|
||||
await connection.execute(proc_bindout_drop);
|
||||
});
|
||||
|
||||
it('134.2.1 works with NULL', function(done) {
|
||||
var insertedStr = null;
|
||||
var maxsize = 10;
|
||||
longraw_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
it('134.2.1 works with NULL', async function() {
|
||||
const insertedStr = null;
|
||||
const maxsize = 10;
|
||||
await longraw_bindout(insertedStr, proc_bindout_exec, maxsize);
|
||||
});
|
||||
|
||||
it('134.2.2 works with undefined', function(done) {
|
||||
var insertedStr = undefined;
|
||||
var maxsize = 10;
|
||||
longraw_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
it('134.2.2 works with undefined', async function() {
|
||||
const insertedStr = undefined;
|
||||
const maxsize = 10;
|
||||
await longraw_bindout(insertedStr, proc_bindout_exec, maxsize);
|
||||
});
|
||||
|
||||
it('134.2.3 works with empty buffer', function(done) {
|
||||
var insertedStr = Buffer.from("");
|
||||
var maxsize = 10;
|
||||
longraw_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
it('134.2.3 works with empty buffer', async function() {
|
||||
const insertedStr = Buffer.from("");
|
||||
const maxsize = 10;
|
||||
await longraw_bindout(insertedStr, proc_bindout_exec, maxsize);
|
||||
});
|
||||
|
||||
it('134.2.4 works with data size 2000', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(2000);
|
||||
var maxsize = insertedStr.length;
|
||||
longraw_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
it('134.2.4 works with data size 2000', async function() {
|
||||
const insertedStr = random.getRandomLengthString(2000);
|
||||
const maxsize = insertedStr.length;
|
||||
await longraw_bindout(insertedStr, proc_bindout_exec, maxsize);
|
||||
});
|
||||
|
||||
it('134.2.5 works with data size 32760', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(32760);
|
||||
var maxsize = insertedStr.length;
|
||||
longraw_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
it('134.2.5 works with data size 32760', async function() {
|
||||
const insertedStr = random.getRandomLengthString(32760);
|
||||
const maxsize = insertedStr.length;
|
||||
await longraw_bindout(insertedStr, proc_bindout_exec, maxsize);
|
||||
});
|
||||
|
||||
it('134.2.6 set maxSize to size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
longraw_bindout(insertedStr, proc_bindout_exec, 32767, done);
|
||||
it('134.2.6 set maxSize to size (32K - 1)', async function() {
|
||||
const insertedStr = random.getRandomLengthString(100);
|
||||
await longraw_bindout(insertedStr, proc_bindout_exec, 32767);
|
||||
});
|
||||
|
||||
it('134.2.7 set maxSize to size 1GB', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
var maxsize = 1 * 1024 * 1024 * 1024;
|
||||
longraw_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
it('134.2.7 set maxSize to size 1GB', async function() {
|
||||
const insertedStr = random.getRandomLengthString(100);
|
||||
const maxsize = 1 * 1024 * 1024 * 1024;
|
||||
await longraw_bindout(insertedStr, proc_bindout_exec, maxsize);
|
||||
});
|
||||
|
||||
}); // 134.2
|
||||
|
||||
var longraw_bindout = function(insertContent, proc_bindout_exec, maxsize, callback) {
|
||||
var insertBuf, expectedBuf;
|
||||
const longraw_bindout = async function(insertContent, proc_bindout_exec, maxsize) {
|
||||
let insertBuf, expectedBuf;
|
||||
if (insertContent == null || insertContent == undefined || insertContent.length == 0) {
|
||||
insertBuf = insertContent;
|
||||
expectedBuf = null;
|
||||
|
@ -219,45 +200,32 @@ describe('134. longrawProcedureBind_out.js', function() {
|
|||
insertBuf = Buffer.from(insertContent);
|
||||
expectedBuf = insertBuf;
|
||||
}
|
||||
async.series([
|
||||
function(cb) {
|
||||
insert(insertBuf, cb);
|
||||
},
|
||||
function(cb) {
|
||||
var bind_in_var = {
|
||||
i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { type: oracledb.BUFFER, dir: oracledb.BIND_OUT, maxSize: maxsize }
|
||||
};
|
||||
connection.execute(
|
||||
proc_bindout_exec,
|
||||
bind_in_var,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
if (expectedBuf == null) {
|
||||
should.strictEqual(result.outBinds.c, expectedBuf);
|
||||
} else {
|
||||
assist.compare2Buffers(result.outBinds.c, expectedBuf);
|
||||
}
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], callback);
|
||||
|
||||
await insert(insertBuf);
|
||||
|
||||
const bind_in_var = {
|
||||
i: { val: insertID, dir: await oracledb.BIND_IN, type: await oracledb.NUMBER },
|
||||
c: { type: await oracledb.BUFFER, dir: await oracledb.BIND_OUT, maxSize: maxsize }
|
||||
};
|
||||
const result = await connection.execute(
|
||||
proc_bindout_exec,
|
||||
bind_in_var);
|
||||
|
||||
if (expectedBuf == null) {
|
||||
assert.strictEqual(result.outBinds.c, expectedBuf);
|
||||
} else {
|
||||
assist.compare2Buffers(result.outBinds.c, expectedBuf);
|
||||
}
|
||||
};
|
||||
|
||||
var insert = function(insertStr, callback) {
|
||||
connection.execute(
|
||||
const insert = async function(insertStr) {
|
||||
const result = await 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();
|
||||
}
|
||||
);
|
||||
i: { val: insertID, dir: await oracledb.BIND_IN, type: await oracledb.NUMBER },
|
||||
c: { val: insertStr, type: await oracledb.BUFFER, dir: await oracledb.BIND_IN }
|
||||
});
|
||||
assert.strictEqual(result.rowsAffected, 1);
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017, 2022, Oracle and/or its affiliates. */
|
||||
/* Copyright (c) 2017, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
|
@ -34,7 +34,6 @@
|
|||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sqlClone.js');
|
||||
|
||||
describe('109. rowidFunctionBindAsString_bind.js', function() {
|
||||
let connection = null;
|
||||
|
@ -62,17 +61,16 @@ describe('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
|
||||
before('get connection and create table', async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
await sql.executeSql(connection, fun_create_table, {}, {});
|
||||
await connection.execute(fun_create_table);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
await sql.executeSql(connection, drop_table, {}, {});
|
||||
await connection.execute(drop_table);
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function() {
|
||||
insertID++;
|
||||
done();
|
||||
});
|
||||
|
||||
describe('109.1 FUNCTION BIND_IN/OUT as rowid', function() {
|
||||
|
@ -88,11 +86,11 @@ describe('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
const fun_drop = "DROP FUNCTION nodb_rowid_bind";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, fun_create, {}, {});
|
||||
await connection.execute(fun_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, fun_drop, {}, {});
|
||||
await connection.execute(fun_drop);
|
||||
});
|
||||
|
||||
it('109.1.1 works with null', async function() {
|
||||
|
@ -114,12 +112,10 @@ describe('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_create, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_create, bindVar),
|
||||
/NJS-011:/ // 'NJS-011: encountered bind value and type mismatch'
|
||||
);
|
||||
});
|
||||
|
||||
it('109.1.5 works with extended rowid', async function() {
|
||||
|
@ -141,11 +137,10 @@ describe('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_create, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_create, bindVar),
|
||||
/NJS-011:/ // 'NJS-011: encountered bind value and type mismatch'
|
||||
);
|
||||
});
|
||||
|
||||
it('109.1.9 works with default bind type/dir - extended rowid', async function() {
|
||||
|
@ -170,20 +165,18 @@ describe('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_create, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_create, bindVar),
|
||||
/NJS-037:/ // 'NJS-037: invalid data type at array index 0 for bind ":c"'
|
||||
);
|
||||
});
|
||||
|
||||
it('109.1.14 bind error: NJS-052', async function() {
|
||||
const bindVar = [ { type: oracledb.STRING, dir: oracledb.BIND_OUT }, insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN } ];
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_create, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 3');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_create, bindVar),
|
||||
/NJS-052:/ // 'NJS-052: invalid data type at array index 0 for bind position 3'
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -201,11 +194,11 @@ describe('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
const fun_drop = "DROP FUNCTION nodb_rowid_bind";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, fun_create, {}, {});
|
||||
await connection.execute(fun_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, fun_drop, {}, {});
|
||||
await connection.execute(fun_drop);
|
||||
});
|
||||
|
||||
it('109.2.1 works with null', async function() {
|
||||
|
@ -227,11 +220,10 @@ describe('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_create, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_create, bindVar),
|
||||
/NJS-011:/ // 'NJS-011: encountered bind value and type mismatch'
|
||||
);
|
||||
});
|
||||
|
||||
it('109.2.5 works with extended rowid', async function() {
|
||||
|
@ -253,11 +245,10 @@ describe('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_create, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_create, bindVar),
|
||||
/NJS-011:/ // 'NJS-011: encountered bind value and type mismatch'
|
||||
);
|
||||
});
|
||||
|
||||
it('109.2.9 works with default bind type/dir - extended rowid', async function() {
|
||||
|
@ -282,20 +273,18 @@ describe('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_create, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_create, bindVar),
|
||||
/NJS-037:/ // 'NJS-037: invalid data type at array index 0 for bind ":c"'
|
||||
);
|
||||
});
|
||||
|
||||
it('109.2.14 bind error: NJS-052', async function() {
|
||||
const bindVar = [ { type: oracledb.STRING, dir: oracledb.BIND_OUT }, insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN } ];
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_create, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 3');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_create, bindVar),
|
||||
/NJS-052:/ // 'NJS-052: invalid data type at array index 0 for bind position 3'
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -314,11 +303,11 @@ describe('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
const fun_drop = "DROP FUNCTION nodb_rowid_bind_1083";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, fun_create, {}, {});
|
||||
await connection.execute(fun_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, fun_drop, {}, {});
|
||||
await connection.execute(fun_drop);
|
||||
});
|
||||
|
||||
it('109.3.1 update null with rowid', async function() {
|
||||
|
@ -399,7 +388,6 @@ describe('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
assert(result);
|
||||
const resultVal = result.outBinds.o;
|
||||
assert.strictEqual(resultVal, expected);
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017, 2022, Oracle and/or its affiliates. */
|
||||
/* Copyright (c) 2017, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
|
@ -29,12 +29,12 @@
|
|||
* Testing rowid plsql bind as String.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sqlClone.js');
|
||||
|
||||
describe('112. rowidFunctionBindAsString_bindinout.js', function() {
|
||||
let connection = null;
|
||||
|
@ -62,17 +62,16 @@ describe('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
|
||||
before('get connection and create table', async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
await sql.executeSql(connection, fun_create_table, {}, {});
|
||||
await connection.execute(fun_create_table);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
await sql.executeSql(connection, drop_table, {}, {});
|
||||
await connection.execute(drop_table);
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function() {
|
||||
insertID++;
|
||||
done();
|
||||
});
|
||||
|
||||
describe('112.1 FUNCTION BIND_INOUT as rowid', function() {
|
||||
|
@ -89,11 +88,11 @@ describe('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
const fun_drop = "DROP FUNCTION nodb_rowid_bind_inout_1121";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, fun_create, {}, {});
|
||||
await connection.execute(fun_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, fun_drop, {}, {});
|
||||
await connection.execute(fun_drop);
|
||||
});
|
||||
|
||||
it('112.1.1 works with null', async function() {
|
||||
|
@ -115,11 +114,10 @@ describe('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_create, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_create, bindVar),
|
||||
/NJS-011:/ // 'NJS-011: encountered bind value and type mismatch'
|
||||
);
|
||||
});
|
||||
|
||||
it('112.1.5 works with extended rowid', async function() {
|
||||
|
@ -141,11 +139,10 @@ describe('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_create, bindVar),
|
||||
/NJS-011:/ // 'NJS-011: encountered bind value and type mismatch'
|
||||
);
|
||||
});
|
||||
|
||||
it('112.1.9 works with default bind type/dir - extended rowid', async function() {
|
||||
|
@ -170,20 +167,18 @@ describe('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_create, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_create, bindVar),
|
||||
/NJS-037:/ // 'NJS-037: invalid data type at array index 0 for bind ":c"'
|
||||
);
|
||||
});
|
||||
|
||||
it('112.1.14 bind error: NJS-052', async function() {
|
||||
const bindVar = [ { type: oracledb.STRING, dir: oracledb.BIND_OUT }, insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 } ];
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_create, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 3');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_create, bindVar),
|
||||
/NJS-052:/ // 'NJS-052: invalid data type at array index 0 for bind position 3'
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -202,11 +197,11 @@ describe('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
const fun_drop = "DROP FUNCTION nodb_rowid_bind_inout_1121";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, fun_create, {}, {});
|
||||
await connection.execute(fun_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, fun_drop, {}, {});
|
||||
await connection.execute(fun_drop);
|
||||
});
|
||||
|
||||
it('112.2.1 works with null', async function() {
|
||||
|
@ -228,11 +223,10 @@ describe('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_create, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_create, bindVar),
|
||||
/NJS-011:/ // 'NJS-011: encountered bind value and type mismatch'
|
||||
);
|
||||
});
|
||||
|
||||
it('112.2.5 works with extended rowid', async function() {
|
||||
|
@ -254,11 +248,10 @@ describe('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_create, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_create, bindVar),
|
||||
/NJS-011:/ // 'NJS-011: encountered bind value and type mismatch'
|
||||
);
|
||||
});
|
||||
|
||||
it('112.2.9 works with default bind type/dir - extended rowid', async function() {
|
||||
|
@ -283,20 +276,18 @@ describe('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_create, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_create, bindVar),
|
||||
/NJS-037:/ // 'NJS-037: invalid data type at array index 0 for bind ":c"'
|
||||
);
|
||||
});
|
||||
|
||||
it('112.2.14 bind error: NJS-052', async function() {
|
||||
const bindVar = [ { type: oracledb.STRING, dir: oracledb.BIND_OUT }, insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 } ];
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 3');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_create, bindVar),
|
||||
/NJS-052:/ // 'NJS-052: invalid data type at array index 0 for bind position 3'
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -316,11 +307,11 @@ describe('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
const fun_drop = "DROP FUNCTION nodb_rowid_bind_1083";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, fun_create, {}, {});
|
||||
await connection.execute(fun_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, fun_drop, {}, {});
|
||||
await connection.execute(fun_drop);
|
||||
});
|
||||
|
||||
it('112.3.1 update null with rowid', async function() {
|
||||
|
@ -408,7 +399,6 @@ describe('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
const resultVal_2 = result.outBinds.o;
|
||||
assert.strictEqual(resultVal_2, expected);
|
||||
assert.strictEqual(resultVal_1, "AAACiZAAFAAAAJEAAA");
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017, 2022, Oracle and/or its affiliates. */
|
||||
/* Copyright (c) 2017, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
|
@ -29,12 +29,12 @@
|
|||
* Testing rowid plsql bind as String.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sqlClone.js');
|
||||
|
||||
describe('111. rowidProcedureBindAsString_bindinout.js', function() {
|
||||
let connection = null;
|
||||
|
@ -62,17 +62,16 @@ describe('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
|
||||
before('get connection and create table', async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
sql.executeSql(connection, proc_create_table, {}, {});
|
||||
await connection.execute(proc_create_table);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
await sql.executeSql(connection, drop_table, {}, {});
|
||||
await connection.execute(drop_table);
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function() {
|
||||
insertID++;
|
||||
done();
|
||||
});
|
||||
|
||||
describe('111.1 PROCEDURE BIND_INOUT as rowid', function() {
|
||||
|
@ -86,11 +85,11 @@ describe('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_rowid_bind_inout";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('111.1.1 works with null', async function() {
|
||||
|
@ -111,11 +110,10 @@ describe('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 1000 }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/ // 'NJS-011: encountered bind value and type mismatch'
|
||||
);
|
||||
});
|
||||
|
||||
it('111.1.5 works with extended rowid', async function() {
|
||||
|
@ -137,11 +135,10 @@ describe('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 1000 }
|
||||
};
|
||||
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/ // 'NJS-011: encountered bind value and type mismatch'
|
||||
);
|
||||
});
|
||||
|
||||
it('111.1.9 works with default bind type/dir - extended rowid', async function() {
|
||||
|
@ -165,20 +162,19 @@ describe('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-037:/ // 'NJS-037: invalid data type at array index 0 for bind ":c"'
|
||||
);
|
||||
});
|
||||
|
||||
it('111.1.14 bind error: NJS-052', async function() {
|
||||
const bindVar = [ insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 }];
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 2');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-052:/ // 'invalid data type at array index 0 for bind position 2'
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -194,11 +190,11 @@ describe('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_rowid_bind_inout";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('111.2.1 works with null', async function() {
|
||||
|
@ -219,11 +215,11 @@ describe('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/ // 'NJS-011: encountered bind value and type mismatch'
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
it('111.2.5 works with extended rowid', async function() {
|
||||
|
@ -244,11 +240,10 @@ describe('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/ // 'NJS-011: encountered bind value and type mismatch'
|
||||
);
|
||||
});
|
||||
|
||||
it('111.2.9 works with default bind type/dir - extended rowid', async function() {
|
||||
|
@ -272,21 +267,18 @@ describe('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-037:/ // 'NJS-037: invalid data type at array index 0 for bind ":c"'
|
||||
);
|
||||
});
|
||||
|
||||
it('111.2.14 bind error: NJS-052', async function() {
|
||||
const bindVar = [ insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 }];
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 2');
|
||||
}
|
||||
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-052:/ // 'NJS-052: invalid data type at array index 0 for bind position 2'
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -303,11 +295,11 @@ describe('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_rowid_bind_1083";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('111.3.1 update null with rowid', async function() {
|
||||
|
@ -384,4 +376,5 @@ describe('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
const resultVal = result.outBinds.c2;
|
||||
assert.strictEqual(resultVal, expected);
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017, 2022, Oracle and/or its affiliates. */
|
||||
/* Copyright (c) 2017, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
|
@ -29,19 +29,19 @@
|
|||
* Testing rowid plsql bind as String.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sqlClone.js');
|
||||
|
||||
describe('110. rowidProcedureBindAsString_bindout.js', function() {
|
||||
let connection = null;
|
||||
let tableName = "nodb_rowid_plsql_out";
|
||||
const tableName = "nodb_rowid_plsql_out";
|
||||
let insertID = 1;
|
||||
|
||||
let proc_create_table = "BEGIN \n" +
|
||||
const proc_create_table = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n" +
|
||||
|
@ -58,42 +58,39 @@ describe('110. rowidProcedureBindAsString_bindout.js', function() {
|
|||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
let drop_table = "DROP TABLE " + tableName + " PURGE";
|
||||
const drop_table = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
before('get connection and create table', async function() {
|
||||
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
assert(connection);
|
||||
await sql.executeSql(connection, proc_create_table, {}, {});
|
||||
await connection.execute(proc_create_table);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
|
||||
await sql.executeSql(connection, drop_table, {}, {});
|
||||
await connection.execute(drop_table);
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
beforeEach(function() {
|
||||
insertID++;
|
||||
|
||||
});
|
||||
|
||||
describe('110.1 PROCEDURE BIND_OUT as rowid', function() {
|
||||
let proc_create = "CREATE OR REPLACE PROCEDURE nodb_rowid_bind_out (id_in IN NUMBER, content_in IN ROWID, content_out OUT ROWID)\n" +
|
||||
const proc_create = "CREATE OR REPLACE PROCEDURE nodb_rowid_bind_out (id_in IN NUMBER, content_in IN ROWID, content_out OUT ROWID)\n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " (id, content) values (id_in, CHARTOROWID(content_in)); \n" +
|
||||
" select content into content_out from " + tableName + " where id = id_in; \n" +
|
||||
"END nodb_rowid_bind_out; ";
|
||||
let proc_execute = "BEGIN nodb_rowid_bind_out (:i, :c, :o); END;";
|
||||
let proc_drop = "DROP PROCEDURE nodb_rowid_bind_out";
|
||||
const proc_execute = "BEGIN nodb_rowid_bind_out (:i, :c, :o); END;";
|
||||
const proc_drop = "DROP PROCEDURE nodb_rowid_bind_out";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('110.1.1 works with null', async function() {
|
||||
|
@ -109,16 +106,14 @@ describe('110. rowidProcedureBindAsString_bindout.js', function() {
|
|||
});
|
||||
|
||||
it('110.1.4 works with NaN', async function() {
|
||||
let content = NaN;
|
||||
let bindVar = {
|
||||
const content = NaN;
|
||||
const 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 }
|
||||
};
|
||||
await assert.rejects(
|
||||
async () => {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
},
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
@ -136,16 +131,14 @@ describe('110. rowidProcedureBindAsString_bindout.js', function() {
|
|||
});
|
||||
|
||||
it('110.1.8 works with number 0', async function() {
|
||||
let content = 0;
|
||||
let bindVar = {
|
||||
const content = 0;
|
||||
const 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 }
|
||||
};
|
||||
await assert.rejects(
|
||||
async () => {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
},
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
@ -167,25 +160,21 @@ describe('110. rowidProcedureBindAsString_bindout.js', function() {
|
|||
});
|
||||
|
||||
it('110.1.13 bind error: NJS-037', async function() {
|
||||
let bindVar = {
|
||||
const bindVar = {
|
||||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
await assert.rejects(
|
||||
async () => {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
},
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-037:/
|
||||
);
|
||||
});
|
||||
|
||||
it('110.1.14 bind error: NJS-052', async function() {
|
||||
let bindVar = [ insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN }, { type: oracledb.STRING, dir: oracledb.BIND_OUT } ];
|
||||
const bindVar = [ insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN }, { type: oracledb.STRING, dir: oracledb.BIND_OUT } ];
|
||||
await assert.rejects(
|
||||
async () => {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
},
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-052:/
|
||||
);
|
||||
});
|
||||
|
@ -193,21 +182,21 @@ describe('110. rowidProcedureBindAsString_bindout.js', function() {
|
|||
});
|
||||
|
||||
describe('110.2 PROCEDURE BIND_OUT as string', function() {
|
||||
let proc_create = "CREATE OR REPLACE PROCEDURE nodb_rowid_bind_out (id_in IN NUMBER, content_in IN ROWID, content_out OUT VARCHAR2)\n" +
|
||||
const proc_create = "CREATE OR REPLACE PROCEDURE nodb_rowid_bind_out (id_in IN NUMBER, content_in IN ROWID, content_out OUT VARCHAR2)\n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " (id, content) values (id_in, CHARTOROWID(content_in)); \n" +
|
||||
" select content into content_out from " + tableName + " where id = id_in; \n" +
|
||||
"END nodb_rowid_bind_out; ";
|
||||
let proc_execute = "BEGIN nodb_rowid_bind_out (:i, :c, :o); END;";
|
||||
let proc_drop = "DROP PROCEDURE nodb_rowid_bind_out";
|
||||
const proc_execute = "BEGIN nodb_rowid_bind_out (:i, :c, :o); END;";
|
||||
const proc_drop = "DROP PROCEDURE nodb_rowid_bind_out";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('110.2.1 works with null', async function() {
|
||||
|
@ -223,16 +212,14 @@ describe('110. rowidProcedureBindAsString_bindout.js', function() {
|
|||
});
|
||||
|
||||
it('110.2.4 works with NaN', async function() {
|
||||
let content = NaN;
|
||||
let bindVar = {
|
||||
const content = NaN;
|
||||
const 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 }
|
||||
};
|
||||
await assert.rejects(
|
||||
async () => {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
},
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
@ -250,16 +237,14 @@ describe('110. rowidProcedureBindAsString_bindout.js', function() {
|
|||
});
|
||||
|
||||
it('110.2.8 works with number 0', async function() {
|
||||
let content = 0;
|
||||
let bindVar = {
|
||||
const content = 0;
|
||||
const 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 }
|
||||
};
|
||||
await assert.rejects(
|
||||
async () => {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
},
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
@ -281,25 +266,21 @@ describe('110. rowidProcedureBindAsString_bindout.js', function() {
|
|||
});
|
||||
|
||||
it('110.2.13 bind error: NJS-037', async function() {
|
||||
let bindVar = {
|
||||
const bindVar = {
|
||||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
await assert.rejects(
|
||||
async () => {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
},
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-037:/
|
||||
);
|
||||
});
|
||||
|
||||
it('110.2.14 bind error: NJS-052', async function() {
|
||||
let bindVar = [ insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN }, { type: oracledb.STRING, dir: oracledb.BIND_OUT } ];
|
||||
const bindVar = [ insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN }, { type: oracledb.STRING, dir: oracledb.BIND_OUT } ];
|
||||
await assert.rejects(
|
||||
async () => {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
},
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-052:/
|
||||
);
|
||||
});
|
||||
|
@ -307,22 +288,22 @@ describe('110. rowidProcedureBindAsString_bindout.js', function() {
|
|||
});
|
||||
|
||||
describe('110.3 PROCEDURE BIND_IN, UPDATE', function() {
|
||||
let proc_create = "CREATE OR REPLACE PROCEDURE nodb_rowid_bind_1083 (id_in IN NUMBER, content_1 IN STRING, content_2 IN ROWID, content_out OUT ROWID)\n" +
|
||||
const proc_create = "CREATE OR REPLACE PROCEDURE nodb_rowid_bind_1083 (id_in IN NUMBER, content_1 IN STRING, content_2 IN ROWID, content_out OUT ROWID)\n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " (id, content) values (id_in, CHARTOROWID(content_1)); \n" +
|
||||
" update " + tableName + " set content = content_2 where id = id_in; \n" +
|
||||
" select content into content_out from " + tableName + " where id = id_in; \n" +
|
||||
"END nodb_rowid_bind_1083; ";
|
||||
let proc_execute = "BEGIN nodb_rowid_bind_1083 (:i, :c1, :c2, :o); END;";
|
||||
let proc_drop = "DROP PROCEDURE nodb_rowid_bind_1083";
|
||||
const proc_execute = "BEGIN nodb_rowid_bind_1083 (:i, :c1, :c2, :o); END;";
|
||||
const proc_drop = "DROP PROCEDURE nodb_rowid_bind_1083";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('110.3.1 update null with rowid', async function() {
|
||||
|
@ -355,50 +336,47 @@ describe('110. rowidProcedureBindAsString_bindout.js', function() {
|
|||
|
||||
});
|
||||
|
||||
let procedureBindOut = async function(proc_execute, content_in, expected) {
|
||||
let bindVar_out = {
|
||||
const procedureBindOut = async function(proc_execute, content_in, expected) {
|
||||
const 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 }
|
||||
};
|
||||
let result = await connection.execute(proc_execute, bindVar_out);
|
||||
assert(result);
|
||||
const result = await connection.execute(proc_execute, bindVar_out);
|
||||
assert.strictEqual(result.outBinds.o, expected);
|
||||
};
|
||||
|
||||
let procedureBindOut_default = async function(proc_execute, content_in, expected) {
|
||||
let bindVar_out = {
|
||||
const procedureBindOut_default = async function(proc_execute, content_in, expected) {
|
||||
const bindVar_out = {
|
||||
i: insertID,
|
||||
c: content_in,
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
let result = await connection.execute(proc_execute, bindVar_out);
|
||||
assert(result);
|
||||
const result = await connection.execute(proc_execute, bindVar_out);
|
||||
assert.strictEqual(result.outBinds.o, expected);
|
||||
};
|
||||
|
||||
let procedureBindOut_update = async function(proc_execute, content_1, content_2, expected) {
|
||||
let bindVar_in = {
|
||||
const procedureBindOut_update = async function(proc_execute, content_1, content_2, expected) {
|
||||
const 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 },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
let result = await connection.execute(proc_execute, bindVar_in);
|
||||
assert(result);
|
||||
const result = await connection.execute(proc_execute, bindVar_in);
|
||||
assert.strictEqual(result.outBinds.o, expected);
|
||||
};
|
||||
|
||||
let procedureBindOut_update_default = async function(proc_execute, content_1, content_2, expected) {
|
||||
let bindVar_in = {
|
||||
const procedureBindOut_update_default = async function(proc_execute, content_1, content_2, expected) {
|
||||
const bindVar_in = {
|
||||
i: insertID,
|
||||
c1: content_1,
|
||||
c2: content_2,
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
let result = await connection.execute(proc_execute, bindVar_in);
|
||||
assert(result);
|
||||
const result = await connection.execute(proc_execute, bindVar_in);
|
||||
assert.strictEqual(result.outBinds.o, expected);
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
|
|
30
test/sql.js
30
test/sql.js
|
@ -136,36 +136,6 @@ sql.executeSql = function(connection, sql, bindVar, option, callback) {
|
|||
);
|
||||
};
|
||||
|
||||
sql.executeInsert = function(connection, sql, bindVar, option, callback) {
|
||||
connection.execute(
|
||||
sql,
|
||||
bindVar,
|
||||
option,
|
||||
function(err, result) {
|
||||
if (err) {
|
||||
let stack = new Error().stack;
|
||||
console.error(err);
|
||||
console.error(stack);
|
||||
}
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
callback(err);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
sql.executeSqlWithErr = function(connection, sql, bindVar, option, callback) {
|
||||
connection.execute(
|
||||
sql,
|
||||
bindVar,
|
||||
option,
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
callback(err);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
sql.createRowid = function(connection, rowid_type, object_number, relative_fno, block_number, row_number, callback) {
|
||||
// Parameter Description
|
||||
// rowid_type Type (restricted or extended), set the rowid_type parameter to 0 for a restricted ROWID. Set it to 1 to create an extended ROWID.
|
||||
|
|
|
@ -143,26 +143,6 @@ sql.executeSql = async function(connection, sql, bindVar, option) {
|
|||
}
|
||||
};
|
||||
|
||||
sql.executeInsert = async function(connection, sql, bindVar, option) {
|
||||
try {
|
||||
const result = await connection.execute(sql, bindVar, option);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
} catch (err) {
|
||||
should.not.exist(err);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
sql.executeSqlWithErr = async function(connection, sql, bindVar, option) {
|
||||
try {
|
||||
await connection.execute(sql, bindVar, option);
|
||||
} catch (err) {
|
||||
should.exist(err);
|
||||
throw err;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
sql.createRowid = function(connection, rowid_type, object_number, relative_fno, block_number, row_number, callback) {
|
||||
// Parameter Description
|
||||
// rowid_type Type (restricted or extended), set the rowid_type parameter to 0 for a restricted ROWID. Set it to 1 to create an extended ROWID.
|
||||
|
|
|
@ -116,14 +116,10 @@ testsUtil.dropTable = async function(tableName) {
|
|||
|
||||
testsUtil.checkPrerequisites = async function(clientVersion = 1805000000, serverVersion = 1805000000) {
|
||||
if (testsUtil.getClientVersion() < clientVersion) return false;
|
||||
try {
|
||||
let connection = await oracledb.getConnection(dbConfig);
|
||||
if (connection.oracleServerVersion < serverVersion) return false;
|
||||
await connection.close();
|
||||
return true;
|
||||
} catch (err) {
|
||||
console.log('Error in checking prerequistes:\n', err);
|
||||
}
|
||||
const connection = await oracledb.getConnection(dbConfig);
|
||||
const version = connection.oracleServerVersion;
|
||||
await connection.close();
|
||||
return (version >= serverVersion);
|
||||
};
|
||||
|
||||
testsUtil.isSodaRunnable = async function() {
|
||||
|
@ -436,13 +432,10 @@ testsUtil.assertOneOf = function(array, value) {
|
|||
assert(matches);
|
||||
};
|
||||
|
||||
testsUtil.checkUrowidLength = async function(urowidLen, expectedLength) {
|
||||
const connection = await oracledb.getConnection(dbConfig);
|
||||
// The Oracle Cloud Database doesn't support UROWID and therefore a regular ROWID is returned which has a fixed size of 18 bytes.
|
||||
const UROWID_LENGTH_LIMIT_CLOUD_DB = 18;
|
||||
|
||||
if (dbConfig.test.isCloudService) assert(urowidLen > UROWID_LENGTH_LIMIT_CLOUD_DB - 1);
|
||||
else assert(urowidLen > expectedLength);
|
||||
|
||||
await connection.close();
|
||||
testsUtil.checkUrowidLength = function(urowidLen, expectedLength) {
|
||||
// The Oracle Cloud Database doesn't support UROWID and therefore a regular
|
||||
// ROWID is returned which has a fixed size of 18 bytes
|
||||
if (dbConfig.test.isCloudService)
|
||||
expectedLength = 18;
|
||||
assert(urowidLen >= expectedLength);
|
||||
};
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sqlClone.js');
|
||||
const random = require('./random.js');
|
||||
const testsUtil = require('./testsUtil.js');
|
||||
|
||||
|
@ -88,13 +87,13 @@ describe('115. urowidDMLBindAsString2.js', function() {
|
|||
|
||||
before('get connection and create table', async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
await sql.executeSql(connection, table_indexed, {}, {});
|
||||
await sql.executeSql(connection, table_normal, {}, {});
|
||||
await connection.execute(table_indexed);
|
||||
await connection.execute(table_normal);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
await sql.executeSql(connection, drop_table_indexed, {}, {});
|
||||
await sql.executeSql(connection, drop_table_normal, {}, {});
|
||||
await connection.execute(drop_table_indexed);
|
||||
await connection.execute(drop_table_normal);
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
|
@ -208,11 +207,11 @@ describe('115. urowidDMLBindAsString2.js', function() {
|
|||
let urowid, urowidLen;
|
||||
let result;
|
||||
const sql_insert = "insert into " + tableName_indexed + " values (" + insertID + ", '" + str + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + insertID);
|
||||
urowid = result.rows[0][0];
|
||||
urowidLen = urowid.length;
|
||||
testsUtil.checkUrowidLength(urowidLen, rowidLenExpected);
|
||||
await testsUtil.checkUrowidLength(urowidLen, rowidLenExpected);
|
||||
const bindVar = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : urowid, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
|
@ -261,11 +260,11 @@ describe('115. urowidDMLBindAsString2.js', function() {
|
|||
let urowid, urowidLen;
|
||||
let result;
|
||||
const sql_insert = "insert into " + tableName_indexed + " values (" + insertID + ", '" + str + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + insertID);
|
||||
urowid = result.rows[0][0];
|
||||
urowidLen = urowid.length;
|
||||
testsUtil.checkUrowidLength(urowidLen, rowidLenExpected);
|
||||
await testsUtil.checkUrowidLength(urowidLen, rowidLenExpected);
|
||||
const bindVar = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : urowid, dir : oracledb.BIND_IN, type : oracledb.STRING, maxSize: 100 }
|
||||
|
@ -318,23 +317,23 @@ describe('115. urowidDMLBindAsString2.js', function() {
|
|||
i: { val : id_1, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : rowid_org, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
await sql.executeInsert(connection, sql_insert, bindVar, {});
|
||||
await connection.execute(sql_insert, bindVar);
|
||||
|
||||
sql_insert = "insert into " + tableName_normal + " (ID, content) values (:i, :c)";
|
||||
bindVar = {
|
||||
i: { val : id_2, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : rowid_org, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
await sql.executeInsert(connection, sql_insert, bindVar, {});
|
||||
await connection.execute(sql_insert, bindVar);
|
||||
|
||||
sql_insert = "insert into " + tableName_indexed + " values (" + insertID + ", '" + str + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
|
||||
result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + insertID);
|
||||
|
||||
urowid = result.rows[0][0];
|
||||
urowidLen = urowid.length;
|
||||
testsUtil.checkUrowidLength(urowidLen, rowidLenExpected);
|
||||
await testsUtil.checkUrowidLength(urowidLen, rowidLenExpected);
|
||||
|
||||
bindVar = {
|
||||
c: { val : urowid, dir : oracledb.BIND_IN, type : oracledb.STRING },
|
||||
|
@ -348,7 +347,7 @@ describe('115. urowidDMLBindAsString2.js', function() {
|
|||
}
|
||||
}
|
||||
if (urowidLen <= 4000) {
|
||||
assert(result.rowsAffected, 1);
|
||||
assert.strictEqual(result.rowsAffected, 1);
|
||||
}
|
||||
|
||||
result = await connection.execute("select * from " + tableName_normal + " where ID = " + id_1);
|
||||
|
@ -385,17 +384,17 @@ describe('115. urowidDMLBindAsString2.js', function() {
|
|||
i: { val : id_1, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : rowid_org, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
await sql.executeInsert(connection, sql_insert, bindVar, {});
|
||||
await connection.execute(sql_insert, bindVar);
|
||||
|
||||
sql_insert = "insert into " + tableName_normal + " (ID, content) values (:i, :c)";
|
||||
bindVar = {
|
||||
i: { val : id_2, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : rowid_org, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
await sql.executeInsert(connection, sql_insert, bindVar, {});
|
||||
await connection.execute(sql_insert, bindVar);
|
||||
|
||||
sql_insert = "insert into " + tableName_indexed + " values (" + insertID + ", '" + str + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
|
||||
result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + insertID);
|
||||
assert(result);
|
||||
|
@ -434,7 +433,7 @@ describe('115. urowidDMLBindAsString2.js', function() {
|
|||
let urowid, urowidLen;
|
||||
let sql_insert, result, bindVar;
|
||||
sql_insert = "insert into " + tableName_indexed + " values (" + insertID + ", '" + str + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + insertID);
|
||||
assert(result);
|
||||
|
||||
|
@ -472,7 +471,7 @@ describe('115. urowidDMLBindAsString2.js', function() {
|
|||
let sql_insert, result, bindVar;
|
||||
|
||||
sql_insert = "insert into " + tableName_indexed + " values (" + insertID + ", '" + str + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
|
||||
result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + insertID);
|
||||
assert(result);
|
||||
|
@ -508,10 +507,10 @@ describe('115. urowidDMLBindAsString2.js', function() {
|
|||
oracledb.maxRows = maxRows;
|
||||
let sql_insert, result;
|
||||
sql_insert = "insert into " + tableName_indexed + " values (" + id_1 + ", '" + str + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
|
||||
sql_insert = "insert into " + tableName_indexed + " values (" + id_2 + ", '" + str + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + id_1);
|
||||
urowid_1 = result.rows[0][0];
|
||||
urowidLen_1 = urowid_1.length;
|
||||
|
@ -561,3 +560,4 @@ describe('115. urowidDMLBindAsString2.js', function() {
|
|||
};
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017, 2022, Oracle and/or its affiliates. */
|
||||
/* Copyright (c) 2017, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
|
@ -29,12 +29,12 @@
|
|||
* Testing UROWID(< 200 bytes) plsql function bind in/out as String.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sqlClone.js');
|
||||
|
||||
describe('121. urowidFunctionBindAsString1.js', function() {
|
||||
let connection = null;
|
||||
|
@ -62,11 +62,11 @@ describe('121. urowidFunctionBindAsString1.js', function() {
|
|||
|
||||
before('get connection and create table', async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
await sql.executeSql(connection, fun_create_table, {}, {});
|
||||
await connection.execute(fun_create_table);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
await sql.executeSql(connection, drop_table, {}, {});
|
||||
await connection.execute(drop_table);
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
|
@ -87,11 +87,11 @@ describe('121. urowidFunctionBindAsString1.js', function() {
|
|||
const fun_drop = "DROP FUNCTION nodb_rowid_bind";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, fun_create, {}, {});
|
||||
await connection.execute(fun_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, fun_drop, {}, {});
|
||||
await connection.execute(fun_drop);
|
||||
});
|
||||
|
||||
it('121.1.1 works with null', async function() {
|
||||
|
@ -112,11 +112,10 @@ describe('121. urowidFunctionBindAsString1.js', function() {
|
|||
c: { val: NaN, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_create, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_create, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('121.1.5 works with extended ROWID', async function() {
|
||||
|
@ -133,12 +132,10 @@ describe('121. urowidFunctionBindAsString1.js', function() {
|
|||
c: { val: "0", type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.equal(err.message.substring(0, 10), "ORA-01410:");
|
||||
// ORA-01410: invalid ROWID
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_execute, bindVar),
|
||||
/ORA-01410:/
|
||||
);
|
||||
});
|
||||
|
||||
it('121.1.8 works with number 0', async function() {
|
||||
|
@ -147,12 +144,10 @@ describe('121. urowidFunctionBindAsString1.js', function() {
|
|||
c: { val: 0, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('121.1.9 works with default bind type/dir - extended ROWID', async function() {
|
||||
|
@ -177,21 +172,18 @@ describe('121. urowidFunctionBindAsString1.js', function() {
|
|||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
}
|
||||
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_execute, bindVar),
|
||||
/NJS-037:/
|
||||
);
|
||||
});
|
||||
|
||||
it('121.1.14 bind error: NJS-052', async function() {
|
||||
const bindVar = [ { type: oracledb.STRING, dir: oracledb.BIND_OUT }, insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN } ];
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 3');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_execute, bindVar),
|
||||
/NJS-052:/
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -209,11 +201,11 @@ describe('121. urowidFunctionBindAsString1.js', function() {
|
|||
const fun_drop = "DROP FUNCTION nodb_rowid_bind";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, fun_create, {}, {});
|
||||
await connection.execute(fun_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, fun_drop, {}, {});
|
||||
await connection.execute(fun_drop);
|
||||
});
|
||||
|
||||
it('121.2.1 works with null', async function() {
|
||||
|
@ -234,11 +226,10 @@ describe('121. urowidFunctionBindAsString1.js', function() {
|
|||
c: { val: NaN, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('121.2.5 works with extended ROWID', async function() {
|
||||
|
@ -255,12 +246,10 @@ describe('121. urowidFunctionBindAsString1.js', function() {
|
|||
c: { val: "0", type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.equal(err.message.substring(0, 10), "ORA-01410:");
|
||||
// ORA-01410: invalid ROWID
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_execute, bindVar),
|
||||
/ORA-01410:/
|
||||
);
|
||||
});
|
||||
|
||||
it('121.2.8 works with number 0', async function() {
|
||||
|
@ -269,11 +258,10 @@ describe('121. urowidFunctionBindAsString1.js', function() {
|
|||
c: { val: 0, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('121.2.9 works with default bind type/dir - extended ROWID', async function() {
|
||||
|
@ -298,21 +286,18 @@ describe('121. urowidFunctionBindAsString1.js', function() {
|
|||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
}
|
||||
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_execute, bindVar),
|
||||
/NJS-037:/
|
||||
);
|
||||
});
|
||||
|
||||
it('121.2.14 bind error: NJS-052', async function() {
|
||||
const bindVar = [ { type: oracledb.STRING, dir: oracledb.BIND_OUT }, insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN } ];
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 3');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_execute, bindVar),
|
||||
/NJS-052:/
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -331,11 +316,11 @@ describe('121. urowidFunctionBindAsString1.js', function() {
|
|||
const fun_drop = "DROP FUNCTION nodb_rowid_bind_1083";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, fun_create, {}, {});
|
||||
await connection.execute(fun_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, fun_drop, {}, {});
|
||||
await connection.execute(fun_drop);
|
||||
});
|
||||
|
||||
it('121.3.1 update null with UROWID', async function() {
|
||||
|
@ -357,11 +342,10 @@ describe('121. urowidFunctionBindAsString1.js', function() {
|
|||
c2: { val: "0", type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_exec, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.equal(err.message.substring(0, 10), "ORA-01410:");
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_exec, bindVar),
|
||||
/ORA-01410:/
|
||||
);
|
||||
// ORA-01410: invalid ROWID
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017, 2022, Oracle and/or its affiliates. */
|
||||
/* Copyright (c) 2017, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
|
@ -29,12 +29,12 @@
|
|||
* Testing UROWID(< 200 bytes) plsql function bind inout as String.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sqlClone.js');
|
||||
|
||||
describe('122. urowidFunctionBindAsString2.js', function() {
|
||||
let connection = null;
|
||||
|
@ -62,17 +62,16 @@ describe('122. urowidFunctionBindAsString2.js', function() {
|
|||
|
||||
before('get connection and create table', async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
await sql.executeSql(connection, fun_create_table, {}, {});
|
||||
await connection.execute(fun_create_table);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
await sql.executeSql(connection, drop_table, {}, {});
|
||||
await connection.execute(drop_table);
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function() {
|
||||
insertID++;
|
||||
done();
|
||||
});
|
||||
|
||||
describe('122.1 FUNCTION BIND_INOUT as UROWID', function() {
|
||||
|
@ -89,11 +88,11 @@ describe('122. urowidFunctionBindAsString2.js', function() {
|
|||
const fun_drop = "DROP FUNCTION nodb_rowid_bind_inout_1121";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, fun_create, {}, {});
|
||||
await connection.execute(fun_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, fun_drop, {}, {});
|
||||
await connection.execute(fun_drop);
|
||||
});
|
||||
|
||||
it('122.1.1 works with null', async function() {
|
||||
|
@ -116,11 +115,10 @@ describe('122. urowidFunctionBindAsString2.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_create, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_create, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('122.1.5 works with extended ROWID', async function() {
|
||||
|
@ -140,11 +138,10 @@ describe('122. urowidFunctionBindAsString2.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.equal(err.message.substring(0, 10), "ORA-01410:");
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_execute, bindVar),
|
||||
/ORA-01410:/
|
||||
);
|
||||
});
|
||||
|
||||
it('122.1.8 works with number 0', async function() {
|
||||
|
@ -154,13 +151,10 @@ describe('122. urowidFunctionBindAsString2.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
|
||||
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('122.1.9 works with default bind type/dir - extended ROWID', async function() {
|
||||
|
@ -186,21 +180,18 @@ describe('122. urowidFunctionBindAsString2.js', function() {
|
|||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_execute, bindVar),
|
||||
/NJS-037:/
|
||||
);
|
||||
});
|
||||
|
||||
it('122.1.14 bind error: NJS-052', async function() {
|
||||
const bindVar = [ { type: oracledb.STRING, dir: oracledb.BIND_OUT }, insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 } ];
|
||||
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 3');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_execute, bindVar),
|
||||
/NJS-052:/
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -219,11 +210,11 @@ describe('122. urowidFunctionBindAsString2.js', function() {
|
|||
const fun_drop = "DROP FUNCTION nodb_rowid_bind_inout_1121";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, fun_create, {}, {});
|
||||
await connection.execute(fun_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, fun_drop, {}, {});
|
||||
await connection.execute(fun_drop);
|
||||
});
|
||||
|
||||
it('122.2.1 works with null', async function() {
|
||||
|
@ -245,11 +236,10 @@ describe('122. urowidFunctionBindAsString2.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('122.2.5 works with extended ROWID', async function() {
|
||||
|
@ -271,11 +261,10 @@ describe('122. urowidFunctionBindAsString2.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('122.2.9 works with default bind type/dir - extended ROWID', async function() {
|
||||
|
@ -300,20 +289,18 @@ describe('122. urowidFunctionBindAsString2.js', function() {
|
|||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_execute, bindVar),
|
||||
/NJS-037:/
|
||||
);
|
||||
});
|
||||
|
||||
it('122.2.14 bind error: NJS-052', async function() {
|
||||
const bindVar = [ { type: oracledb.STRING, dir: oracledb.BIND_OUT }, insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 } ];
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 3');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_execute, bindVar),
|
||||
/NJS-052:/
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -333,11 +320,11 @@ describe('122. urowidFunctionBindAsString2.js', function() {
|
|||
const fun_drop = "DROP FUNCTION nodb_rowid_bind_1083";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, fun_create, {}, {});
|
||||
await connection.execute(fun_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, fun_drop, {}, {});
|
||||
await connection.execute(fun_drop);
|
||||
});
|
||||
|
||||
it('122.3.1 update null with UROWID', async function() {
|
||||
|
@ -361,12 +348,10 @@ describe('122. urowidFunctionBindAsString2.js', function() {
|
|||
c2: { val: content_2, type: oracledb.STRING, dir: oracledb.BIND_INOUT },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, fun_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.equal(err.message.substring(0, 10), "ORA-01410:");
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(fun_execute, bindVar),
|
||||
/ORA-01410:/
|
||||
);
|
||||
// ORA-01410: invalid ROWID
|
||||
});
|
||||
|
||||
|
|
|
@ -29,12 +29,12 @@
|
|||
* Testing UROWID(> 200 bytes) plsql function bind in/out as String.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sqlClone.js');
|
||||
const random = require('./random.js');
|
||||
const testsUtil = require('./testsUtil.js');
|
||||
|
||||
|
@ -86,19 +86,18 @@ describe('142. urowidFunctionBindAsString3.js', function() {
|
|||
|
||||
before('get connection and create table', async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
await sql.executeSql(connection, table_indexed, {}, {});
|
||||
await sql.executeSql(connection, table_normal, {}, {});
|
||||
await connection.execute(table_indexed);
|
||||
await connection.execute(table_normal);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
await sql.executeSql(connection, drop_table_indexed, {}, {});
|
||||
await sql.executeSql(connection, drop_table_normal, {}, {});
|
||||
await connection.execute(drop_table_indexed);
|
||||
await connection.execute(drop_table_normal);
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function() {
|
||||
insertID++;
|
||||
done();
|
||||
});
|
||||
|
||||
describe('142.1 FUNCTION BIND_IN/OUT as UROWID', function() {
|
||||
|
@ -114,11 +113,11 @@ describe('142. urowidFunctionBindAsString3.js', function() {
|
|||
const fun_drop = "DROP FUNCTION nodb_rowid_bind";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, fun_create, {}, {});
|
||||
await connection.execute(fun_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, fun_drop, {}, {});
|
||||
await connection.execute(fun_drop);
|
||||
});
|
||||
|
||||
it('142.1.1 urowid length > 200', async function() {
|
||||
|
@ -148,11 +147,11 @@ describe('142. urowidFunctionBindAsString3.js', function() {
|
|||
const fun_drop = "DROP FUNCTION nodb_rowid_bind";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, fun_create, {}, {});
|
||||
await connection.execute(fun_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, fun_drop, {}, {});
|
||||
await connection.execute(fun_drop);
|
||||
});
|
||||
|
||||
it('142.2.1 urowid length > 200', async function() {
|
||||
|
@ -183,11 +182,11 @@ describe('142. urowidFunctionBindAsString3.js', function() {
|
|||
const fun_drop = "DROP FUNCTION nodb_rowid_bind_1083";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, fun_create, {}, {});
|
||||
await connection.execute(fun_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, fun_drop, {}, {});
|
||||
await connection.execute(fun_drop);
|
||||
});
|
||||
|
||||
it('142.3.1 update with UROWID > 200', async function() {
|
||||
|
@ -208,7 +207,7 @@ describe('142. urowidFunctionBindAsString3.js', function() {
|
|||
const str = random.getRandomLengthString(expectedLength);
|
||||
let urowid, urowidLen;
|
||||
const sql_insert = "insert into " + tableName_indexed + " values (" + insertID + ", '" + str + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
let result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + insertID);
|
||||
assert(result);
|
||||
urowid = result.rows[0][0];
|
||||
|
@ -233,7 +232,7 @@ describe('142. urowidFunctionBindAsString3.js', function() {
|
|||
let urowid_1, urowid_2, urowidLen_1, urowidLen_2, id_1, id_2;
|
||||
id_1 = insertID;
|
||||
let sql_insert = "insert into " + tableName_indexed + " values (" + id_1 + ", '" + str_1 + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
let result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + id_1);
|
||||
assert(result);
|
||||
urowid_1 = result.rows[0][0];
|
||||
|
@ -241,7 +240,7 @@ describe('142. urowidFunctionBindAsString3.js', function() {
|
|||
testsUtil.checkUrowidLength(urowidLen_1, contentLen_1);
|
||||
id_2 = insertID + 1;
|
||||
sql_insert = "insert into " + tableName_indexed + " values (" + id_2 + ", '" + str_2 + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + id_2);
|
||||
assert(result);
|
||||
urowid_2 = result.rows[0][0];
|
||||
|
|
|
@ -29,12 +29,12 @@
|
|||
* Testing UROWID(> 200 bytes) plsql function bind inout as String.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sql.js');
|
||||
const random = require('./random.js');
|
||||
const testsUtil = require('./testsUtil.js');
|
||||
|
||||
|
@ -86,19 +86,18 @@ describe('143. urowidFunctionBindAsString4.js', function() {
|
|||
|
||||
before('get connection and create table', async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
await sql.executeSql(connection, table_indexed, {}, {});
|
||||
await sql.executeSql(connection, table_normal, {}, {});
|
||||
await connection.execute(table_indexed);
|
||||
await connection.execute(table_normal);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
await sql.executeSql(connection, drop_table_indexed, {}, {});
|
||||
await sql.executeSql(connection, drop_table_normal, {}, {});
|
||||
await connection.execute(drop_table_indexed);
|
||||
await connection.execute(drop_table_normal);
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
beforeEach(function(done) {
|
||||
beforeEach(function() {
|
||||
insertID++;
|
||||
done();
|
||||
});
|
||||
|
||||
describe('143.1 FUNCTION BIND_INOUT as UROWID', function() {
|
||||
|
@ -115,11 +114,11 @@ describe('143. urowidFunctionBindAsString4.js', function() {
|
|||
const fun_drop = "DROP FUNCTION nodb_rowid_bind_inout_1121";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, fun_create, {}, {});
|
||||
await connection.execute(fun_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, fun_drop, {}, {});
|
||||
await connection.execute(fun_drop);
|
||||
});
|
||||
|
||||
it('143.1.1 urowid length > 200', async function() {
|
||||
|
@ -150,11 +149,11 @@ describe('143. urowidFunctionBindAsString4.js', function() {
|
|||
const fun_drop = "DROP FUNCTION nodb_rowid_bind_inout_1121";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, fun_create, {}, {});
|
||||
await connection.execute(fun_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, fun_drop, {}, {});
|
||||
await connection.execute(fun_drop);
|
||||
});
|
||||
|
||||
it('143.2.1 urowid length > 200', async function() {
|
||||
|
@ -187,11 +186,11 @@ describe('143. urowidFunctionBindAsString4.js', function() {
|
|||
const fun_drop = "DROP FUNCTION nodb_rowid_bind_1443";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, fun_create, {}, {});
|
||||
await connection.execute(fun_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, fun_drop, {}, {});
|
||||
await connection.execute(fun_drop);
|
||||
});
|
||||
|
||||
it('143.3.1 update with UROWID > 200', async function() {
|
||||
|
@ -212,7 +211,7 @@ describe('143. urowidFunctionBindAsString4.js', function() {
|
|||
const str = random.getRandomLengthString(expectedLength);
|
||||
let urowid, urowidLen;
|
||||
const sql_insert = "insert into " + tableName_indexed + " values (" + insertID + ", '" + str + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
let result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + insertID);
|
||||
assert(result);
|
||||
urowid = result.rows[0][0];
|
||||
|
@ -239,7 +238,7 @@ describe('143. urowidFunctionBindAsString4.js', function() {
|
|||
let urowid_1, urowid_2, urowidLen_1, urowidLen_2, id_1, id_2;
|
||||
id_1 = insertID;
|
||||
let sql_insert = "insert into " + tableName_indexed + " values (" + id_1 + ", '" + str_1 + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
|
||||
let result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + id_1);
|
||||
assert(result);
|
||||
|
@ -248,7 +247,7 @@ describe('143. urowidFunctionBindAsString4.js', function() {
|
|||
testsUtil.checkUrowidLength(urowidLen_1, contentLen_1);
|
||||
id_2 = insertID + 1;
|
||||
sql_insert = "insert into " + tableName_indexed + " values (" + id_2 + ", '" + str_2 + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + id_2);
|
||||
assert(result);
|
||||
urowid_2 = result.rows[0][0];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017, 2022, Oracle and/or its affiliates. */
|
||||
/* Copyright (c) 2017, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
|
@ -29,12 +29,13 @@
|
|||
* Testing UROWID(< 200 bytes) plsql procedure bind in as String.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sqlClone.js');
|
||||
|
||||
describe('118. urowidProcedureBindAsString1.js', function() {
|
||||
let connection = null;
|
||||
const tableName = "nodb_urowid_plsql_in";
|
||||
|
@ -61,11 +62,11 @@ describe('118. urowidProcedureBindAsString1.js', function() {
|
|||
|
||||
before('get connection and create table', async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
await sql.executeSql(connection, proc_create_table, {}, {});
|
||||
await connection.execute(proc_create_table);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
await sql.executeSql(connection, drop_table, {}, {});
|
||||
await connection.execute(drop_table);
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
|
@ -83,11 +84,11 @@ describe('118. urowidProcedureBindAsString1.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_urowid_bind_in_1081";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('118.1.1 works with null', async function() {
|
||||
|
@ -108,12 +109,10 @@ describe('118. urowidProcedureBindAsString1.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_IN }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('118.1.5 works with extended ROWID', async function() {
|
||||
|
@ -130,11 +129,10 @@ describe('118. urowidProcedureBindAsString1.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_IN }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.equal(err.message.substring(0, 10), "ORA-01410:");
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/ORA-01410:/
|
||||
);
|
||||
// ORA-01410: invalid ROWID
|
||||
});
|
||||
|
||||
|
@ -144,12 +142,10 @@ describe('118. urowidProcedureBindAsString1.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_IN }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('118.1.9 works with default bind type/dir - extended ROWID', async function() {
|
||||
|
@ -173,20 +169,18 @@ describe('118. urowidProcedureBindAsString1.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-037:/
|
||||
);
|
||||
});
|
||||
|
||||
it('118.1.14 bind error: NJS-052', async function() {
|
||||
const bindVar = [ insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN } ];
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 2');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-052:/
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -201,11 +195,11 @@ describe('118. urowidProcedureBindAsString1.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_urowid_bind_in_1082";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('118.2.1 works with null', async function() {
|
||||
|
@ -226,11 +220,10 @@ describe('118. urowidProcedureBindAsString1.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_IN }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('118.2.5 works with extended ROWID', async function() {
|
||||
|
@ -251,11 +244,10 @@ describe('118. urowidProcedureBindAsString1.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_IN }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('118.2.9 works with default bind type/dir - extended ROWID', async function() {
|
||||
|
@ -279,23 +271,22 @@ describe('118. urowidProcedureBindAsString1.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-037:/
|
||||
);
|
||||
});
|
||||
|
||||
it('118.2.14 bind error: NJS-052', async function() {
|
||||
const bindVar = [ insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN } ];
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 2');
|
||||
}
|
||||
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-052:/
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('118.3 PROCEDURE BIND_IN, UPDATE', function() {
|
||||
const proc_create = "CREATE OR REPLACE PROCEDURE nodb_urowid_bind_in_1083 (id IN NUMBER, content_1 IN VARCHAR2, content_2 IN UROWID)\n" +
|
||||
"AS \n" +
|
||||
|
@ -307,11 +298,11 @@ describe('118. urowidProcedureBindAsString1.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_urowid_bind_in_1083";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('118.3.1 update null with UROWID', async function() {
|
||||
|
@ -334,11 +325,10 @@ describe('118. urowidProcedureBindAsString1.js', function() {
|
|||
c1: { val: content_1, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
c2: { val: content_2, type: oracledb.STRING, dir: oracledb.BIND_IN }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.equal(err.message.substring(0, 10), "ORA-01410:");
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/ORA-01410:/
|
||||
);
|
||||
// ORA-01410: invalid ROWID
|
||||
});
|
||||
|
||||
|
@ -362,7 +352,7 @@ describe('118. urowidProcedureBindAsString1.js', function() {
|
|||
c: { val: content_in, type: oracledb.STRING, dir: oracledb.BIND_IN }
|
||||
};
|
||||
const option_in = { autoCommit: true };
|
||||
await sql.executeSql(connection, proc_execute, bindVar_in, option_in);
|
||||
await connection.execute(proc_execute, bindVar_in, option_in);
|
||||
|
||||
const sql_query = "select * from " + tableName + " where id = " + insertID;
|
||||
const result = await connection.execute(sql_query);
|
||||
|
@ -378,7 +368,7 @@ describe('118. urowidProcedureBindAsString1.js', function() {
|
|||
i: insertID,
|
||||
c: content_in
|
||||
};
|
||||
await sql.executeSql(connection, proc_execute, bindVar_in, option_in);
|
||||
await connection.execute(proc_execute, bindVar_in, option_in);
|
||||
|
||||
let sql_query = "select * from " + tableName + " where id = " + insertID;
|
||||
let result = await connection.execute(sql_query);
|
||||
|
@ -386,7 +376,7 @@ describe('118. urowidProcedureBindAsString1.js', function() {
|
|||
assert.strictEqual(resultVal, expected);
|
||||
insertID++;
|
||||
bindVar_in = [ insertID, content_in ];
|
||||
await sql.executeSql(connection, proc_execute, bindVar_in, option_in);
|
||||
await connection.execute(proc_execute, bindVar_in, option_in);
|
||||
sql_query = "select * from " + tableName + " where id = " + insertID;
|
||||
result = await connection.execute(sql_query);
|
||||
resultVal = result.rows[0][1];
|
||||
|
@ -401,7 +391,7 @@ describe('118. urowidProcedureBindAsString1.js', function() {
|
|||
};
|
||||
const option_in = { autoCommit: true };
|
||||
|
||||
await sql.executeSql(connection, proc_execute, bindVar_in, option_in);
|
||||
await connection.execute(proc_execute, bindVar_in, option_in);
|
||||
|
||||
const sql_query = "select * from " + tableName + " where id = " + insertID;
|
||||
const result = await connection.execute(sql_query);
|
||||
|
@ -417,7 +407,7 @@ describe('118. urowidProcedureBindAsString1.js', function() {
|
|||
c1: content_1,
|
||||
c2: content_2
|
||||
};
|
||||
await sql.executeSql(connection, proc_execute, bindVar_in, option_in);
|
||||
await connection.execute(proc_execute, bindVar_in, option_in);
|
||||
let sql_query = "select * from " + tableName + " where id = " + insertID;
|
||||
let result = await connection.execute(sql_query);
|
||||
let resultVal = result.rows[0][1];
|
||||
|
@ -425,7 +415,7 @@ describe('118. urowidProcedureBindAsString1.js', function() {
|
|||
insertID++;
|
||||
|
||||
bindVar_in = [ insertID, content_1, content_2 ];
|
||||
await sql.executeSql(connection, proc_execute, bindVar_in, option_in);
|
||||
await connection.execute(proc_execute, bindVar_in, option_in);
|
||||
sql_query = "select * from " + tableName + " where id = " + insertID;
|
||||
result = await connection.execute(sql_query);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017, 2022, Oracle and/or its affiliates. */
|
||||
/* Copyright (c) 2017, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
|
@ -29,12 +29,12 @@
|
|||
* Testing UROWID(< 200 bytes) plsql procedure bind out as String.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sqlClone.js');
|
||||
|
||||
describe('119. urowidProcedureBindAsString2.js', function() {
|
||||
let connection = null;
|
||||
|
@ -63,11 +63,11 @@ describe('119. urowidProcedureBindAsString2.js', function() {
|
|||
before('get connection and create table', async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
assert(connection);
|
||||
await sql.executeSql(connection, proc_create_table, {}, {});
|
||||
await connection.execute(proc_create_table);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
await sql.executeSql(connection, drop_table, {}, {});
|
||||
await connection.execute(drop_table);
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
|
@ -86,11 +86,11 @@ describe('119. urowidProcedureBindAsString2.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_rowid_bind_out";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('119.1.1 works with null', async function() {
|
||||
|
@ -112,12 +112,10 @@ describe('119. urowidProcedureBindAsString2.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('119.1.5 works with extended ROWID', async function() {
|
||||
|
@ -135,11 +133,10 @@ describe('119. urowidProcedureBindAsString2.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.equal(err.message.substring(0, 10), "ORA-01410:");
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/ORA-01410:/
|
||||
);
|
||||
// ORA-01410: invalid ROWID
|
||||
});
|
||||
|
||||
|
@ -149,11 +146,10 @@ describe('119. urowidProcedureBindAsString2.js', function() {
|
|||
c: { val: 0, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('119.1.9 works with default bind type/dir - extended ROWID', async function() {
|
||||
|
@ -178,20 +174,18 @@ describe('119. urowidProcedureBindAsString2.js', function() {
|
|||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-037:/
|
||||
);
|
||||
});
|
||||
|
||||
it('119.1.14 bind error: NJS-052', async function() {
|
||||
const bindVar = [ insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN }, { type: oracledb.STRING, dir: oracledb.BIND_OUT } ];
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 2');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-052:/
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -207,11 +201,11 @@ describe('119. urowidProcedureBindAsString2.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_rowid_bind_out";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('119.2.1 works with null', async function() {
|
||||
|
@ -233,11 +227,10 @@ describe('119. urowidProcedureBindAsString2.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('119.2.5 works with extended ROWID', async function() {
|
||||
|
@ -254,12 +247,11 @@ describe('119. urowidProcedureBindAsString2.js', function() {
|
|||
c: { val: "0", type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.equal(err.message.substring(0, 10), "ORA-01410:");
|
||||
// ORA-01410: invalid ROWID
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/ORA-01410:/
|
||||
);
|
||||
// ORA-01410: invalid ROWID
|
||||
});
|
||||
|
||||
it('119.2.8 works with number 0', async function() {
|
||||
|
@ -268,12 +260,10 @@ describe('119. urowidProcedureBindAsString2.js', function() {
|
|||
c: { val: 0, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('119.2.9 works with default bind type/dir - extended ROWID', async function() {
|
||||
|
@ -298,21 +288,18 @@ describe('119. urowidProcedureBindAsString2.js', function() {
|
|||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
}
|
||||
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-037:/
|
||||
);
|
||||
});
|
||||
|
||||
it('119.2.14 bind error: NJS-052', async function() {
|
||||
const bindVar = [ insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN }, { type: oracledb.STRING, dir: oracledb.BIND_OUT } ];
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 2');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-052:/
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -329,11 +316,11 @@ describe('119. urowidProcedureBindAsString2.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_rowid_bind_1083";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('119.3.1 update null with UROWID', async function() {
|
||||
|
@ -355,12 +342,11 @@ describe('119. urowidProcedureBindAsString2.js', function() {
|
|||
c2: { val: "0", type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.equal(err.message.substring(0, 10), "ORA-01410:");
|
||||
// ORA-01410: invalid ROWID
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/ORA-01410:/
|
||||
);
|
||||
// ORA-01410: invalid ROWID
|
||||
});
|
||||
|
||||
it('119.3.5 works with default bind type/dir - null value', async function() {
|
||||
|
@ -426,4 +412,5 @@ describe('119. urowidProcedureBindAsString2.js', function() {
|
|||
const resultVal = result.outBinds.o;
|
||||
assert.strictEqual(resultVal, expected);
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2017, 2022, Oracle and/or its affiliates. */
|
||||
/* Copyright (c) 2017, 2023, Oracle and/or its affiliates. */
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
|
@ -29,12 +29,12 @@
|
|||
* Testing UROWID(< 200 bytes) plsql procedure bind inout as String.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sqlClone.js');
|
||||
|
||||
describe('120. urowidProcedureBindAsString3.js', function() {
|
||||
let connection = null;
|
||||
|
@ -63,11 +63,11 @@ describe('120. urowidProcedureBindAsString3.js', function() {
|
|||
before('get connection and create table', async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
assert(connection);
|
||||
await sql.executeSql(connection, proc_create_table, {}, {});
|
||||
await connection.execute(proc_create_table);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
await sql.executeSql(connection, drop_table, {}, {});
|
||||
await connection.execute(drop_table);
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
|
@ -86,11 +86,11 @@ describe('120. urowidProcedureBindAsString3.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_rowid_bind_inout";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('120.1.1 works with null', async function() {
|
||||
|
@ -110,12 +110,10 @@ describe('120. urowidProcedureBindAsString3.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: NaN, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 1000 }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('120.1.5 works with extended ROWID', async function() {
|
||||
|
@ -132,13 +130,11 @@ describe('120. urowidProcedureBindAsString3.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 1000 }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.equal(err.message.substring(0, 10), "ORA-01410:");
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/ORA-01410:/
|
||||
);
|
||||
// ORA-01410: invalid ROWID
|
||||
|
||||
});
|
||||
|
||||
it('120.1.8 works with number 0', async function() {
|
||||
|
@ -146,12 +142,10 @@ describe('120. urowidProcedureBindAsString3.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: 0, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 1000 }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('120.1.9 works with default bind type/dir - extended ROWID', async function() {
|
||||
|
@ -175,21 +169,18 @@ describe('120. urowidProcedureBindAsString3.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
}
|
||||
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-037:/
|
||||
);
|
||||
});
|
||||
|
||||
it('120.1.14 bind error: NJS-052', async function() {
|
||||
const bindVar = [ insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 }];
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 2');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-052:/
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -205,11 +196,11 @@ describe('120. urowidProcedureBindAsString3.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_rowid_bind_inout";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('120.2.1 works with null', async function() {
|
||||
|
@ -229,11 +220,10 @@ describe('120. urowidProcedureBindAsString3.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: NaN, type: oracledb.STRING, dir: oracledb.BIND_INOUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('120.2.5 works with extended ROWID', async function() {
|
||||
|
@ -253,12 +243,10 @@ describe('120. urowidProcedureBindAsString3.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: 0, type: oracledb.STRING, dir: oracledb.BIND_INOUT }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
}
|
||||
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-011:/
|
||||
);
|
||||
});
|
||||
|
||||
it('120.2.9 works with default bind type/dir - extended ROWID', async function() {
|
||||
|
@ -282,20 +270,18 @@ describe('120. urowidProcedureBindAsString3.js', function() {
|
|||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-037:/
|
||||
);
|
||||
});
|
||||
|
||||
it('120.2.14 bind error: NJS-052', async function() {
|
||||
const bindVar = [ insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 }];
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 2');
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/NJS-052:/
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -311,11 +297,11 @@ describe('120. urowidProcedureBindAsString3.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_rowid_bind_1083";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('120.3.1 update null with UROWID', async function() {
|
||||
|
@ -336,11 +322,10 @@ describe('120. urowidProcedureBindAsString3.js', function() {
|
|||
c1: { val: "AAAB1+AADAAAAwPAAA", type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 1000 },
|
||||
c2: { val: "0", type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 1000 }
|
||||
};
|
||||
try {
|
||||
await sql.executeSqlWithErr(connection, proc_execute, bindVar, {});
|
||||
} catch (err) {
|
||||
assert.equal(err.message.substring(0, 10), "ORA-01410:");
|
||||
}
|
||||
await assert.rejects(
|
||||
async () => await connection.execute(proc_execute, bindVar),
|
||||
/ORA-01410:/
|
||||
);
|
||||
// ORA-01410: invalid ROWID
|
||||
});
|
||||
|
||||
|
@ -403,4 +388,5 @@ describe('120. urowidProcedureBindAsString3.js', function() {
|
|||
const resultVal = result.outBinds.c2;
|
||||
assert.strictEqual(resultVal, expected);
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -29,12 +29,12 @@
|
|||
* Testing UROWID(> 200 bytes) plsql procedure bind in as String.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sqlClone.js');
|
||||
const random = require('./random.js');
|
||||
const testsUtil = require('./testsUtil.js');
|
||||
|
||||
|
@ -86,13 +86,13 @@ describe('144. urowidProcedureBindAsString4.js', function() {
|
|||
|
||||
before('get connection and create table', async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
await sql.executeSql(connection, table_indexed, {}, {});
|
||||
await sql.executeSql(connection, table_normal, {}, {});
|
||||
await connection.execute(table_indexed);
|
||||
await connection.execute(table_normal);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
await sql.executeSql(connection, drop_table_indexed, {}, {});
|
||||
await sql.executeSql(connection, drop_table_normal, {}, {});
|
||||
await connection.execute(drop_table_indexed);
|
||||
await connection.execute(drop_table_normal);
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
|
@ -110,11 +110,11 @@ describe('144. urowidProcedureBindAsString4.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_urowid_bind_in_1441";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('144.1.1 urowid length > 500', async function() {
|
||||
|
@ -141,11 +141,11 @@ describe('144. urowidProcedureBindAsString4.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_urowid_bind_in_1442";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('144.2.1 urowid length > 500', async function() {
|
||||
|
@ -173,11 +173,11 @@ describe('144. urowidProcedureBindAsString4.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_urowid_bind_in_1443";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('144.3.1 update with urowid length > 500', async function() {
|
||||
|
@ -198,10 +198,9 @@ describe('144. urowidProcedureBindAsString4.js', function() {
|
|||
const str = random.getRandomLengthString(expectedLength);
|
||||
let urowid, urowidLen;
|
||||
const sql_insert = "insert into " + tableName_indexed + " values (" + insertID + ", '" + str + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
|
||||
let result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + insertID);
|
||||
assert(result);
|
||||
urowid = result.rows[0][0];
|
||||
urowidLen = urowid.length;
|
||||
testsUtil.checkUrowidLength(urowidLen, expectedLength);
|
||||
|
@ -211,11 +210,10 @@ describe('144. urowidProcedureBindAsString4.js', function() {
|
|||
c: { val: urowid, type: oracledb.STRING, dir: oracledb.BIND_IN }
|
||||
};
|
||||
const option_in = { autoCommit: true };
|
||||
await sql.executeSql(connection, proc_execute, bindVar_in, option_in);
|
||||
await connection.execute(proc_execute, bindVar_in, option_in);
|
||||
|
||||
const sql_query = "select * from " + tableName_normal + " where id = " + insertID;
|
||||
result = await connection.execute(sql_query);
|
||||
assert(result);
|
||||
const resultVal = result.rows[0][1];
|
||||
assert.strictEqual(resultVal, urowid);
|
||||
};
|
||||
|
@ -227,10 +225,9 @@ describe('144. urowidProcedureBindAsString4.js', function() {
|
|||
|
||||
id_1 = insertID;
|
||||
let sql_insert = "insert into " + tableName_indexed + " values (" + id_1 + ", '" + str_1 + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
|
||||
let result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + id_1);
|
||||
assert(result);
|
||||
urowid_1 = result.rows[0][0];
|
||||
urowidLen_1 = urowid_1.length;
|
||||
testsUtil.checkUrowidLength(urowidLen_1, contentLen_1);
|
||||
|
@ -238,7 +235,6 @@ describe('144. urowidProcedureBindAsString4.js', function() {
|
|||
sql_insert = "insert into " + tableName_indexed + " values (" + id_2 + ", '" + str_2 + "')";
|
||||
result = await connection.execute(sql_insert);
|
||||
result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + id_2);
|
||||
assert(result);
|
||||
urowid_2 = result.rows[0][0];
|
||||
urowidLen_2 = urowid_2.length;
|
||||
testsUtil.checkUrowidLength(urowidLen_2, contentLen_2);
|
||||
|
@ -249,7 +245,7 @@ describe('144. urowidProcedureBindAsString4.js', function() {
|
|||
c2: { val: urowid_2, type: oracledb.STRING, dir: oracledb.BIND_IN }
|
||||
};
|
||||
const option_in = { autoCommit: true };
|
||||
await sql.executeSql(connection, proc_execute, bindVar_in, option_in);
|
||||
await connection.execute(proc_execute, bindVar_in, option_in);
|
||||
|
||||
sql_insert = "select * from " + tableName_normal + " where id = " + insertID;
|
||||
result = await connection.execute(sql_insert);
|
||||
|
|
|
@ -29,12 +29,12 @@
|
|||
* Testing UROWID(> 200 bytes) plsql procedure bind out as String.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sqlClone.js');
|
||||
const random = require('./random.js');
|
||||
const testsUtil = require('./testsUtil.js');
|
||||
|
||||
|
@ -86,13 +86,13 @@ describe('145. urowidProcedureBindAsString5.js', function() {
|
|||
|
||||
before('get connection and create table', async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
await sql.executeSql(connection, table_indexed, {}, {});
|
||||
await sql.executeSql(connection, table_normal, {}, {});
|
||||
await connection.execute(table_indexed);
|
||||
await connection.execute(table_normal);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
await sql.executeSql(connection, drop_table_indexed, {}, {});
|
||||
await sql.executeSql(connection, drop_table_normal, {}, {});
|
||||
await connection.execute(drop_table_indexed);
|
||||
await connection.execute(drop_table_normal);
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
|
@ -111,11 +111,11 @@ describe('145. urowidProcedureBindAsString5.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_rowid_bind_out_1451";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('145.1.1 urowid length > 500', async function() {
|
||||
|
@ -143,11 +143,11 @@ describe('145. urowidProcedureBindAsString5.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_rowid_bind_out_1452";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('145.2.1 urowid length > 500', async function() {
|
||||
|
@ -168,9 +168,8 @@ describe('145. urowidProcedureBindAsString5.js', function() {
|
|||
const str = random.getRandomLengthString(expectedLength);
|
||||
let urowid, urowidLen;
|
||||
const sql_insert = "insert into " + tableName_indexed + " values (" + insertID + ", '" + str + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
let result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + insertID);
|
||||
assert(result);
|
||||
urowid = result.rows[0][0];
|
||||
urowidLen = urowid.length;
|
||||
testsUtil.checkUrowidLength(urowidLen, expectedLength);
|
||||
|
@ -180,8 +179,8 @@ describe('145. urowidProcedureBindAsString5.js', function() {
|
|||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 5000 }
|
||||
};
|
||||
result = await connection.execute(proc_execute, bindVar_out);
|
||||
assert(result);
|
||||
const resultVal = result.outBinds.o;
|
||||
assert.strictEqual(resultVal, urowid);
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
@ -29,12 +29,12 @@
|
|||
* Testing UROWID(> 200 bytes) plsql procedure bind inout as String.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
'use strict';
|
||||
|
||||
const oracledb = require('oracledb');
|
||||
const assert = require('assert');
|
||||
const dbConfig = require('./dbconfig.js');
|
||||
const sql = require('./sqlClone.js');
|
||||
const random = require('./random.js');
|
||||
const testsUtil = require('./testsUtil.js');
|
||||
|
||||
|
@ -86,13 +86,13 @@ describe('146. urowidProcedureBindAsString6.js', function() {
|
|||
|
||||
before('get connection and create table', async function() {
|
||||
connection = await oracledb.getConnection(dbConfig);
|
||||
await sql.executeSql(connection, table_indexed, {}, {});
|
||||
await sql.executeSql(connection, table_normal, {}, {});
|
||||
await connection.execute(table_indexed);
|
||||
await connection.execute(table_normal);
|
||||
});
|
||||
|
||||
after('release connection', async function() {
|
||||
await sql.executeSql(connection, drop_table_indexed, {}, {});
|
||||
await sql.executeSql(connection, drop_table_normal, {}, {});
|
||||
await connection.execute(drop_table_indexed);
|
||||
await connection.execute(drop_table_normal);
|
||||
await connection.close();
|
||||
});
|
||||
|
||||
|
@ -111,11 +111,11 @@ describe('146. urowidProcedureBindAsString6.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_rowid_bind_inout_1461";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('146.1.1 urowid length > 500', async function() {
|
||||
|
@ -143,11 +143,11 @@ describe('146. urowidProcedureBindAsString6.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_rowid_bind_inout_1462";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('146.2.1 urowid length > 500', async function() {
|
||||
|
@ -177,11 +177,11 @@ describe('146. urowidProcedureBindAsString6.js', function() {
|
|||
const proc_drop = "DROP PROCEDURE nodb_rowid_bind_inout_1463";
|
||||
|
||||
before('create procedure', async function() {
|
||||
await sql.executeSql(connection, proc_create, {}, {});
|
||||
await connection.execute(proc_create);
|
||||
});
|
||||
|
||||
after('drop procedure', async function() {
|
||||
await sql.executeSql(connection, proc_drop, {}, {});
|
||||
await connection.execute(proc_drop);
|
||||
});
|
||||
|
||||
it('146.3.1 update with urowid length > 500', async function() {
|
||||
|
@ -202,7 +202,7 @@ describe('146. urowidProcedureBindAsString6.js', function() {
|
|||
const str = random.getRandomLengthString(expectedLength);
|
||||
let urowid, urowidLen;
|
||||
const sql_insert = "insert into " + tableName_indexed + " values (" + insertID + ", '" + str + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
let result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + insertID);
|
||||
urowid = result.rows[0][0];
|
||||
urowidLen = urowid.length;
|
||||
|
@ -223,7 +223,7 @@ describe('146. urowidProcedureBindAsString6.js', function() {
|
|||
let urowid_1, urowid_2, urowidLen_1, urowidLen_2, id_1, id_2;
|
||||
id_1 = insertID;
|
||||
let sql_insert = "insert into " + tableName_indexed + " values (" + id_1 + ", '" + str_1 + "')";
|
||||
await sql.executeInsert(connection, sql_insert, {}, {});
|
||||
await connection.execute(sql_insert);
|
||||
let result = await connection.execute("select ROWID from " + tableName_indexed + " where c1 = " + id_1);
|
||||
urowid_1 = result.rows[0][0];
|
||||
urowidLen_1 = urowid_1.length;
|
||||
|
@ -249,4 +249,5 @@ describe('146. urowidProcedureBindAsString6.js', function() {
|
|||
assert.strictEqual(resultVal_2, urowid_2);
|
||||
insertID = insertID + 10;
|
||||
};
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue