Add BLOB PL/SQL bind tests

This commit is contained in:
Christopher Jones 2017-03-16 15:51:55 +11:00
parent 60677b8329
commit 0e3b1b55db
27 changed files with 18369 additions and 17059 deletions

View File

@ -212,7 +212,7 @@ describe('63. autoCommit4nestedExecutes.js', function() {
function(err, result) {
should.exist(err);
// ORA-01036: illegal variable name/number
(err.message).should.startWith('ORA-01036');
(err.message).should.startWith('ORA-01036:');
should.not.exist(result);
cb();
}

View File

@ -19,7 +19,7 @@
* See LICENSE.md for relevant licenses.
*
* NAME
* 80. blobDMLBindAsBuffer.js
* 82. blobDMLBindAsBuffer.js
*
* DESCRIPTION
* Testing BLOB binding as Buffer with DML.
@ -37,16 +37,18 @@ var oracledb = require('oracledb');
var should = require('should');
var async = require('async');
var dbConfig = require('./dbconfig.js');
var random = require('./random.js');
var fs = require('fs');
var assist = require('./dataTypeAssist.js');
var random = require('./random.js');
var fs = require('fs');
var assist = require('./dataTypeAssist.js');
describe('80.blobDMLBindAsBuffer.js', function() {
describe('82.blobDMLBindAsBuffer.js', function() {
this.timeout(100000);
var connection = null;
var client11gPlus = true; // assume instant client runtime version is greater than 11.2.0.4.0
var node6plus = false; // assume node runtime version is lower than 6
var insertID = 1; // assume id for insert into db starts from 1
var proc_blob_1 = "BEGIN \n" +
" DECLARE \n" +
" e_table_missing EXCEPTION; \n" +
@ -212,14 +214,7 @@ describe('80.blobDMLBindAsBuffer.js', function() {
}
};
// Generate id for insert blob into db
var insertID = 0;
var getID = function() {
insertID = insertID + 1;
return insertID;
};
describe('80.1 BLOB, INSERT', function() {
describe('82.1 BLOB, INSERT', function() {
before(function(done) {
executeSQL(proc_blob_1, done);
}); // before
@ -228,8 +223,8 @@ describe('80.blobDMLBindAsBuffer.js', function() {
executeSQL(sql2DropTable1, done);
}); // after
it('80.1.1 works with EMPTY_BLOB', function(done) {
var id = getID();
it('82.1.1 works with EMPTY_BLOB', function(done) {
var id = insertID++;
var content = "EMPTY_BLOB";
async.series([
@ -240,10 +235,10 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content, null, false, cb);
}
], done);
}); // 80.1.1
}); // 82.1.1
it('80.1.2 works with empty buffer', function(done) {
var id = getID();
it('82.1.2 works with empty buffer', function(done) {
var id = insertID++;
var bigStr = '';
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
@ -255,10 +250,10 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content, null, false, cb);
}
], done);
}); // 80.1.2
}); // 82.1.2
it('80.1.3 works with empty buffer and bind in maxSize set to 32767', function(done) {
var id = getID();
it('82.1.3 works with empty buffer and bind in maxSize set to 32767', function(done) {
var id = insertID++;
var bigStr = '';
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
@ -281,10 +276,10 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content, null, false, cb);
}
], done);
}); // 80.1.3
}); // 82.1.3
it('80.1.4 works with empty buffer and bind in maxSize set to 50000', function(done) {
var id = getID();
it('82.1.4 works with empty buffer and bind in maxSize set to 50000', function(done) {
var id = insertID++;
var bigStr = '';
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
@ -307,10 +302,10 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content, null, false, cb);
}
], done);
}); // 80.1.4
}); // 82.1.4
it('80.1.5 works with undefined', function(done) {
var id = getID();
it('82.1.5 works with undefined', function(done) {
var id = insertID++;
var content = undefined;
async.series([
@ -321,10 +316,10 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content, null, false, cb);
}
], done);
}); // 80.1.5
}); // 82.1.5
it('80.1.6 works with null', function(done) {
var id = getID();
it('82.1.6 works with null', function(done) {
var id = insertID++;
var content = null;
async.series([
@ -335,10 +330,10 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content, null, false, cb);
}
], done);
}); // 80.1.6
}); // 82.1.6
it('80.1.7 works with null and bind in maxSize set to 32767', function(done) {
var id = getID();
it('82.1.7 works with null and bind in maxSize set to 32767', function(done) {
var id = insertID++;
var content = null;
async.series([
@ -360,10 +355,10 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content, null, false, cb);
}
], done);
}); // 80.1.7
}); // 82.1.7
it('80.1.8 works with null and bind in maxSize set to 50000', function(done) {
var id = getID();
it('82.1.8 works with null and bind in maxSize set to 50000', function(done) {
var id = insertID++;
var content = null;
async.series([
@ -385,10 +380,10 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content, null, false, cb);
}
], done);
}); // 80.1.8
}); // 82.1.8
it('80.1.9 works with NaN', function(done) {
var id = getID();
it('82.1.9 works with NaN', function(done) {
var id = insertID++;
var content = NaN;
connection.execute(
@ -404,10 +399,10 @@ describe('80.blobDMLBindAsBuffer.js', function() {
done();
}
);
}); // 80.1.9
}); // 82.1.9
it('80.1.10 works with 0', function(done) {
var id = getID();
it('82.1.10 works with 0', function(done) {
var id = insertID++;
var content = 0;
connection.execute(
@ -423,12 +418,12 @@ describe('80.blobDMLBindAsBuffer.js', function() {
done();
}
);
}); // 80.1.10
}); // 82.1.10
it('80.1.11 works with Buffer length 32K', function(done) {
var id = getID();
it('82.1.11 works with Buffer length 32K', function(done) {
var id = insertID++;
var contentLength = 32768;
var specialStr = "80.1.11";
var specialStr = "82.1.11";
var bigStr = random.getRandomString(contentLength, specialStr);
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
@ -440,12 +435,12 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content, specialStr, false, cb);
}
], done);
}); // 80.1.11
}); // 82.1.11
it('80.1.12 works with Buffer length (64K - 1)', function(done) {
var id = getID();
it('82.1.12 works with Buffer length (64K - 1)', function(done) {
var id = insertID++;
var contentLength = 65535;
var specialStr = "80.1.12";
var specialStr = "82.1.12";
var bigStr = random.getRandomString(contentLength, specialStr);
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
@ -457,12 +452,12 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content, specialStr, false, cb);
}
], done);
}); // 80.1.12
}); // 82.1.12
it('80.1.13 works with Buffer length (64K + 1)', function(done) {
var id = getID();
it('82.1.13 works with Buffer length (64K + 1)', function(done) {
var id = insertID++;
var contentLength = 65537;
var specialStr = "80.1.13";
var specialStr = "82.1.13";
var bigStr = random.getRandomString(contentLength, specialStr);
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
@ -474,12 +469,12 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content, specialStr, true, cb);
}
], done);
}); // 80.1.13
}); // 82.1.13
it('80.1.14 works with Buffer length (1MB + 1)', function(done) {
var id = getID();
it('82.1.14 works with Buffer length (1MB + 1)', function(done) {
var id = insertID++;
var contentLength = 1048577; // 1 * 1024 * 1024 + 1;
var specialStr = "80.1.14";
var specialStr = "82.1.14";
var bigStr = random.getRandomString(contentLength, specialStr);
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
@ -491,12 +486,12 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content, specialStr, true, cb);
}
], done);
}); // 80.1.14
}); // 82.1.14
it('80.1.15 works with Buffer length (5MB + 1)', function(done) {
var id = getID();
it('82.1.15 works with Buffer length (5MB + 1)', function(done) {
var id = insertID++;
var contentLength = 5242881; // 5 * 1024 * 1024 + 1;
var specialStr = "80.1.15";
var specialStr = "82.1.15";
var bigStr = random.getRandomString(contentLength, specialStr);
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
@ -508,12 +503,12 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content, specialStr, true, cb);
}
], done);
}); // 80.1.15
}); // 82.1.15
it('80.1.16 works with Buffer length (10MB + 1)', function(done) {
var id = getID();
it('82.1.16 works with Buffer length (10MB + 1)', function(done) {
var id = insertID++;
var contentLength = 10485761; // 10 * 1024 * 1024 + 1;
var specialStr = "80.1.16";
var specialStr = "82.1.16";
var bigStr = random.getRandomString(contentLength, specialStr);
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
@ -525,10 +520,10 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content, specialStr, true, cb);
}
], done);
}); // 80.1.16
}); // 82.1.16
it('80.1.17 bind value and type mismatch', function(done) {
var id = getID();
it('82.1.17 bind value and type mismatch', function(done) {
var id = insertID++;
var content = 100;
connection.execute(
@ -544,12 +539,12 @@ describe('80.blobDMLBindAsBuffer.js', function() {
done();
}
);
}); // 80.1.17
}); // 82.1.17
it('80.1.18 mixing named with positional binding', function(done) {
var id = getID();
it('82.1.18 mixing named with positional binding', function(done) {
var id = insertID++;
var contentLength = 40000;
var specialStr = "80.1.18";
var specialStr = "82.1.18";
var bigStr = random.getRandomString(contentLength, specialStr);
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
@ -571,10 +566,10 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content, specialStr, true, cb);
}
], done);
}); // 80.1.18
}); // 82.1.18
it('80.1.19 bind with invalid BLOB', function(done) {
var id = getID();
it('82.1.19 bind with invalid BLOB', function(done) {
var id = insertID++;
connection.execute(
"INSERT INTO nodb_dml_blob_1 VALUES (:1, :2)",
@ -588,12 +583,12 @@ describe('80.blobDMLBindAsBuffer.js', function() {
done();
}
);
}); // 80.1.19
}); // 82.1.19
it('80.1.20 Negative: RETURNING INTO with bind type BUFFER', function(done) {
var id = getID();
it('82.1.20 Negative: RETURNING INTO with bind type BUFFER', function(done) {
var id = insertID++;
var contentLength = 400;
var specialStr = "80.1.20";
var specialStr = "82.1.20";
var bigStr = random.getRandomString(contentLength, specialStr);
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
var sql = "INSERT INTO nodb_dml_blob_1 (id, blob) VALUES (:i, :c) RETURNING blob INTO :lobbv";
@ -612,10 +607,10 @@ describe('80.blobDMLBindAsBuffer.js', function() {
done();
}
);
}); // 80.1.20
}); // 82.1.20
it('80.1.21 Negative: RETURNING INTO with autocommit on', function(done) {
var id = getID();
it('82.1.21 Negative: RETURNING INTO with autocommit on', function(done) {
var id = insertID++;
var sql = "INSERT INTO nodb_dml_blob_1 (id, blob) VALUES (:i, EMPTY_BLOB()) RETURNING blob INTO :lobbv";
var inFileName = './test/tree.jpg';
@ -649,12 +644,12 @@ describe('80.blobDMLBindAsBuffer.js', function() {
inStream.pipe(lob); // copies the text to the CLOB
}
);
}); // 80.1.21
}); // 82.1.21
it('80.1.22 works with bind in maxSize smaller than buffer size', function(done) {
var id = getID();
it('82.1.22 works with bind in maxSize smaller than buffer size', function(done) {
var id = insertID++;
var contentLength = 32768;
var specialStr = "80.1.22";
var specialStr = "82.1.22";
var bigStr = random.getRandomString(contentLength, specialStr);
var content = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
@ -677,11 +672,11 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content, specialStr, false, cb);
}
], done);
}); // 80.1.22
}); // 82.1.22
}); // 80.1
}); // 82.1
describe('80.2 BLOB, UPDATE', function() {
describe('82.2 BLOB, UPDATE', function() {
insertID = 0;
before(function(done) {
@ -692,11 +687,11 @@ describe('80.blobDMLBindAsBuffer.js', function() {
executeSQL(sql2DropTable1, done);
}); // after
it('80.2.1 update EMPTY_BLOB column', function(done) {
var id = getID();
it('82.2.1 update EMPTY_BLOB column', function(done) {
var id = insertID++;
var content_1 = "EMPTY_BLOB";
var contentLength_2 = 32768;
var specialStr_2 = "80.2.1";
var specialStr_2 = "82.2.1";
var bigStr_2 = random.getRandomString(contentLength_2, specialStr_2);
var content_2 = node6plus ? Buffer.from(bigStr_2, "utf-8") : new Buffer(bigStr_2, "utf-8");
@ -714,12 +709,12 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content_2, specialStr_2, false, cb);
}
], done);
}); // 80.2.1
}); // 82.2.1
it('80.2.2 update a cloumn with EMPTY_BLOB', function(done) {
var id = getID();
it('82.2.2 update a cloumn with EMPTY_BLOB', function(done) {
var id = insertID++;
var contentLength_1 = 50000;
var specialStr_1 = "80.2.2";
var specialStr_1 = "82.2.2";
var bigStr_1 = random.getRandomString(contentLength_1, specialStr_1);
var content_1 = node6plus ? Buffer.from(bigStr_1, "utf-8") : new Buffer(bigStr_1, "utf-8");
var content_2 = "EMPTY_BLOB";
@ -738,10 +733,10 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content_2, null, false, cb);
}
], done);
}); // 80.2.2
}); // 82.2.2
it('80.2.3 update EMPTY_BLOB column with empty buffer', function(done) {
var id = getID();
it('82.2.3 update EMPTY_BLOB column with empty buffer', function(done) {
var id = insertID++;
var content_1 = "EMPTY_BLOB";
var content_2 = "";
@ -759,14 +754,14 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content_2, null, false, cb);
}
], done);
}); // 80.2.3
}); // 82.2.3
it('80.2.4 update empty buffer column', function(done) {
var id = getID();
it('82.2.4 update empty buffer column', function(done) {
var id = insertID++;
var bigStr_1 = "";
var content_1 = node6plus ? Buffer.from(bigStr_1, "utf-8") : new Buffer(bigStr_1, "utf-8");
var contentLength_2 = 54321;
var specialStr_2 = "80.2.4";
var specialStr_2 = "82.2.4";
var bigStr_2 = random.getRandomString(contentLength_2, specialStr_2);
var content_2 = node6plus ? Buffer.from(bigStr_2, "utf-8") : new Buffer(bigStr_2, "utf-8");
@ -784,12 +779,12 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content_2, specialStr_2, false, cb);
}
], done);
}); // 80.2.4
}); // 82.2.4
it('80.2.5 update a column with empty buffer', function(done) {
var id = getID();
it('82.2.5 update a column with empty buffer', function(done) {
var id = insertID++;
var contentLength_1 = 50000;
var specialStr_1 = "80.2.2";
var specialStr_1 = "82.2.2";
var bigStr_1 = random.getRandomString(contentLength_1, specialStr_1);
var content_1 = node6plus ? Buffer.from(bigStr_1, "utf-8") : new Buffer(bigStr_1, "utf-8");
var content_2 = "";
@ -808,16 +803,16 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content_2, null, false, cb);
}
], done);
}); // 80.2.5
}); // 82.2.5
it('80.2.6 update a column with (10MB + 1) buffer', function(done) {
var id = getID();
it('82.2.6 update a column with (10MB + 1) buffer', function(done) {
var id = insertID++;
var contentLength_1 = 50000;
var specialStr_1 = "80.2.6_1";
var specialStr_1 = "82.2.6_1";
var bigStr_1 = random.getRandomString(contentLength_1, specialStr_1);
var content_1 = node6plus ? Buffer.from(bigStr_1, "utf-8") : new Buffer(bigStr_1, "utf-8");
var contentLength_2 = 10485761; // 10 * 1024 * 1024 + 1;
var specialStr_2 = "80.2.6_2";
var specialStr_2 = "82.2.6_2";
var bigStr_2 = random.getRandomString(contentLength_2, specialStr_2);
var content_2 = node6plus ? Buffer.from(bigStr_2, "utf-8") : new Buffer(bigStr_2, "utf-8");
@ -835,7 +830,7 @@ describe('80.blobDMLBindAsBuffer.js', function() {
checkInsertResult(id, content_2, specialStr_2, true, cb);
}
], done);
}); // 80.2.6
}); // 82.2.6
}); // 80.2
}); // 82.2
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@
* See LICENSE.md for relevant licenses.
*
* NAME
* 79. clobDMLBindAsString.js
* 81. clobDMLBindAsString.js
*
* DESCRIPTION
* Testing CLOB binding as String with DML.
@ -36,15 +36,17 @@
var oracledb = require('oracledb');
var should = require('should');
var async = require('async');
var fs = require('fs');
var dbConfig = require('./dbconfig.js');
var random = require('./random.js');
var fs = require('fs');
var random = require('./random.js');
describe('79.clobDMLBindAsString.js', function() {
describe('81. clobDMLBindAsString.js', function() {
this.timeout(100000);
var connection = null;
var client11gPlus = true; // assume instant client runtime version is greater than 11.2.0.4.0
var insertID = 1; // assume id for insert into db starts from 1
var proc_clob_1 = "BEGIN \n" +
" DECLARE \n" +
" e_table_missing EXCEPTION; \n" +
@ -207,14 +209,7 @@ describe('79.clobDMLBindAsString.js', function() {
}
};
// Generate id for insert clob into db
var insertID = 0;
var getID = function() {
insertID = insertID + 1;
return insertID;
};
describe('79.1 CLOB, INSERT', function() {
describe('81.1 CLOB, INSERT', function() {
before(function(done) {
executeSQL(proc_clob_1, done);
}); // before
@ -223,8 +218,8 @@ describe('79.clobDMLBindAsString.js', function() {
executeSQL(sql2DropTable1, done);
}); // after
it('79.1.1 works with EMPTY_CLOB', function(done) {
var id = getID();
it('81.1.1 works with EMPTY_CLOB', function(done) {
var id = insertID++;
var content = "EMPTY_CLOB";
async.series([
@ -235,10 +230,10 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content, null, false, cb);
}
], done);
}); // 79.1.1
}); // 81.1.1
it('79.1.2 works with empty string', function(done) {
var id = getID();
it('81.1.2 works with empty string', function(done) {
var id = insertID++;
var content = '';
async.series([
@ -249,10 +244,10 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content, null, false, cb);
}
], done);
}); // 79.1.2
}); // 81.1.2
it('79.1.3 works with empty string and bind in maxSize set to 32767', function(done) {
var id = getID();
it('81.1.3 works with empty string and bind in maxSize set to 32767', function(done) {
var id = insertID++;
var content = "";
async.series([
@ -274,10 +269,10 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content, null, false, cb);
}
], done);
}); // 79.1.3
}); // 81.1.3
it('79.1.4 works with empty string and bind in maxSize set to 50000', function(done) {
var id = getID();
it('81.1.4 works with empty string and bind in maxSize set to 50000', function(done) {
var id = insertID++;
var content = "";
async.series([
@ -299,10 +294,10 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content, null, false, cb);
}
], done);
}); // 79.1.4
}); // 81.1.4
it('79.1.5 works with undefined', function(done) {
var id = getID();
it('81.1.5 works with undefined', function(done) {
var id = insertID++;
var content = undefined;
async.series([
@ -313,10 +308,10 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content, null, false, cb);
}
], done);
}); // 79.1.5
}); // 81.1.5
it('79.1.6 works with null', function(done) {
var id = getID();
it('81.1.6 works with null', function(done) {
var id = insertID++;
var content = null;
async.series([
@ -327,10 +322,10 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content, null, false, cb);
}
], done);
}); // 79.1.6
}); // 81.1.6
it('79.1.7 works with null and bind in maxSize set to 32767', function(done) {
var id = getID();
it('81.1.7 works with null and bind in maxSize set to 32767', function(done) {
var id = insertID++;
var content = null;
async.series([
@ -352,10 +347,10 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content, null, false, cb);
}
], done);
}); // 79.1.7
}); // 81.1.7
it('79.1.8 works with null and bind in maxSize set to 50000', function(done) {
var id = getID();
it('81.1.8 works with null and bind in maxSize set to 50000', function(done) {
var id = insertID++;
var content = null;
async.series([
@ -377,10 +372,10 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content, null, false, cb);
}
], done);
}); // 79.1.8
}); // 81.1.8
it('79.1.9 works with NaN', function(done) {
var id = getID();
it('81.1.9 works with NaN', function(done) {
var id = insertID++;
var content = NaN;
connection.execute(
@ -396,10 +391,10 @@ describe('79.clobDMLBindAsString.js', function() {
done();
}
);
}); // 79.1.9
}); // 81.1.9
it('79.1.10 works with 0', function(done) {
var id = getID();
it('81.1.10 works with 0', function(done) {
var id = insertID++;
var content = 0;
connection.execute(
@ -415,12 +410,12 @@ describe('79.clobDMLBindAsString.js', function() {
done();
}
);
}); // 79.1.10
}); // 81.1.10
it('79.1.11 works with String length 32K', function(done) {
var id = getID();
it('81.1.11 works with String length 32K', function(done) {
var id = insertID++;
var contentLength = 32768;
var specialStr = "79.1.11";
var specialStr = "81.1.11";
var content = random.getRandomString(contentLength, specialStr);
async.series([
@ -431,12 +426,12 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content, specialStr, false, cb);
}
], done);
}); // 79.1.11
}); // 81.1.11
it('79.1.12 works with String length (64K - 1)', function(done) {
var id = getID();
it('81.1.12 works with String length (64K - 1)', function(done) {
var id = insertID++;
var contentLength = 65535;
var specialStr = "79.1.12";
var specialStr = "81.1.12";
var content = random.getRandomString(contentLength, specialStr);
async.series([
@ -447,12 +442,12 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content, specialStr, false, cb);
}
], done);
}); // 79.1.12
}); // 81.1.12
it('79.1.13 works with String length (64K + 1)', function(done) {
var id = getID();
it('81.1.13 works with String length (64K + 1)', function(done) {
var id = insertID++;
var contentLength = 65537;
var specialStr = "79.1.13";
var specialStr = "81.1.13";
var content = random.getRandomString(contentLength, specialStr);
async.series([
@ -463,12 +458,12 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content, specialStr, true, cb);
}
], done);
}); // 79.1.13
}); // 81.1.13
it('79.1.14 works with String length (1MB + 1)', function(done) {
var id = getID();
it('81.1.14 works with String length (1MB + 1)', function(done) {
var id = insertID++;
var contentLength = 1048577; // 1 * 1024 * 1024 + 1;
var specialStr = "79.1.14";
var specialStr = "81.1.14";
var content = random.getRandomString(contentLength, specialStr);
async.series([
@ -479,12 +474,12 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content, specialStr, true, cb);
}
], done);
}); // 79.1.14
}); // 81.1.14
it('79.1.15 works with String length (5MB + 1)', function(done) {
var id = getID();
it('81.1.15 works with String length (5MB + 1)', function(done) {
var id = insertID++;
var contentLength = 5242881; // 5 * 1024 * 1024 + 1;
var specialStr = "79.1.15";
var specialStr = "81.1.15";
var content = random.getRandomString(contentLength, specialStr);
async.series([
@ -495,12 +490,12 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content, specialStr, true, cb);
}
], done);
}); // 79.1.15
}); // 81.1.15
it('79.1.16 works with String length (10MB + 1)', function(done) {
var id = getID();
it('81.1.16 works with String length (10MB + 1)', function(done) {
var id = insertID++;
var contentLength = 10485761; // 10 * 1024 * 1024 + 1;
var specialStr = "79.1.16";
var specialStr = "81.1.16";
var content = random.getRandomString(contentLength, specialStr);
async.series([
@ -511,10 +506,10 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content, specialStr, true, cb);
}
], done);
}); // 79.1.16
}); // 81.1.16
it('79.1.17 bind value and type mismatch', function(done) {
var id = getID();
it('81.1.17 bind value and type mismatch', function(done) {
var id = insertID++;
var content = 100;
connection.execute(
@ -530,12 +525,12 @@ describe('79.clobDMLBindAsString.js', function() {
done();
}
);
}); // 79.1.17
}); // 81.1.17
it('79.1.18 mixing named with positional binding', function(done) {
var id = getID();
it('81.1.18 mixing named with positional binding', function(done) {
var id = insertID++;
var contentLength = 40000;
var specialStr = "79.1.18";
var specialStr = "81.1.18";
var content = random.getRandomString(contentLength, specialStr);
async.series([
@ -556,10 +551,10 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content, specialStr, true, cb);
}
], done);
}); // 79.1.18
}); // 81.1.18
it('79.1.19 bind with invalid CLOB', function(done) {
var id = getID();
it('81.1.19 bind with invalid CLOB', function(done) {
var id = insertID++;
connection.execute(
"INSERT INTO nodb_dml_clob_1 VALUES (:1, :2)",
@ -573,12 +568,12 @@ describe('79.clobDMLBindAsString.js', function() {
done();
}
);
}); // 79.1.19
}); // 81.1.19
it('79.1.20 RETURNING INTO with bind type STRING', function(done) {
var id = getID();
it('81.1.20 RETURNING INTO with bind type STRING', function(done) {
var id = insertID++;
var contentLength = 400;
var specialStr = "79.1.20";
var specialStr = "81.1.20";
var content = random.getRandomString(contentLength, specialStr);
var sql = "INSERT INTO nodb_dml_clob_1 (id, clob) VALUES (:i, :c) RETURNING clob INTO :lobbv";
@ -604,10 +599,10 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content, specialStr, false, cb);
}
], done);
}); // 79.1.20
}); // 81.1.20
it('79.1.21 Negative: RETURNING INTO with autocommit on', function(done) {
var id = getID();
it('81.1.21 Negative: RETURNING INTO with autocommit on', function(done) {
var id = insertID++;
var sql = "INSERT INTO nodb_dml_clob_1 (id, clob) VALUES (:i, EMPTY_CLOB()) RETURNING clob INTO :lobbv";
var inFileName = './test/clobexample.txt';
@ -641,12 +636,12 @@ describe('79.clobDMLBindAsString.js', function() {
inStream.pipe(lob); // copies the text to the CLOB
}
);
}); // 79.1.21
}); // 81.1.21
it('79.1.22 works with bind in maxSize smaller than string length', function(done) {
var id = getID();
it('81.1.22 works with bind in maxSize smaller than string length', function(done) {
var id = insertID++;
var contentLength = 32768;
var specialStr = "79.1.22";
var specialStr = "81.1.22";
var content = random.getRandomString(contentLength, specialStr);
async.series([
@ -668,11 +663,11 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content, specialStr, false, cb);
}
], done);
}); // 79.1.22
}); // 81.1.22
}); // 79.1
}); // 81.1
describe('79.2 CLOB, UPDATE', function() {
describe('81.2 CLOB, UPDATE', function() {
insertID = 0;
before(function(done) {
@ -683,11 +678,11 @@ describe('79.clobDMLBindAsString.js', function() {
executeSQL(sql2DropTable1, done);
}); // after
it('79.2.1 update EMPTY_CLOB column', function(done) {
var id = getID();
it('81.2.1 update EMPTY_CLOB column', function(done) {
var id = insertID++;
var content_1 = "EMPTY_CLOB";
var contentLength_2 = 32768;
var specialStr_2 = "79.2.1";
var specialStr_2 = "81.2.1";
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
async.series([
@ -704,12 +699,12 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content_2, specialStr_2, false, cb);
}
], done);
}); // 79.2.1
}); // 81.2.1
it('79.2.2 update a cloumn with EMPTY_CLOB', function(done) {
var id = getID();
it('81.2.2 update a cloumn with EMPTY_CLOB', function(done) {
var id = insertID++;
var contentLength_1 = 50000;
var specialStr_1 = "79.2.2";
var specialStr_1 = "81.2.2";
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
var content_2 = "EMPTY_CLOB";
@ -727,10 +722,10 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content_2, null, false, cb);
}
], done);
}); // 79.2.2
}); // 81.2.2
it('79.2.3 update EMPTY_CLOB column with empty string', function(done) {
var id = getID();
it('81.2.3 update EMPTY_CLOB column with empty string', function(done) {
var id = insertID++;
var content_1 = "EMPTY_CLOB";
var content_2 = "";
@ -748,13 +743,13 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content_2, null, false, cb);
}
], done);
}); // 79.2.3
}); // 81.2.3
it('79.2.4 update empty string column', function(done) {
var id = getID();
it('81.2.4 update empty string column', function(done) {
var id = insertID++;
var content_1 = "";
var contentLength_2 = 54321;
var specialStr_2 = "79.2.4";
var specialStr_2 = "81.2.4";
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
async.series([
@ -771,12 +766,12 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content_2, specialStr_2, false, cb);
}
], done);
}); // 79.2.4
}); // 81.2.4
it('79.2.5 update a column with empty string', function(done) {
var id = getID();
it('81.2.5 update a column with empty string', function(done) {
var id = insertID++;
var contentLength_1 = 50000;
var specialStr_1 = "79.2.2";
var specialStr_1 = "81.2.2";
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
var content_2 = "";
@ -794,15 +789,15 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content_2, null, false, cb);
}
], done);
}); // 79.2.5
}); // 81.2.5
it('79.2.6 update a column with (10MB + 1) string', function(done) {
var id = getID();
it('81.2.6 update a column with (10MB + 1) string', function(done) {
var id = insertID++;
var contentLength_1 = 50000;
var specialStr_1 = "79.2.6_1";
var specialStr_1 = "81.2.6_1";
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
var contentLength_2 = 10485761; // 10 * 1024 * 1024 + 1;
var specialStr_2 = "79.2.6_2";
var specialStr_2 = "81.2.6_2";
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
async.series([
@ -819,7 +814,7 @@ describe('79.clobDMLBindAsString.js', function() {
checkInsertResult(id, content_2, specialStr_2, true, cb);
}
], done);
}); // 79.2.6
}); // 81.2.6
}); // 79.2
}); // 81.2
});

View File

@ -37,14 +37,15 @@ var oracledb = require('oracledb');
var should = require('should');
var async = require('async');
var dbConfig = require('./dbconfig.js');
var fs = require('fs');
var random = require('./random.js');
var fs = require('fs');
var random = require('./random.js');
describe('74.clobPlsqlBindAsString_bindin.js', function() {
describe('74. clobPlsqlBindAsString_bindin.js', function() {
this.timeout(100000);
var connection = null;
var client11gPlus = true; // assume instant client runtime version is greater than 11.2.0.4.0
var insertID = 1; // assume id for insert into db starts from 1
var proc_clob_in_tab = "BEGIN \n" +
" DECLARE \n" +
" e_table_missing EXCEPTION; \n" +
@ -311,13 +312,6 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
});
};
// Generate id for insert clob into db
var insertID = 0;
var getID = function() {
insertID = insertID + 1;
return insertID;
};
describe('74.1 CLOB, PLSQL, BIND_IN', function() {
var proc = "CREATE OR REPLACE PROCEDURE nodb_clobs_in_741 (clob_id IN NUMBER, clob_in IN CLOB)\n" +
"AS \n" +
@ -343,7 +337,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
}); // after
it('74.1.1 works with EMPTY_CLOB', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_IN }
@ -368,7 +362,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
}); // 74.1.1
it('74.1.2 works with EMPTY_CLOB and bind in maxSize set to 1', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 1 }
@ -393,7 +387,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
}); // 74.1.2
it('74.1.3 works with EMPTY_CLOB and bind in maxSize set to (64K - 1)', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 65535 }
@ -418,7 +412,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
}); // 74.1.3
it('74.1.4 works with null', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: null, type: oracledb.STRING, dir: oracledb.BIND_IN }
@ -437,7 +431,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
}); // 74.1.4
it('74.1.5 works with null and bind in maxSize set to 1', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: null, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 1 }
@ -456,7 +450,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
}); // 74.1.5
it('74.1.6 works with null and bind in maxSize set to (64K - 1)', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: null, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 65535 }
@ -475,7 +469,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
}); // 74.1.6
it('74.1.7 works with empty string', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: '', type: oracledb.STRING, dir: oracledb.BIND_IN}
@ -494,7 +488,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
}); // 74.1.7
it('74.1.8 works with empty string and bind in maxSize set to 1', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: '', type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 1}
@ -513,7 +507,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
}); // 74.1.8
it('74.1.9 works with empty string and bind in maxSize set to (64K - 1)', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: '', type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 65535}
@ -532,7 +526,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
}); // 74.1.9
it('74.1.10 works with undefined', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: undefined, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 50000 }
@ -551,7 +545,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
}); // 74.1.10
it('74.1.11 works with undefined and bind in maxSize set to 1', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: undefined, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 1 }
@ -570,7 +564,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
}); // 74.1.11
it('74.1.12 works with undefined and bind in maxSize set to (64K - 1)', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: undefined, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 65535 }
@ -589,7 +583,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
}); // 74.1.12
it('74.1.13 works with NaN', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: NaN, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 50000 }
@ -609,7 +603,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
}); // 74.1.13
it('74.1.14 works with 0', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: 0, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 50000 }
@ -632,7 +626,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
// Driver already supports CLOB AS STRING and BLOB AS BUFFER for PLSQL BIND if the data size less than or equal to 32767.
// As part of this enhancement, driver allows even if data size more than 32767 for both column types
var len = 32768;
var sequence = getID();
var sequence = insertID++;
var specialStr = "74.1.15";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
@ -658,8 +652,8 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
// 11.2 libraries is 64 Kb. With Oracle Client 12, the limit is 1 Gb
var len = 65535;
var sequence = getID();
var specialStr = "74.1.6";
var sequence = insertID++;
var specialStr = "74.1.16";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
@ -680,7 +674,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
it('74.1.17 works with String length (64K + 1)', function(done) {
var len = 65537;
var sequence = getID();
var sequence = insertID++;
var specialStr = "74.1.17";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
@ -702,7 +696,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
it('74.1.18 works with String length (1MB + 1)', function(done) {
var len = 1048577; // 1 * 1024 * 1024 + 1
var sequence = getID();
var sequence = insertID++;
var specialStr = "74.1.18";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
@ -724,7 +718,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
it('74.1.19 works with String length (5MB + 1)', function(done) {
var len = 5242881; // 5 * 1024 * 1024 + 1;
var sequence = getID();
var sequence = insertID++;
var specialStr = "74.1.19";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
@ -746,7 +740,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
it('74.1.20 works with String length (10MB + 1)', function(done) {
var len = 10485761; // 10 * 1024 * 1024 + 1;
var sequence = getID();
var sequence = insertID++;
var specialStr = "74.1.20";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
@ -767,7 +761,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
}); // 74.1.20
it('74.1.21 works with bind value and type mismatch', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: 20, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 50000 }
@ -789,7 +783,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
it('74.1.22 mixing named with positional binding', function(done) {
var sqlRun_7419 = "BEGIN nodb_clobs_in_741 (:1, :2); END;";
var len = 50000;
var sequence = getID();
var sequence = insertID++;
var specialStr = "74.1.22";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = [ sequence, { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 50000 } ];
@ -807,7 +801,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
}); // 74.1.22
it('74.1.23 works with invalid CLOB', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: {}, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 5000 }
@ -828,7 +822,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
it('74.1.24 works with bind in maxSize smaller than string length', function(done) {
var len = 50000;
var sequence = getID();
var sequence = insertID++;
var specialStr = "74.1.24";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
@ -860,7 +854,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
var sqlRun_74123 = "BEGIN :o := nodb_clobs_in_74123(:i, :c); END;";
var proc_drop_74123 = "DROP FUNCTION nodb_clobs_in_74123";
var len = 500;
var sequence = getID();
var sequence = insertID++;
var specialStr = "74.1.25";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
@ -900,7 +894,7 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
"END nodb_clobs_in_74124; ";
var sqlRun_74124 = "BEGIN nodb_clobs_in_74124 (:i, :c1, :c2); END;";
var proc_drop_74124 = "DROP PROCEDURE nodb_clobs_in_74124";
var sequence = getID();
var sequence = insertID++;
var len_1 = 5000;
var specialStr_1 = "74.1.26_1";
var clobStr_1 = random.getRandomString(len_1, specialStr_1);
@ -940,7 +934,454 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
}); // 74.1
describe('74.2 Multiple CLOBs, BIND_IN', function() {
describe('74.2 CLOB, PLSQL, BIND_IN to VARCHAR2', function() {
var proc = "CREATE OR REPLACE PROCEDURE nodb_clobs_in_741 (clob_id IN NUMBER, clob_in IN VARCHAR2)\n" +
"AS \n" +
"BEGIN \n" +
" insert into nodb_tab_clob_in (id, clob_1) values (clob_id, clob_in); \n" +
"END nodb_clobs_in_741; ";
var sqlRun = "BEGIN nodb_clobs_in_741 (:i, :c); END;";
var proc_drop = "DROP PROCEDURE nodb_clobs_in_741";
var proc_7411 = "CREATE OR REPLACE PROCEDURE nodb_clobs_in_7411 (clob_id IN NUMBER, clob_in IN VARCHAR2)\n" +
"AS \n" +
"BEGIN \n" +
" insert into nodb_tab_clob_in (id, clob_1) values (clob_id, EMPTY_CLOB()); \n" +
"END nodb_clobs_in_7411; ";
var sqlRun_7411 = "BEGIN nodb_clobs_in_7411 (:i, :c); END;";
var proc_drop_7411 = "DROP PROCEDURE nodb_clobs_in_7411";
before(function(done) {
executeSQL(proc, done);
}); // before
after(function(done) {
executeSQL(proc_drop, done);
}); // after
it('74.2.1 works with EMPTY_CLOB', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_IN }
};
var option = { autoCommit: true };
async.series([
function(cb) {
executeSQL(proc_7411, cb);
},
function(cb) {
plsqlBindIn(sqlRun_7411, bindVar, option, false, client11gPlus, cb);
},
function(cb) {
var sql = "select clob_1 from nodb_tab_clob_in where id = " + sequence;
compareBindInResult(sql, "", null, false, client11gPlus, cb);
},
function(cb) {
executeSQL(proc_drop_7411, cb);
}
], done);
}); // 74.2.1
it('74.2.2 works with EMPTY_CLOB and bind in maxSize set to 1', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 1 }
};
var option = { autoCommit: true };
async.series([
function(cb) {
executeSQL(proc_7411, cb);
},
function(cb) {
plsqlBindIn(sqlRun_7411, bindVar, option, false, client11gPlus, cb);
},
function(cb) {
var sql = "select clob_1 from nodb_tab_clob_in where id = " + sequence;
compareBindInResult(sql, "", null, false, client11gPlus, cb);
},
function(cb) {
executeSQL(proc_drop_7411, cb);
}
], done);
}); // 74.2.2
it('74.2.3 works with EMPTY_CLOB and bind in maxSize set to (64K - 1)', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 65535 }
};
var option = { autoCommit: true };
async.series([
function(cb) {
executeSQL(proc_7411, cb);
},
function(cb) {
plsqlBindIn(sqlRun_7411, bindVar, option, false, client11gPlus, cb);
},
function(cb) {
var sql = "select clob_1 from nodb_tab_clob_in where id = " + sequence;
compareBindInResult(sql, "", null, false, client11gPlus, cb);
},
function(cb) {
executeSQL(proc_drop_7411, cb);
}
], done);
}); // 74.2.3
it('74.2.4 works with null', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: null, type: oracledb.STRING, dir: oracledb.BIND_IN }
};
var option = { autoCommit: true };
async.series([
function(cb) {
plsqlBindIn(sqlRun, bindVar, option, false, client11gPlus, cb);
},
function(cb) {
var sql = "select clob_1 from nodb_tab_clob_in where id = " + sequence;
compareBindInResult(sql, null, null, false, client11gPlus, cb);
}
], done);
}); // 74.2.4
it('74.2.5 works with null and bind in maxSize set to 1', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: null, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 1 }
};
var option = { autoCommit: true };
async.series([
function(cb) {
plsqlBindIn(sqlRun, bindVar, option, false, client11gPlus, cb);
},
function(cb) {
var sql = "select clob_1 from nodb_tab_clob_in where id = " + sequence;
compareBindInResult(sql, null, null, false, client11gPlus, cb);
}
], done);
}); // 74.2.5
it('74.2.6 works with null and bind in maxSize set to (64K - 1)', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: null, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 65535 }
};
var option = { autoCommit: true };
async.series([
function(cb) {
plsqlBindIn(sqlRun, bindVar, option, false, client11gPlus, cb);
},
function(cb) {
var sql = "select clob_1 from nodb_tab_clob_in where id = " + sequence;
compareBindInResult(sql, null, null, false, client11gPlus, cb);
}
], done);
}); // 74.2.6
it('74.2.7 works with empty string', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: '', type: oracledb.STRING, dir: oracledb.BIND_IN}
};
var option = { autoCommit: true };
async.series([
function(cb) {
plsqlBindIn(sqlRun, bindVar, option, false, client11gPlus, cb);
},
function(cb) {
var sql = "select clob_1 from nodb_tab_clob_in where id = " + sequence;
compareBindInResult(sql, null, null, false, client11gPlus, cb);
}
], done);
}); // 74.2.7
it('74.2.8 works with empty string and bind in maxSize set to 1', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: '', type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 1}
};
var option = { autoCommit: true };
async.series([
function(cb) {
plsqlBindIn(sqlRun, bindVar, option, false, client11gPlus, cb);
},
function(cb) {
var sql = "select clob_1 from nodb_tab_clob_in where id = " + sequence;
compareBindInResult(sql, null, null, false, client11gPlus, cb);
}
], done);
}); // 74.2.8
it('74.2.9 works with empty string and bind in maxSize set to (64K - 1)', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: '', type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 65535}
};
var option = { autoCommit: true };
async.series([
function(cb) {
plsqlBindIn(sqlRun, bindVar, option, false, client11gPlus, cb);
},
function(cb) {
var sql = "select clob_1 from nodb_tab_clob_in where id = " + sequence;
compareBindInResult(sql, null, null, false, client11gPlus, cb);
}
], done);
}); // 74.2.9
it('74.2.10 works with undefined', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: undefined, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 50000 }
};
var option = { autoCommit: true };
async.series([
function(cb) {
plsqlBindIn(sqlRun, bindVar, option, false, client11gPlus, cb);
},
function(cb) {
var sql = "select clob_1 from nodb_tab_clob_in where id = " + sequence;
compareBindInResult(sql, null, null, false, client11gPlus, cb);
}
], done);
}); // 74.2.10
it('74.2.11 works with undefined and bind in maxSize set to 1', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: undefined, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 1 }
};
var option = { autoCommit: true };
async.series([
function(cb) {
plsqlBindIn(sqlRun, bindVar, option, false, client11gPlus, cb);
},
function(cb) {
var sql = "select clob_1 from nodb_tab_clob_in where id = " + sequence;
compareBindInResult(sql, null, null, false, client11gPlus, cb);
}
], done);
}); // 74.2.11
it('74.2.12 works with undefined and bind in maxSize set to (64K - 1)', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: undefined, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 65535 }
};
var option = { autoCommit: true };
async.series([
function(cb) {
plsqlBindIn(sqlRun, bindVar, option, false, client11gPlus, cb);
},
function(cb) {
var sql = "select clob_1 from nodb_tab_clob_in where id = " + sequence;
compareBindInResult(sql, null, null, false, client11gPlus, cb);
}
], done);
}); // 74.2.12
it('74.2.13 works with NaN', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: NaN, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 50000 }
};
connection.execute(
sqlRun,
bindVar,
{ autoCommit: true },
function(err) {
should.exist(err);
// NJS-011: encountered bind value and type mismatch in parameter 2
(err.message).should.startWith('NJS-011:');
done();
}
);
}); // 74.2.13
it('74.2.14 works with 0', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: 0, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 50000 }
};
connection.execute(
sqlRun,
bindVar,
{ autoCommit: true },
function(err) {
should.exist(err);
// NJS-011: encountered bind value and type mismatch in parameter 2
(err.message).should.startWith('NJS-011:');
done();
}
);
}); // 74.2.14
it('74.2.15 works with String length (32K - 1)', function(done) {
var len = 32767;
var sequence = insertID++;
var specialStr = "74.2.15";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
};
var option = { autoCommit: true };
async.series([
function(cb) {
plsqlBindIn(sqlRun, bindVar, option, false, client11gPlus, cb);
},
function(cb) {
var sql = "select clob_1 from nodb_tab_clob_in where id = " + sequence;
compareBindInResult(sql, clobStr, specialStr, false, client11gPlus, cb);
}
], done);
}); // 74.2.15
it('74.2.16 works with String length 32K', function(done) {
var len = 32768;
var sequence = insertID++;
var specialStr = "74.2.16";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len }
};
var option = { autoCommit: true };
connection.execute(
sqlRun,
bindVar,
option,
function(err) {
should.exist(err);
// ORA-06502: PL/SQL: numeric or value error
(err.message).should.startWith('ORA-06502:');
done();
}
);
}); // 74.2.16
it('74.2.17 works with invalid CLOB', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: {}, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: 5000 }
};
connection.execute(
sqlRun,
bindVar,
{ autoCommit: true },
function(err) {
should.exist(err);
// NJS-012: encountered invalid bind datatype in parameter 2
(err.message).should.startWith('NJS-012:');
done();
}
);
}); // 74.2.17
it('74.2.18 works with bind in maxSize smaller than string length', function(done) {
var len = 500;
var sequence = insertID++;
var specialStr = "74.2.18";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: clobStr, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len - 1 }
};
var option = { autoCommit: true };
async.series([
function(cb) {
plsqlBindIn(sqlRun, bindVar, option, false, client11gPlus, cb);
},
function(cb) {
var sql = "select clob_1 from nodb_tab_clob_in where id = " + sequence;
compareBindInResult(sql, clobStr, specialStr, false, client11gPlus, cb);
}
], done);
}); // 74.2.18
it('74.2.19 works with UPDATE', function(done) {
var proc_74219 = "CREATE OR REPLACE PROCEDURE nodb_clobs_in_74219 (clob_id IN NUMBER, clob_in IN VARCHAR2, clob_update IN VARCHAR2)\n" +
"AS \n" +
"BEGIN \n" +
" insert into nodb_tab_clob_in (id, clob_1) values (clob_id, clob_in); \n" +
" update nodb_tab_clob_in set clob_1 = clob_update where id = clob_id; \n" +
"END nodb_clobs_in_74219; ";
var sqlRun_74219 = "BEGIN nodb_clobs_in_74219 (:i, :c1, :c2); END;";
var proc_drop_74219 = "DROP PROCEDURE nodb_clobs_in_74219";
var sequence = insertID++;
var len_1 = 3000;
var specialStr_1 = "74.2.19_1";
var clobStr_1 = random.getRandomString(len_1, specialStr_1);
var len_2 = 2000;
var specialStr_2 = "74.2.19_2";
var clobStr_2 = random.getRandomString(len_2, specialStr_2);
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c1: { val: clobStr_1, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len_1 },
c2: { val: clobStr_2, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len_2 },
};
var option = { autoCommit: true };
async.series([
function(cb) {
executeSQL(proc_74219, cb);
},
function(cb) {
connection.execute(
sqlRun_74219,
bindVar,
option,
function(err) {
should.not.exist(err);
cb();
});
},
function(cb) {
var sql = "select clob_1 from nodb_tab_clob_in where id = " + sequence;
compareBindInResult(sql, clobStr_2, specialStr_2, false, client11gPlus, cb);
},
function(cb) {
executeSQL(proc_drop_74219, cb);
}
], done);
}); // 74.2.19
}); // 74.2
describe('74.3 Multiple CLOBs, BIND_IN', function() {
var proc = "CREATE OR REPLACE PROCEDURE nodb_lobs_in_742 (clob_id IN NUMBER, clob_1 IN CLOB, clob_2 IN CLOB)\n" +
"AS \n" +
"BEGIN \n" +
@ -957,13 +1398,13 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
executeSQL(proc_drop, done);
}); // after
it('74.2.1 bind two string', function(done) {
var sequence = getID();
it('74.3.1 bind two string', function(done) {
var sequence = insertID++;
var len_1 = 50000;
var specialStr_1 = "74.2.1_1";
var specialStr_1 = "74.3.1_1";
var clobStr_1 = random.getRandomString(len_1, specialStr_1);
var len_2 = 10000;
var specialStr_2 = "74.2.1_2";
var specialStr_2 = "74.3.1_2";
var clobStr_2 = random.getRandomString(len_2, specialStr_2);
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
@ -985,14 +1426,14 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
compareBindInResult(sql_2, clobStr_2, specialStr_2, false, client11gPlus, cb);
}
], done);
}); // 74.2.1
}); // 74.3.1
it('74.2.2 bind a txt file and a string', function(done) {
it('74.3.2 bind a txt file and a string', function(done) {
var preparedCLOBID = 200;
var len_1 = 50000;
var specialStr_1 = "74.2.2";
var specialStr_1 = "74.3.2";
var clobStr_1 = random.getRandomString(len_1, specialStr_1);
var sequence = getID();
var sequence = insertID++;
async.series([
function(cb) {
@ -1033,15 +1474,15 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
verifyClobValueWithFileData(sql_2, cb);
}
], done);
}); // 74.2.2
}); // 74.3.2
it('74.2.3 bind two string, one > (64K - 1)', function(done) {
var sequence = getID();
it('74.3.3 bind two string, one > (64K - 1)', function(done) {
var sequence = insertID++;
var len_1 = 65538;
var specialStr_1 = "74.2.3_1";
var specialStr_1 = "74.3.3_1";
var clobStr_1 = random.getRandomString(len_1, specialStr_1);
var len_2 = 10000;
var specialStr_2 = "74.2.3_2";
var specialStr_2 = "74.3.3_2";
var clobStr_2 = random.getRandomString(len_2, specialStr_2);
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
@ -1063,8 +1504,8 @@ describe('74.clobPlsqlBindAsString_bindin.js', function() {
compareBindInResult(sql_2, clobStr_2, specialStr_2, true, client11gPlus, cb);
}
], done);
}); // 74.2.3
}); // 74.3.3
}); // 74.2
}); // 74.3
}); // 74

View File

@ -37,14 +37,15 @@ var oracledb = require('oracledb');
var should = require('should');
var async = require('async');
var dbConfig = require('./dbconfig.js');
var fs = require('fs');
var random = require('./random.js');
var fs = require('fs');
var random = require('./random.js');
describe('76.clobPlsqlBindAsString_bindinout.js', function() {
describe('76. clobPlsqlBindAsString_bindinout.js', function() {
this.timeout(100000);
var connection = null;
var client11gPlus = true; // assume instant client runtime version is greater than 11.2.0.4.0
var insertID = 1; // assume id for insert into db starts from 1
var proc_clob_in_tab = "BEGIN \n" +
" DECLARE \n" +
" e_table_missing EXCEPTION; \n" +
@ -215,11 +216,29 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
should.strictEqual(resultVal.substring(resultLength - specStrLength, resultLength), specialStr);
};
// Generate id for insert clob into db
var insertID = 0;
var getID = function() {
insertID = insertID + 1;
return insertID;
// execute plsql bind in out procedure, and verify the plsql bind out string
var plsqlBindInOut = function(sqlRun, bindVar, originalStr, specialStr, case64KPlus, client11gPlus, callback) {
connection.execute(
sqlRun,
bindVar,
function(err, result) {
if(client11gPlus === false && case64KPlus === true){
should.exist(err);
// NJS-051: "maxSize" must be less than 65535
(err.message).should.startWith('NJS-051:');
callback();
} else {
should.not.exist(err);
var resultVal = result.outBinds.io;
if(originalStr == 'EMPTY_CLOB' || originalStr == null || originalStr == "" || originalStr == undefined) {
should.strictEqual(resultVal, null);
} else {
compareResultStrAndOriginal(resultVal, originalStr, specialStr);
}
callback();
}
}
);
};
describe('76.1 CLOB, PLSQL, BIND_INOUT', function() {
@ -248,33 +267,8 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
executeSQL(proc_drop, done);
}); // after
// execute plsql bind in out procedure, and verify the plsql bind out string
var plsqlBindInOut = function(sqlRun, bindVar, originalStr, specialStr, case64KPlus, client11gPlus, callback) {
connection.execute(
sqlRun,
bindVar,
function(err, result) {
if(client11gPlus === false && case64KPlus === true){
should.exist(err);
// NJS-051: "maxSize" must be less than 65535
(err.message).should.startWith('NJS-051:');
callback();
} else {
should.not.exist(err);
var resultVal = result.outBinds.io;
if(originalStr == 'EMPTY_CLOB' || originalStr == null || originalStr == "" || originalStr == undefined) {
should.strictEqual(resultVal, null);
} else {
compareResultStrAndOriginal(resultVal, originalStr, specialStr);
}
callback();
}
}
);
};
it('76.1.1 works with EMPTY_CLOB', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { dir: oracledb.BIND_INOUT, type: oracledb.STRING }
@ -294,7 +288,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.1
it('76.1.2 works with EMPTY_CLOB and maxSize set to 1', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 1 }
@ -314,7 +308,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.2
it('76.1.3 works with EMPTY_CLOB and maxSize set to (64K - 1)', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 65535 }
@ -334,7 +328,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.3
it('76.1.4 works with null', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: null, dir: oracledb.BIND_INOUT, type: oracledb.STRING }
@ -344,7 +338,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.4
it('76.1.5 works with null and maxSize set to 1', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: null, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 1 }
@ -354,7 +348,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.5
it('76.1.6 works with null and maxSize set to (64K - 1)', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: null, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 65535 }
@ -364,7 +358,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.6
it('76.1.7 works with empty string', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: "", dir: oracledb.BIND_INOUT, type: oracledb.STRING }
@ -374,7 +368,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.7
it('76.1.8 works with empty string and maxSize set to 1', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: "", dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 1 }
@ -384,7 +378,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.8
it('76.1.9 works with empty string and maxSize set to (64K - 1)', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: "", dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 65535 }
@ -394,7 +388,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.9
it('76.1.10 works with undefined', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: undefined, dir: oracledb.BIND_INOUT, type: oracledb.STRING }
@ -404,7 +398,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.10
it('76.1.11 works with undefined and maxSize set to 1', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: undefined, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 1 }
@ -414,7 +408,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.11
it('76.1.12 works with undefined and maxSize set to (64K - 1)', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: undefined, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 65535 }
@ -424,7 +418,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.12
it('76.1.13 works with NaN', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: NaN, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 65535 }
@ -443,7 +437,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.13
it('76.1.14 works with 0', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: 0, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 65535 }
@ -465,7 +459,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
var specialStr = "76.1.15";
var len = 32768;
var clobVal = random.getRandomString(len, specialStr);
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: clobVal, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: len }
@ -475,7 +469,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.15
it('76.1.16 works with String length (64K - 1)', function(done) {
var sequence = getID();
var sequence = insertID++;
var specialStr = "76.1.16";
var len = 65535;
var clobVal = random.getRandomString(len, specialStr);
@ -488,7 +482,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.16
it('76.1.17 works with String length (64K + 1)', function(done) {
var sequence = getID();
var sequence = insertID++;
var specialStr = "76.1.17";
var len = 65537;
var clobVal = random.getRandomString(len, specialStr);
@ -501,7 +495,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.17
it('76.1.18 works with String length (1MB + 1)', function(done) {
var sequence = getID();
var sequence = insertID++;
var specialStr = "76.1.18";
var len = 1048577; // 1 * 1024 * 1024 + 1
var clobVal = random.getRandomString(len, specialStr);
@ -514,7 +508,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.18
it('76.1.19 works with String length (5MB + 1)', function(done) {
var sequence = getID();
var sequence = insertID++;
var specialStr = "76.1.19";
var len = 5242881; // 5 * 1024 * 1024 + 1;
var clobVal = random.getRandomString(len, specialStr);
@ -527,7 +521,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.19
it('76.1.20 works with String length (10MB + 1)', function(done) {
var sequence = getID();
var sequence = insertID++;
var specialStr = "76.1.20";
var len = 10485761; // 10 * 1024 * 1024 + 1;
var clobVal = random.getRandomString(len, specialStr);
@ -540,7 +534,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.20
it('76.1.21 works with bind value and type mismatch', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: 10, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 65535 }
@ -559,7 +553,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.21
it('76.1.22 mixing named with positional binding', function(done) {
var sequence = getID();
var sequence = insertID++;
var specialStr = "76.1.20";
var len = 50000;
var clobVal = random.getRandomString(len, specialStr);
@ -578,7 +572,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.22
it('76.1.23 works with bind out maxSize smaller than string length', function(done) {
var sequence = getID();
var sequence = insertID++;
var specialStr = "76.1.23";
var len = 65535;
var clobVal = random.getRandomString(len, specialStr);
@ -593,14 +587,14 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
function(err) {
should.exist(err);
// NJS-016: buffer is too small for OUT binds
(err.message).should.startWith('NJS-016');
(err.message).should.startWith('NJS-016:');
done();
}
);
}); // 76.1.23
it('76.1.24 works with UPDATE', function(done) {
var sequence = getID();
var sequence = insertID++;
var len_1 = 50000;
var specialStr_1 = "76.1.24_1";
var clobVal_1 = random.getRandomString(len_1, specialStr_1);
@ -637,7 +631,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
}); // 76.1.24
it('76.1.25 works with invalid CLOB', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: {}, dir: oracledb.BIND_INOUT, type: oracledb.STRING }
@ -664,7 +658,7 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
"END nodb_clob_in_out_74126;";
var sqlRun_76126 = "begin nodb_clob_in_out_74126(:i, :io); end;";
var proc_drop_76126 = "DROP PROCEDURE nodb_clob_in_out_74126";
var sequence = getID();
var sequence = insertID++;
var len = 32768;
var specialStr = '76.1.26';
var clobStr = random.getRandomString(len, specialStr);
@ -697,11 +691,384 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
executeSQL(proc_drop_76126, cb);
}
], done);
}); // 76.26
}); // 76.1.26
}); // 76.1
describe('76.2 Multiple CLOBs, BIND INOUT', function() {
describe('76.2 CLOB, PLSQL, BIND_INOUT to VARCHAR2', function() {
var proc = "CREATE OR REPLACE PROCEDURE nodb_clob_in_out_743 (lob_id IN NUMBER, lob_in_out IN OUT VARCHAR2) \n" +
"AS \n" +
"BEGIN \n" +
" insert into nodb_tab_clob_in (id, clob_1) values (lob_id, lob_in_out); \n" +
" select clob_1 into lob_in_out from nodb_tab_clob_in where id = lob_id; \n" +
"END nodb_clob_in_out_743;";
var sqlRun = "begin nodb_clob_in_out_743(:i, :io); end;";
var proc_drop = "DROP PROCEDURE nodb_clob_in_out_743";
var proc_7421 = "CREATE OR REPLACE PROCEDURE nodb_clob_in_out_7421 (lob_id IN NUMBER, lob_in_out IN OUT VARCHAR2) \n" +
"AS \n" +
"BEGIN \n" +
" insert into nodb_tab_clob_in (id, clob_1) values (lob_id, EMPTY_CLOB()); \n" +
" select clob_1 into lob_in_out from nodb_tab_clob_in where id = lob_id; \n" +
"END nodb_clob_in_out_7421;";
var sqlRun_7421 = "begin nodb_clob_in_out_7421(:i, :io); end;";
var proc_drop_7421 = "DROP PROCEDURE nodb_clob_in_out_7421";
before(function(done) {
executeSQL(proc, done);
}); // before
after(function(done) {
executeSQL(proc_drop, done);
}); // after
it('76.2.1 works with EMPTY_CLOB', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { dir: oracledb.BIND_INOUT, type: oracledb.STRING }
};
async.series([
function(cb) {
executeSQL(proc_7421, cb);
},
function(cb) {
plsqlBindInOut(sqlRun_7421, bindVar, 'EMPTY_CLOB', null, false, client11gPlus, cb);
},
function(cb) {
executeSQL(proc_drop_7421, cb);
}
], done);
}); // 76.2.1
it('76.2.2 works with EMPTY_CLOB and maxSize set to 1', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 1 }
};
async.series([
function(cb) {
executeSQL(proc_7421, cb);
},
function(cb) {
plsqlBindInOut(sqlRun_7421, bindVar, 'EMPTY_CLOB', null, false, client11gPlus, cb);
},
function(cb) {
executeSQL(proc_drop_7421, cb);
}
], done);
}); // 76.2.2
it('76.2.3 works with EMPTY_CLOB and maxSize set to (64K - 1)', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 65535 }
};
async.series([
function(cb) {
executeSQL(proc_7421, cb);
},
function(cb) {
plsqlBindInOut(sqlRun_7421, bindVar, 'EMPTY_CLOB', null, false, client11gPlus, cb);
},
function(cb) {
executeSQL(proc_drop_7421, cb);
}
], done);
}); // 76.2.3
it('76.2.4 works with null', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: null, dir: oracledb.BIND_INOUT, type: oracledb.STRING }
};
plsqlBindInOut(sqlRun, bindVar, null, null, false, client11gPlus, done);
}); // 76.2.4
it('76.2.5 works with null and maxSize set to 1', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: null, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 1 }
};
plsqlBindInOut(sqlRun, bindVar, null, null, false, client11gPlus, done);
}); // 76.2.5
it('76.2.6 works with null and maxSize set to (64K - 1)', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: null, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 65535 }
};
plsqlBindInOut(sqlRun, bindVar, null, null, false, client11gPlus, done);
}); // 76.2.6
it('76.2.7 works with empty string', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: "", dir: oracledb.BIND_INOUT, type: oracledb.STRING }
};
plsqlBindInOut(sqlRun, bindVar, "", null, false, client11gPlus, done);
}); // 76.2.7
it('76.2.8 works with empty string and maxSize set to 1', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: "", dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 1 }
};
plsqlBindInOut(sqlRun, bindVar, "", null, false, client11gPlus, done);
}); // 76.2.8
it('76.2.9 works with empty string and maxSize set to (64K - 1)', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: "", dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 65535 }
};
plsqlBindInOut(sqlRun, bindVar, "", null, false, client11gPlus, done);
}); // 76.2.9
it('76.2.10 works with undefined', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: undefined, dir: oracledb.BIND_INOUT, type: oracledb.STRING }
};
plsqlBindInOut(sqlRun, bindVar, undefined, null, false, client11gPlus, done);
}); // 76.2.10
it('76.2.11 works with undefined and maxSize set to 1', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: undefined, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 1 }
};
plsqlBindInOut(sqlRun, bindVar, undefined, null, false, client11gPlus, done);
}); // 76.2.11
it('76.2.12 works with undefined and maxSize set to (64K - 1)', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: undefined, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 65535 }
};
plsqlBindInOut(sqlRun, bindVar, undefined, null, false, client11gPlus, done);
}); // 76.2.12
it('76.2.13 works with NaN', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: NaN, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 65535 }
};
connection.execute(
sqlRun,
bindVar,
function(err) {
should.exist(err);
// NJS-011: encountered bind value and type mismatch in parameter 2
(err.message).should.startWith('NJS-011:');
done();
}
);
}); // 76.2.13
it('76.2.14 works with 0', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: 0, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: 65535 }
};
connection.execute(
sqlRun,
bindVar,
function(err) {
should.exist(err);
// NJS-011: encountered bind value and type mismatch in parameter 2
(err.message).should.startWith('NJS-011:');
done();
}
);
}); // 76.2.14
it('76.2.15 works with String length (32K - 1)', function(done) {
var specialStr = "76.2.15";
var len = 32767;
var clobVal = random.getRandomString(len, specialStr);
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: clobVal, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: len }
};
plsqlBindInOut(sqlRun, bindVar, clobVal, specialStr, false, client11gPlus, done);
}); // 76.2.15
it('76.2.16 works with String length 32K', function(done) {
var sequence = insertID++;
var specialStr = "76.2.16";
var len = 32768;
var clobVal = random.getRandomString(len, specialStr);
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: clobVal, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: len }
};
connection.execute(
sqlRun,
bindVar,
function(err) {
should.exist(err);
// ORA-06502: PL/SQL: numeric or value error
(err.message).should.startWith('ORA-06502:');
done();
}
);
}); // 76.2.16
it('76.2.17 works with bind out maxSize smaller than string length', function(done) {
var sequence = insertID++;
var specialStr = "76.2.17";
var len = 600;
var clobVal = random.getRandomString(len, specialStr);
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: clobVal, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: len - 1 }
};
connection.execute(
sqlRun,
bindVar,
function(err) {
should.exist(err);
// ORA-01460: unimplemented or unreasonable conversion requested
(err.message).should.startWith('ORA-01460:');
done();
}
);
}); // 76.2.17
it('76.2.18 works with UPDATE', function(done) {
var sequence = insertID++;
var len_1 = 500;
var specialStr_1 = "76.2.18_1";
var clobVal_1 = random.getRandomString(len_1, specialStr_1);
var len_2 = 300;
var specialStr_2 = "76.2.18_2";
var clobVal_2 = random.getRandomString(len_2, specialStr_2);
var bindVar = {
id: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
i: { val: clobVal_1, dir: oracledb.BIND_IN, type: oracledb.STRING, maxSize: len_1 },
io: { val: clobVal_2, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: len_2 }
};
var proc_74218 = "CREATE OR REPLACE PROCEDURE nodb_clob_in_out_74218 (lob_id IN NUMBER, lob_in IN VARCHAR2, lob_in_out IN OUT VARCHAR2) \n" +
"AS \n" +
"BEGIN \n" +
" insert into nodb_tab_clob_in (id, clob_1) values (lob_id, lob_in); \n" +
" update nodb_tab_clob_in set clob_1 = lob_in_out where id = lob_id; \n" +
" select clob_1 into lob_in_out from nodb_tab_clob_in where id = lob_id; \n" +
"END nodb_clob_in_out_74218;";
var sqlRun_74218 = "begin nodb_clob_in_out_74218(:id, :i, :io); end;";
var proc_drop_74218 = "DROP PROCEDURE nodb_clob_in_out_74218";
async.series([
function(cb) {
executeSQL(proc_74218, cb);
},
function(cb) {
plsqlBindInOut(sqlRun_74218, bindVar, clobVal_2, specialStr_2, false, client11gPlus, cb);
},
function(cb) {
executeSQL(proc_drop_74218, cb);
}
], done);
}); // 76.2.18
it('76.2.19 works with invalid CLOB', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: {}, dir: oracledb.BIND_INOUT, type: oracledb.STRING }
};
connection.execute(
sqlRun,
bindVar,
function(err) {
should.exist(err);
// NJS-012: encountered invalid bind datatype in parameter 2
(err.message).should.startWith('NJS-012:');
done();
}
);
}); // 76.2.19
it('76.2.20 works with substr', function(done) {
var proc_76220 = "CREATE OR REPLACE PROCEDURE nodb_clob_in_out_74220 (lob_id IN NUMBER, lob_in_out IN OUT CLOB) \n" +
"AS \n" +
"BEGIN \n" +
" insert into nodb_tab_clob_in (id, clob_1) values (lob_id, lob_in_out); \n" +
" select substr(clob_1, 1, 3) into lob_in_out from nodb_tab_clob_in where id = lob_id; \n" +
"END nodb_clob_in_out_74220;";
var sqlRun_76220 = "begin nodb_clob_in_out_74220(:i, :io); end;";
var proc_drop_76220 = "DROP PROCEDURE nodb_clob_in_out_74220";
var sequence = insertID++;
var len = 3000;
var specialStr = '76.2.20';
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
i: { val: sequence, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
io: { val: clobStr, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: len }
};
async.series([
function(cb) {
executeSQL(proc_76220, cb);
},
function(cb) {
connection.execute(
sqlRun_76220,
bindVar,
function(err, result) {
should.not.exist(err);
var resultVal = result.outBinds.io;
// 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.
clobStr = clobStr.substring(0, 3);
should.strictEqual(resultVal.length, 3);
should.strictEqual(resultVal, clobStr);
cb();
}
);
},
function(cb) {
executeSQL(proc_drop_76220, cb);
}
], done);
}); // 76.2.20
}); // 76.2
describe('76.3 Multiple CLOBs, BIND INOUT', function() {
var lobs_proc_inout_762 = "CREATE OR REPLACE PROCEDURE nodb_lobs_in_out_746 (lob_id IN NUMBER, clob_1 IN OUT CLOB, clob_2 IN OUT CLOB) \n" +
"AS \n" +
"BEGIN \n" +
@ -719,12 +1086,12 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
executeSQL(proc_drop_762, done);
}); // after
it('76.2.1 bind a txt file and a 32K string', function(done) {
var specialStr = "76.2.1";
it('76.3.1 bind a txt file and a 32K string', function(done) {
var specialStr = "76.3.1";
var len1 = 32768;
var clobVal = random.getRandomString(len1, specialStr);
var sequence = getID();
var preparedCLOBID = getID();
var sequence = insertID++;
var preparedCLOBID = insertID++;
async.series([
function(cb) {
@ -777,14 +1144,14 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
);
}
], done);
}); // 76.2.1
}); // 76.3.1
it('76.2.2 bind a txt file and a (64K - 1) string', function(done) {
var specialStr = "76.2.2";
it('76.3.2 bind a txt file and a (64K - 1) string', function(done) {
var specialStr = "76.3.2";
var len1 = 65535;
var clobVal = random.getRandomString(len1, specialStr);
var preparedCLOBID = getID();
var sequence = getID();
var preparedCLOBID = insertID++;
var sequence = insertID++;
async.series([
function(cb) {
@ -837,14 +1204,14 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
);
}
], done);
}); // 76.2.2
}); // 76.3.2
it('76.2.3 bind a txt file and a (64K + 1) string', function(done) {
var specialStr = "76.2.3";
it('76.3.3 bind a txt file and a (64K + 1) string', function(done) {
var specialStr = "76.3.3";
var len1 = 65537;
var clobVal = random.getRandomString(len1, specialStr);
var preparedCLOBID = getID();
var sequence = getID();
var preparedCLOBID = insertID++;
var sequence = insertID++;
async.series([
function(cb) {
@ -869,8 +1236,8 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
{ autoCommit: true },
function(err, result) {
if(client11gPlus === false){
// NJS-051: "maxSize" must be less than 65535
should.exist(err);
// NJS-051: "maxSize" must be less than 65535
(err.message).should.startWith('NJS-051:');
} else {
var resultVal = result.outBinds.io1;
@ -902,8 +1269,8 @@ describe('76.clobPlsqlBindAsString_bindinout.js', function() {
);
}
], done);
}); // 76.2.3
}); // 76.3.3
}); // 76.2
}); // 76.3
});

View File

@ -36,15 +36,17 @@
var oracledb = require('oracledb');
var should = require('should');
var async = require('async');
var fs = require('fs');
var dbConfig = require('./dbconfig.js');
var fs = require('fs');
var random = require('./random.js');
var file = require('./file.js');
var random = require('./random.js');
describe('75.clobPlsqlBindAsString_bindout.js', function() {
describe('75. clobPlsqlBindAsString_bindout.js', function() {
this.timeout(100000);
var connection = null;
var client11gPlus = true; // assume instant client runtime version is greater than 11.2.0.4.0
var insertID = 1; // assume id for insert into db starts from 1
var proc_clob_in_tab = "BEGIN \n" +
" DECLARE \n" +
" e_table_missing EXCEPTION; \n" +
@ -114,7 +116,8 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
});
},
function(cb) {
deleteFile(inFileStreamed, cb);
file.delete(inFileStreamed);
cb();
}
], done);
@ -206,9 +209,7 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
var inFileStreamed = './test/clobTmpFile.txt';
// Generate a file and streamed into clob column
var streamedIntoClobTable1 = function(id, content, callback) {
var stream = fs.createWriteStream(inFileStreamed, { flags: 'w', defaultEncoding: 'utf8', autoClose: true });
stream.write(content);
stream.end();
file.write(inFileStreamed, content);
setTimeout(function(){
connection.execute(
"INSERT INTO nodb_tab_clob_in (id, clob_1, clob_2) VALUES (:i, EMPTY_CLOB(), EMPTY_CLOB()) RETURNING clob_1 INTO :lobbv",
@ -243,15 +244,6 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
}, 3000);
};
// delete file
var deleteFile = function(fileName, callback) {
fs.existsSync(fileName, function(exists) {
if(exists)
fs.unlink(fileName);
});
callback();
};
var preparedInFileName = './test/clobexample.txt';
var prepareTableWithClob = function(sql, id, callback) {
@ -329,21 +321,39 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
should.strictEqual(resultVal.substring(resultLength - specStrLength, resultLength), specialStr);
};
// Generate id for insert clob into db
var insertID = 0;
var getID = function() {
insertID = insertID + 1;
return insertID;
var verifyBindOutResult = function(sqlRun, bindVar, originalStr, specialStr, case64KPlus, client11gPlus, callback) {
connection.execute(
sqlRun,
bindVar,
function(err, result) {
if(originalStr == "EMPTY_LOB" || originalStr == undefined || originalStr == null || originalStr == "") {
should.not.exist(err);
should.strictEqual(result.outBinds.c, null);
callback();
} else {
if(client11gPlus === false && case64KPlus === true){
// NJS-051: "maxSize" must be less than 65535
(err.message).should.startWith('NJS-051:');
callback();
} else {
should.not.exist(err);
var resultVal = result.outBinds.c;
compareResultStrAndOriginal(resultVal, originalStr, specialStr);
callback();
}
}
}
);
};
describe('75.1 CLOB, PLSQL, BIND_OUT', function() {
var proc = "CREATE OR REPLACE PROCEDURE nodb_clobs_out_742 (clob_id IN NUMBER, clob_out OUT CLOB) \n" +
var proc = "CREATE OR REPLACE PROCEDURE nodb_clobs_out_741 (clob_id IN NUMBER, clob_out OUT CLOB) \n" +
"AS \n" +
"BEGIN \n" +
" select clob_1 into clob_out from nodb_tab_clob_in where id = clob_id; \n" +
"END nodb_clobs_out_742; ";
var sqlRun = "BEGIN nodb_clobs_out_742 (:i, :c); END;";
var proc_drop = "DROP PROCEDURE nodb_clobs_out_742";
"END nodb_clobs_out_741; ";
var sqlRun = "BEGIN nodb_clobs_out_741 (:i, :c); END;";
var proc_drop = "DROP PROCEDURE nodb_clobs_out_741";
before(function(done) {
executeSQL(proc, done);
@ -353,33 +363,8 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
executeSQL(proc_drop, done);
}); // after
var verifyBindOutResult = function(sqlRun, bindVar, originalStr, specialStr, case64KPlus, client11gPlus, callback) {
connection.execute(
sqlRun,
bindVar,
function(err, result) {
if(originalStr == "EMPTY_LOB" || originalStr == undefined || originalStr == null || originalStr == "") {
should.not.exist(err);
should.strictEqual(result.outBinds.c, null);
callback();
} else {
if(client11gPlus === false && case64KPlus === true){
// NJS-051: "maxSize" must be less than 65535
(err.message).should.startWith('NJS-051:');
callback();
} else {
should.not.exist(err);
var resultVal = result.outBinds.c;
compareResultStrAndOriginal(resultVal, originalStr, specialStr);
callback();
}
}
}
);
};
it('75.1.1 works with EMPTY_LOB', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
@ -396,7 +381,7 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
}); // 75.1.1
it('75.1.2 works with EMPTY_LOB and bind out maxSize set to 1', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 1 }
@ -413,7 +398,7 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
}); // 75.1.2
it('75.1.3 works with EMPTY_LOB and bind out maxSize set to (64k - 1)', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 65535 }
@ -430,7 +415,7 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
}); // 75.1.3
it('75.1.4 works with null', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
@ -447,7 +432,7 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
}); // 75.1.4
it('75.1.5 works with null and bind out maxSize set to 1', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 1 }
@ -464,7 +449,7 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
}); // 75.1.5
it('75.1.6 works with null and bind out maxSize set to (64k - 1)', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 65535 }
@ -481,7 +466,7 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
}); // 75.1.6
it('75.1.7 works with empty string', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
@ -498,7 +483,7 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
}); // 75.1.7
it('75.1.8 works with empty string and bind out maxSize set to 1', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 1 }
@ -515,7 +500,7 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
}); // 75.1.8
it('75.1.9 works with empty string and bind out maxSize set to (64K - 1)', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 65535 }
@ -532,7 +517,7 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
}); // 75.1.9
it('75.1.10 works with undefined', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
@ -549,7 +534,7 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
}); // 75.1.10
it('75.1.11 works with undefined and bind out maxSize set to 1', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 1 }
@ -566,7 +551,7 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
}); // 75.1.11
it('75.1.12 works with undefined and bind out maxSize set to (64K - 1)', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 65535 }
@ -583,7 +568,7 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
}); // 75.1.12
it('75.1.13 works with NaN', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: NaN, type: oracledb.STRING, dir: oracledb.BIND_IN }
@ -595,15 +580,15 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
bindVar,
function(err) {
should.exist(err);
// 'NJS-011: encountered bind value and type mismatch in parameter 2'
(err.message).should.startWith('NJS-011');
// NJS-011: encountered bind value and type mismatch in parameter 2
(err.message).should.startWith('NJS-011:');
done();
}
);
}); // 75.1.13
it('75.1.14 works with 0', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: 0, type: oracledb.STRING, dir: oracledb.BIND_IN }
@ -615,8 +600,8 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
bindVar,
function(err) {
should.exist(err);
// 'NJS-011: encountered bind value and type mismatch in parameter 2'
(err.message).should.startWith('NJS-011');
// NJS-011: encountered bind value and type mismatch in parameter 2
(err.message).should.startWith('NJS-011:');
done();
}
);
@ -626,7 +611,7 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
// Driver already supports CLOB AS STRING and BLOB AS BUFFER for PLSQL BIND if the data size less than or equal to 32767.
// As part of this enhancement, driver allows even if data size more than 32767 for both column types
var len = 32768;
var sequence = getID();
var sequence = insertID++;
var specialStr = "75.1.15";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
@ -650,7 +635,7 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
// 11.2 libraries is 64 Kb. With Oracle Client 12, the limit is 1 Gb
var len = 65535;
var sequence = getID();
var sequence = insertID++;
var specialStr = "75.1.16";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
@ -670,7 +655,7 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
it('75.1.17 works with String length (64K + 1)', function(done) {
var len = 65537;
var sequence = getID();
var sequence = insertID++;
var specialStr = "75.1.17";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
@ -686,14 +671,15 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
verifyBindOutResult(sqlRun, bindVar, clobStr, specialStr, true, client11gPlus, cb);
},
function(cb) {
deleteFile(inFileStreamed, cb);
file.delete(inFileStreamed);
cb();
}
], done);
}); // 75.1.17
it('75.1.18 works with String length (1MB + 1)', function(done) {
var len = 1048577; // 1 * 1024 * 1024 + 1
var sequence = getID();
var sequence = insertID++;
var specialStr = "75.1.18";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
@ -709,14 +695,15 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
verifyBindOutResult(sqlRun, bindVar, clobStr, specialStr, true, client11gPlus, cb);
},
function(cb) {
deleteFile(inFileStreamed, cb);
file.delete(inFileStreamed);
cb();
}
], done);
}); // 75.1.18
it('75.1.19 works with String length (5MB + 1)', function(done) {
var len = 5242881; // 5 * 1024 * 1024 + 1;
var sequence = getID();
var sequence = insertID++;
var specialStr = "75.1.19";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
@ -732,14 +719,15 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
verifyBindOutResult(sqlRun, bindVar, clobStr, specialStr, true, client11gPlus, cb);
},
function(cb) {
deleteFile(inFileStreamed, cb);
file.delete(inFileStreamed);
cb();
}
], done);
}); // 75.1.19
it('75.1.20 works with String length (10MB + 1)', function(done) {
var len = 10485761; // 10 * 1024 * 1024 + 1;
var sequence = getID();
var sequence = insertID++;
var specialStr = "75.1.20";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
@ -755,13 +743,14 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
verifyBindOutResult(sqlRun, bindVar, clobStr, specialStr, true, client11gPlus, cb);
},
function(cb) {
deleteFile(inFileStreamed, cb);
file.delete(inFileStreamed);
cb();
}
], done);
}); // 75.1.20
it('75.1.21 works with bind value and type mismatch', function(done) {
var sequence = getID();
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: 100, type: oracledb.STRING, dir: oracledb.BIND_IN }
@ -773,8 +762,8 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
bindVar,
function(err) {
should.exist(err);
// 'NJS-011: encountered bind value and type mismatch in parameter 2'
(err.message).should.startWith('NJS-011');
// NJS-011: encountered bind value and type mismatch in parameter 2
(err.message).should.startWith('NJS-011:');
done();
}
);
@ -782,7 +771,7 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
it('75.1.22 mixing named with positional binding', function(done) {
var len = 50000;
var sequence = getID();
var sequence = insertID++;
var specialStr = "75.1.7";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = [ sequence, { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len } ];
@ -808,7 +797,7 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
it('75.1.23 works with bind out maxSize smaller than string length', function(done) {
var len = 50000;
var sequence = getID();
var sequence = insertID++;
var specialStr = "75.1.23";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = [ sequence, { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len - 1 } ];
@ -833,15 +822,15 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
}); // 75.1.23
it('75.1.24 works with UPDATE', function(done) {
var proc_7422 = "CREATE OR REPLACE PROCEDURE nodb_clobs_out_7422 (clob_id IN NUMBER, clob_out OUT CLOB, clob_in CLOB) \n" +
var proc_7412 = "CREATE OR REPLACE PROCEDURE nodb_clobs_out_7412 (clob_id IN NUMBER, clob_out OUT CLOB, clob_in CLOB) \n" +
"AS \n" +
"BEGIN \n" +
" update nodb_tab_clob_in set clob_1 = clob_in where id = clob_id; \n" +
" select clob_1 into clob_out from nodb_tab_clob_in where id = clob_id; \n" +
"END nodb_clobs_out_7422; ";
var sqlRun_7422 = "BEGIN nodb_clobs_out_7422 (:i, :co, :ci); END;";
var proc_drop_7422 = "DROP PROCEDURE nodb_clobs_out_7422";
var sequence = getID();
"END nodb_clobs_out_7412; ";
var sqlRun_7412 = "BEGIN nodb_clobs_out_7412 (:i, :co, :ci); END;";
var proc_drop_7412 = "DROP PROCEDURE nodb_clobs_out_7412";
var sequence = insertID++;
var len_1 = 50000;
var specialStr_1 = "75.1.24_1";
var clobStr_1 = random.getRandomString(len_1, specialStr_1);
@ -859,11 +848,11 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
insertClobWithString(sequence, clobStr_1, false, client11gPlus, cb);
},
function(cb) {
executeSQL(proc_7422, cb);
executeSQL(proc_7412, cb);
},
function(cb) {
connection.execute(
sqlRun_7422,
sqlRun_7412,
bindVar,
function(err, result) {
should.not.exist(err);
@ -874,20 +863,20 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
);
},
function(cb) {
executeSQL(proc_drop_7422, cb);
executeSQL(proc_drop_7412, cb);
}
], done);
}); // 75.1.24
it('75.1.25 works with substr', function(done) {
var proc_7425 = "CREATE OR REPLACE PROCEDURE nodb_clobs_out_7425 (clob_id IN NUMBER, clob_out OUT CLOB) \n" +
var proc_7415 = "CREATE OR REPLACE PROCEDURE nodb_clobs_out_7415 (clob_id IN NUMBER, clob_out OUT CLOB) \n" +
"AS \n" +
"BEGIN \n" +
" select substr(clob_1, 1, 3) into clob_out from nodb_tab_clob_in where id = clob_id; \n" +
"END nodb_clobs_out_7425; ";
var sqlRun_7425 = "BEGIN nodb_clobs_out_7425 (:i, :co); END;";
var proc_drop_7425 = "DROP PROCEDURE nodb_clobs_out_7425";
var sequence = getID();
"END nodb_clobs_out_7415; ";
var sqlRun_7415 = "BEGIN nodb_clobs_out_7415 (:i, :co); END;";
var proc_drop_7415 = "DROP PROCEDURE nodb_clobs_out_7415";
var sequence = insertID++;
var len = 50000;
var specialStr = "75.1.25";
var clobStr = random.getRandomString(len, specialStr);
@ -901,11 +890,11 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
insertClobWithString(sequence, clobStr, false, client11gPlus, cb);
},
function(cb) {
executeSQL(proc_7425, cb);
executeSQL(proc_7415, cb);
},
function(cb) {
connection.execute(
sqlRun_7425,
sqlRun_7415,
bindVar,
function(err, result) {
should.not.exist(err);
@ -920,14 +909,445 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
);
},
function(cb) {
executeSQL(proc_drop_7425, cb);
executeSQL(proc_drop_7415, cb);
}
], done);
}); // 75.1.25
}); // 75.1
describe('75.2 Multiple CLOBs, BIND_OUT', function() {
describe('75.2 CLOB, PLSQL, BIND_OUT to VARCHAR2', function() {
var proc = "CREATE OR REPLACE PROCEDURE nodb_clobs_out_742 (clob_id IN NUMBER, clob_out OUT VARCHAR2) \n" +
"AS \n" +
"BEGIN \n" +
" select clob_1 into clob_out from nodb_tab_clob_in where id = clob_id; \n" +
"END nodb_clobs_out_742; ";
var sqlRun = "BEGIN nodb_clobs_out_742 (:i, :c); END;";
var proc_drop = "DROP PROCEDURE nodb_clobs_out_742";
before(function(done) {
executeSQL(proc, done);
}); // before
after(function(done) {
executeSQL(proc_drop, done);
}); // after
it('75.2.1 works with EMPTY_LOB', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
};
async.series([
function(cb) {
insertClobWithString(sequence, "EMPTY_LOB", false, client11gPlus, cb);
},
function(cb) {
verifyBindOutResult(sqlRun, bindVar, "EMPTY_LOB", null, false, client11gPlus, cb);
}
], done);
}); // 75.2.1
it('75.2.2 works with EMPTY_LOB and bind out maxSize set to 1', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 1 }
};
async.series([
function(cb) {
insertClobWithString(sequence, "EMPTY_LOB", false, client11gPlus, cb);
},
function(cb) {
verifyBindOutResult(sqlRun, bindVar, "EMPTY_LOB", null, false, client11gPlus, cb);
}
], done);
}); // 75.2.2
it('75.2.3 works with EMPTY_LOB and bind out maxSize set to (64k - 1)', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 65535 }
};
async.series([
function(cb) {
insertClobWithString(sequence, "EMPTY_LOB", false, client11gPlus, cb);
},
function(cb) {
verifyBindOutResult(sqlRun, bindVar, "EMPTY_LOB", null, false, client11gPlus, cb);
}
], done);
}); // 75.2.3
it('75.2.4 works with null', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
};
async.series([
function(cb) {
insertClobWithString(sequence, null, false, client11gPlus, cb);
},
function(cb) {
verifyBindOutResult(sqlRun, bindVar, null, null, false, client11gPlus, cb);
}
], done);
}); // 75.2.4
it('75.2.5 works with null and bind out maxSize set to 1', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 1 }
};
async.series([
function(cb) {
insertClobWithString(sequence, null, false, client11gPlus, cb);
},
function(cb) {
verifyBindOutResult(sqlRun, bindVar, null, null, false, client11gPlus, cb);
}
], done);
}); // 75.2.5
it('75.2.6 works with null and bind out maxSize set to (64k - 1)', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 65535 }
};
async.series([
function(cb) {
insertClobWithString(sequence, null, false, client11gPlus, cb);
},
function(cb) {
verifyBindOutResult(sqlRun, bindVar, null, null, false, client11gPlus, cb);
}
], done);
}); // 75.2.6
it('75.2.7 works with empty string', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
};
async.series([
function(cb) {
insertClobWithString(sequence, "", false, client11gPlus, cb);
},
function(cb) {
verifyBindOutResult(sqlRun, bindVar, "", null, false, client11gPlus, cb);
}
], done);
}); // 75.2.7
it('75.2.8 works with empty string and bind out maxSize set to 1', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 1 }
};
async.series([
function(cb) {
insertClobWithString(sequence, "", false, client11gPlus, cb);
},
function(cb) {
verifyBindOutResult(sqlRun, bindVar, "", null, false, client11gPlus, cb);
}
], done);
}); // 75.2.8
it('75.2.9 works with empty string and bind out maxSize set to (64K - 1)', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 65535 }
};
async.series([
function(cb) {
insertClobWithString(sequence, "", false, client11gPlus, cb);
},
function(cb) {
verifyBindOutResult(sqlRun, bindVar, "", null, false, client11gPlus, cb);
}
], done);
}); // 75.2.9
it('75.2.10 works with undefined', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
};
async.series([
function(cb) {
insertClobWithString(sequence, undefined, false, client11gPlus, cb);
},
function(cb) {
verifyBindOutResult(sqlRun, bindVar, undefined, null, false, client11gPlus, cb);
}
], done);
}); // 75.2.10
it('75.2.11 works with undefined and bind out maxSize set to 1', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 1 }
};
async.series([
function(cb) {
insertClobWithString(sequence, undefined, false, client11gPlus, cb);
},
function(cb) {
verifyBindOutResult(sqlRun, bindVar, undefined, null, false, client11gPlus, cb);
}
], done);
}); // 75.2.11
it('75.2.12 works with undefined and bind out maxSize set to (64K - 1)', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 65535 }
};
async.series([
function(cb) {
insertClobWithString(sequence, undefined, false, client11gPlus, cb);
},
function(cb) {
verifyBindOutResult(sqlRun, bindVar, undefined, null, false, client11gPlus, cb);
}
], done);
}); // 75.2.12
it('75.2.13 works with NaN', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: NaN, type: oracledb.STRING, dir: oracledb.BIND_IN }
};
var sql = "INSERT INTO nodb_tab_clob_in (id, clob_1) VALUES (:i, :c)";
connection.execute(
sql,
bindVar,
function(err) {
should.exist(err);
// NJS-011: encountered bind value and type mismatch in parameter 2
(err.message).should.startWith('NJS-011:');
done();
}
);
}); // 75.2.13
it('75.2.14 works with 0', function(done) {
var sequence = insertID++;
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { val: 0, type: oracledb.STRING, dir: oracledb.BIND_IN }
};
var sql = "INSERT INTO nodb_tab_clob_in (id, clob_1) VALUES (:i, :c)";
connection.execute(
sql,
bindVar,
function(err) {
should.exist(err);
// NJS-011: encountered bind value and type mismatch in parameter 2
(err.message).should.startWith('NJS-011:');
done();
}
);
}); // 75.2.14
it('75.2.15 works with String length (32K - 1)', function(done) {
var len = 32767;
var sequence = insertID++;
var specialStr = "75.2.15";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }
};
async.series([
function(cb) {
insertClobWithString(sequence, clobStr, false, client11gPlus, cb);
},
function(cb) {
verifyBindOutResult(sqlRun, bindVar, clobStr, specialStr, false, client11gPlus, cb);
}
], done);
}); // 75.2.15
it('75.2.16 works with String length 32K', function(done) {
var len = 32768;
var sequence = insertID++;
var specialStr = "75.2.16";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }
};
async.series([
function(cb) {
insertClobWithString(sequence, clobStr, false, client11gPlus, cb);
},
function(cb) {
connection.execute(
sqlRun,
bindVar,
function(err) {
should.exist(err);
// ORA-06502: PL/SQL: numeric or value error
(err.message).should.startWith('ORA-06502:');
cb();
}
);
}
], done);
}); // 75.2.16
it('75.2.17 works with bind out maxSize smaller than string length', function(done) {
var len = 500;
var sequence = insertID++;
var specialStr = "75.2.17";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = [ sequence, { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len - 1 } ];
async.series([
function(cb) {
insertClobWithString(sequence, clobStr, false, client11gPlus, cb);
},
function(cb) {
connection.execute(
sqlRun,
bindVar,
function(err) {
should.exist(err);
// ORA-06502: PL/SQL: numeric or value error
(err.message).should.startWith('ORA-06502:');
cb();
}
);
}
], done);
}); // 75.2.17
it('75.2.18 works with UPDATE', function(done) {
var proc_7518 = "CREATE OR REPLACE PROCEDURE nodb_clobs_out_7518 (clob_id IN NUMBER, clob_out OUT CLOB, clob_in VARCHAR2) \n" +
"AS \n" +
"BEGIN \n" +
" update nodb_tab_clob_in set clob_1 = clob_in where id = clob_id; \n" +
" select clob_1 into clob_out from nodb_tab_clob_in where id = clob_id; \n" +
"END nodb_clobs_out_7518; ";
var sqlRun_7518 = "BEGIN nodb_clobs_out_7518 (:i, :co, :ci); END;";
var proc_drop_7518 = "DROP PROCEDURE nodb_clobs_out_7518";
var sequence = insertID++;
var len_1 = 500;
var specialStr_1 = "75.2.18_1";
var clobStr_1 = random.getRandomString(len_1, specialStr_1);
var len_2 = 200;
var specialStr_2 = "75.2.18_2";
var clobStr_2 = random.getRandomString(len_2, specialStr_2);
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
co: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len_1 },
ci: { val:clobStr_2, type: oracledb.STRING, dir: oracledb.BIND_IN, maxSize: len_2 }
};
async.series([
function(cb) {
insertClobWithString(sequence, clobStr_1, false, client11gPlus, cb);
},
function(cb) {
executeSQL(proc_7518, cb);
},
function(cb) {
connection.execute(
sqlRun_7518,
bindVar,
function(err, result) {
should.not.exist(err);
var resultVal = result.outBinds.co;
compareResultStrAndOriginal(resultVal, clobStr_2, specialStr_2);
cb();
}
);
},
function(cb) {
executeSQL(proc_drop_7518, cb);
}
], done);
}); // 75.2.18
it('75.2.19 works with substr', function(done) {
var proc_7519 = "CREATE OR REPLACE PROCEDURE nodb_clobs_out_7519 (clob_id IN NUMBER, clob_out OUT VARCHAR2) \n" +
"AS \n" +
"BEGIN \n" +
" select substr(clob_1, 1, 3) into clob_out from nodb_tab_clob_in where id = clob_id; \n" +
"END nodb_clobs_out_7519; ";
var sqlRun_7519 = "BEGIN nodb_clobs_out_7519 (:i, :co); END;";
var proc_drop_7519 = "DROP PROCEDURE nodb_clobs_out_7519";
var sequence = insertID++;
var len = 500;
var specialStr = "75.2.19";
var clobStr = random.getRandomString(len, specialStr);
var bindVar = {
i: { val: sequence, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
co: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: len }
};
async.series([
function(cb) {
insertClobWithString(sequence, clobStr, false, client11gPlus, cb);
},
function(cb) {
executeSQL(proc_7519, cb);
},
function(cb) {
connection.execute(
sqlRun_7519,
bindVar,
function(err, result) {
should.not.exist(err);
var 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.
clobStr = clobStr.substring(0, 3);
should.strictEqual(resultVal.length, 3);
should.strictEqual(resultVal, clobStr);
cb();
}
);
},
function(cb) {
executeSQL(proc_drop_7519, cb);
}
], done);
}); // 75.2.19
}); // 75.2
describe('75.3 Multiple CLOBs, BIND_OUT', function() {
var proc = "CREATE OR REPLACE PROCEDURE nodb_lobs_out_745 (clob_id IN NUMBER, clob_1 OUT CLOB, clob_2 OUT CLOB) \n" +
"AS \n" +
"BEGIN \n" +
@ -969,10 +1389,10 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
);
};
it('75.2.1 bind two string', function(done) {
var sequence = getID();
var specialStr_1 = "75.2.1_1";
var specialStr_2 = "75.2.1_2";
it('75.3.1 bind two string', function(done) {
var sequence = insertID++;
var specialStr_1 = "75.3.1_1";
var specialStr_2 = "75.3.1_2";
var len1 = 50000;
var len2 = 10000;
var clobStr_1 = random.getRandomString(len1, specialStr_1);
@ -1003,11 +1423,11 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
}
], done);
}); // 75.2.1
}); // 75.3.1
it('75.2.2 bind a txt file and a string', function(done) {
var specialStr = "75.2.2";
var sequence = getID();
it('75.3.2 bind a txt file and a string', function(done) {
var specialStr = "75.3.2";
var sequence = insertID++;
var len1 = 50000;
var clobStr_1 = random.getRandomString(len1, specialStr);
var bindVar = {
@ -1073,12 +1493,12 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
}
], done);
}); // 75.2.2
}); // 75.3.2
it('75.2.3 bind two string, one > (64K - 1)', function(done) {
var sequence = getID();
var specialStr_1 = "75.2.3_1";
var specialStr_2 = "75.2.3_2";
it('75.3.3 bind two string, one > (64K - 1)', function(done) {
var sequence = insertID++;
var specialStr_1 = "75.3.3_1";
var specialStr_2 = "75.3.3_2";
var len1 = 65538;
var len2 = 10000;
var clobStr_1 = random.getRandomString(len1, specialStr_1);
@ -1113,8 +1533,8 @@ describe('75.clobPlsqlBindAsString_bindout.js', function() {
}
], done);
}); // 75.2.3
}); // 75.3.3
}); // 75.2
}); // 75.3
});

View File

@ -382,7 +382,7 @@ describe('42. dataTypeRaw.js', function() {
function(err) {
should.exist(err);
// ORA-06502: PL/SQL: numeric or value error\nORA-06512: at line 1
(err.message).should.startWith('ORA-06502');
(err.message).should.startWith('ORA-06502:');
done();
}
);
@ -401,7 +401,7 @@ describe('42. dataTypeRaw.js', function() {
function(err) {
should.exist(err);
// ORA-06502: PL/SQL: numeric or value error\nORA-06512: at line 1
(err.message).should.startWith('ORA-06502');
(err.message).should.startWith('ORA-06502:');
done();
}
);

File diff suppressed because it is too large Load Diff

3039
test/fetchBlobAsBuffer1.js Normal file

File diff suppressed because it is too large Load Diff

2383
test/fetchBlobAsBuffer2.js Normal file

File diff suppressed because it is too large Load Diff

353
test/fetchBlobAsBuffer3.js Normal file
View File

@ -0,0 +1,353 @@
/* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */
/******************************************************************************
*
* You may not use the identified files except in compliance with the Apache
* License, Version 2.0 (the "License.")
*
* You may obtain a copy of the License at
* http://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.
*
* The node-oracledb test suite uses 'mocha', 'should' and 'async'.
* See LICENSE.md for relevant licenses.
*
* NAME
* 89. fetchBlobAsBuffer3.js
*
* DESCRIPTION
* Testing Oracle data type support - BLOB.
* To fetch BLOB columns as buffer
*
* NUMBERING RULE
* Test numbers follow this numbering rule:
* 1 - 20 are reserved for basic functional tests
* 21 - 50 are reserved for data type supporting tests
* 51 onwards are for other tests
*
*****************************************************************************/
'use strict';
var oracledb = require('oracledb');
var async = require('async');
var should = require('should');
var dbConfig = require('./dbconfig.js');
var random = require('./random.js');
var assist = require('./dataTypeAssist.js');
describe('89. fetchBlobAsBuffer3.js', function() {
this.timeout(100000);
var connection = null;
var node6plus = false; // assume node runtime version is lower than 6
var insertID = 1; // assume id for insert into db starts from 1
var client11gPlus = true; // assume instant client runtime version is greater than 11.2.0.4.0
var proc_create_table2 = "BEGIN \n" +
" DECLARE \n" +
" e_table_missing EXCEPTION; \n" +
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
" BEGIN \n" +
" EXECUTE IMMEDIATE('DROP TABLE nodb_blob2 PURGE'); \n" +
" EXCEPTION \n" +
" WHEN e_table_missing \n" +
" THEN NULL; \n" +
" END; \n" +
" EXECUTE IMMEDIATE (' \n" +
" CREATE TABLE nodb_blob2 ( \n" +
" ID NUMBER, \n" +
" B1 BLOB, \n" +
" B2 BLOB \n" +
" ) \n" +
" '); \n" +
"END; ";
var drop_table2 = "DROP TABLE nodb_blob2 PURGE";
before('get one connection', function(done) {
oracledb.stmtCacheSize = 0;
oracledb.getConnection(dbConfig, function(err, conn) {
should.not.exist(err);
connection = conn;
if(process.versions["node"].substring(0,1) >= "6")
node6plus = true;
if(oracledb.oracleClientVersion < 1201000200)
client11gPlus = false;
done();
});
}); // before
after('release connection', function(done) {
connection.release(function(err) {
should.not.exist(err);
done();
});
}); // after
var insertIntoBlobTable2 = function(id, content1, content2, callback) {
connection.execute(
"INSERT INTO nodb_blob2 VALUES (:ID, :B1, :B2)",
[ id, content1, content2 ],
function(err, result){
should.not.exist(err);
should.strictEqual(result.rowsAffected, 1);
callback();
}
);
};
// compare fetch result
var compareClientFetchResult = function(err, resultVal, specialStr, content, contentLength, case64KPlus) {
// if test buffer size greater than 64K
if(case64KPlus === true) {
// if client version 12.1.0.2
if(client11gPlus === true) {
should.not.exist(err);
compareBuffers(resultVal, specialStr, content, contentLength);
} else {
// if client version 11.2.0.4
should.not.exist(err);
content = content.slice(0, 65535);
compareBuffers(resultVal, specialStr, content, 65535);
}
} else {
// if test buffer size smaller than 64K
should.not.exist(err);
compareBuffers(resultVal, specialStr, content, contentLength);
}
};
// compare two buffers
var compareBuffers = function(resultVal, specialStr, content, contentLength) {
should.equal(resultVal.length, contentLength);
var compareBuffer = assist.compare2Buffers(resultVal, content);
should.strictEqual(compareBuffer, true);
};
describe('89.1 fetch multiple BLOBs', function() {
before('create Table and populate', function(done) {
connection.execute(
proc_create_table2,
function(err){
should.not.exist(err);
done() ;
}
);
}); // before
after('drop table', function(done) {
connection.execute(
drop_table2,
function(err){
should.not.exist(err);
done();
}
);
}); // after
beforeEach('set oracledb.fetchAsString', function(done) {
oracledb.fetchAsBuffer = [ oracledb.BLOB ];
done();
}); // beforeEach
afterEach('clear the By type specification', function(done) {
oracledb.fetchAsBuffer = [];
done();
}); // afterEach
it('89.1.1 fetch multiple BLOB columns as Buffer', function(done) {
var id = insertID++;
var specialStr_1 = '89.1.1_1';
var contentLength_1 = 26;
var strBuf_1 = random.getRandomString(contentLength_1, specialStr_1);
var content_1 = node6plus ? Buffer.from(strBuf_1, "utf-8") : new Buffer(strBuf_1, "utf-8");
var specialStr_2 = '89.1.1_2';
var contentLength_2 = 100;
var strBuf_2 = random.getRandomString(contentLength_2, specialStr_2);
var content_2 = node6plus ? Buffer.from(strBuf_2, "utf-8") : new Buffer(strBuf_2, "utf-8");
async.series([
function(cb) {
insertIntoBlobTable2(id, content_1, content_2, cb);
},
function(cb) {
connection.execute(
"SELECT ID, B1, B2 from nodb_blob2",
function(err, result){
should.not.exist(err);
var resultVal = result.rows[0][1];
compareClientFetchResult(err, resultVal, specialStr_1, content_1, contentLength_1, false);
resultVal = result.rows[0][2];
compareClientFetchResult(err, resultVal, specialStr_2, content_2, contentLength_2, false);
cb();
}
);
}
], done);
}); // 89.1.1
it('89.1.2 fetch two BLOB columns, one as string, another streamed', function(done) {
var id = insertID++;
var specialStr_1 = '89.1.2_1';
var contentLength_1 = 30;
var strBuf_1 = random.getRandomString(contentLength_1, specialStr_1);
var content_1 = node6plus ? Buffer.from(strBuf_1, "utf-8") : new Buffer(strBuf_1, "utf-8");
var specialStr_2 = '89.1.2_2';
var contentLength_2 = 50;
var strBuf_2 = random.getRandomString(contentLength_2, specialStr_2);
var content_2 = node6plus ? Buffer.from(strBuf_2, "utf-8") : new Buffer(strBuf_2, "utf-8");
async.series([
function(cb) {
insertIntoBlobTable2(id, content_1, content_2, cb);
},
function(cb) {
connection.execute(
"SELECT ID, B1 from nodb_blob2 where ID = :id",
{ id : id },
function(err, result){
should.not.exist(err);
var resultVal = result.rows[0][1];
compareClientFetchResult(err, resultVal, specialStr_1, content_1, contentLength_1, false);
cb();
}
);
},
function(cb) {
oracledb.fetchAsBuffer = [];
connection.execute(
"SELECT B2 from nodb_blob2 where ID = :id",
{ id : id },
function(err, result){
should.not.exist(err);
(result.rows.length).should.not.eql(0);
var lob = result.rows[0][0];
should.exist(lob);
// set the encoding so we get a 'string' not a 'buffer'
lob.setEncoding('utf8');
var clobData = '';
lob.on('data', function(chunk) {
clobData += chunk;
});
lob.on('error', function(err) {
should.not.exist(err, "lob.on 'error' event.");
});
lob.on('end', function() {
should.not.exist(err);
var specialStrLen_2 = specialStr_2.length;
var resultLen_2 = clobData.length;
should.equal(clobData.length, contentLength_2);
should.strictEqual(clobData.substring(0, specialStrLen_2), specialStr_2);
should.strictEqual(clobData.substring(resultLen_2 - specialStrLen_2, resultLen_2), specialStr_2);
cb();
});
}
);
}
], done);
}); // 89.1.2
}); // 89.1
describe('89.2 types support for fetchAsBuffer property', function() {
afterEach ('clear the by-type specification', function ( done ) {
oracledb.fetchAsBuffer = [];
done ();
});
it('89.2.1 String not supported in fetchAsBuffer', function(done) {
try {
oracledb.fetchAsBuffer = [ oracledb.STRING ];
} catch(err) {
should.exist(err);
// NJS-021: invalid type for conversion specified
(err.message).should.startWith ('NJS-021:');
}
done();
}); // 89.2.1
it('89.2.2 CLOB not supported in fetchAsBuffer', function(done) {
try {
oracledb.fetchAsBuffer = [ oracledb.CLOB ];
} catch(err) {
should.exist(err);
// NJS-021: invalid type for conversion specified
(err.message).should.startWith ('NJS-021:');
}
done();
}); // 89.2.2
it('89.2.3 Number not supported in fetchAsBuffer', function(done) {
try {
oracledb.fetchAsBuffer = [ oracledb.NUMBER ];
} catch(err) {
should.exist(err);
// NJS-021: invalid type for conversion specified
(err.message).should.startWith ('NJS-021:');
}
done();
}); // 89.2.3
it('89.2.4 Date not supported in fetchAsBuffer', function(done) {
try {
oracledb.fetchAsBuffer = [ oracledb.DATE ];
} catch(err) {
should.exist(err);
// NJS-021: invalid type for conversion specified
(err.message).should.startWith ('NJS-021:');
}
done();
}); // 89.2.4
it('89.2.5 Cursor not supported in fetchAsBuffer', function(done) {
try {
oracledb.fetchAsBuffer = [ oracledb.CURSOR ];
} catch(err) {
should.exist(err);
// NJS-021: invalid type for conversion specified
(err.message).should.startWith ('NJS-021:');
}
done();
}); // 89.2.5
it('89.2.6 Buffer not supported in fetchAsBuffer', function(done) {
try {
oracledb.fetchAsBuffer = [ oracledb.BUFFER ];
} catch(err) {
should.exist(err);
// NJS-021: invalid type for conversion specified
(err.message).should.startWith ('NJS-021:');
}
done();
}); // 89.2.6
it('89.2.7 BLOB supported in fetchAsBuffer', function(done) {
try {
oracledb.fetchAsBuffer = [ oracledb.BLOB ];
} catch(err) {
should.not.exist(err);
}
should.strictEqual(oracledb.fetchAsBuffer.length, 1);
should.strictEqual(oracledb.fetchAsBuffer[0], oracledb.BLOB);
done();
}); // 89.2.7
}); // 89.2
});

File diff suppressed because it is too large Load Diff

2985
test/fetchClobAsString1.js Normal file

File diff suppressed because it is too large Load Diff

2292
test/fetchClobAsString2.js Normal file

File diff suppressed because it is too large Load Diff

322
test/fetchClobAsString3.js Normal file
View File

@ -0,0 +1,322 @@
/* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. */
/******************************************************************************
*
* You may not use the identified files except in compliance with the Apache
* License, Version 2.0 (the "License.")
*
* You may obtain a copy of the License at
* http://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.
*
* The node-oracledb test suite uses 'mocha', 'should' and 'async'.
* See LICENSE.md for relevant licenses.
*
* NAME
* 86. fetchClobAsString.js
*
* DESCRIPTION
* Testing Oracle data type support - CLOB.
* To fetch CLOB columns as strings
* This could be very useful for smaller CLOB size as it can be fetched as string and processed in memory itself.
*
* NUMBERING RULE
* Test numbers follow this numbering rule:
* 1 - 20 are reserved for basic functional tests
* 21 - 50 are reserved for data type supporting tests
* 51 onwards are for other tests
*
*****************************************************************************/
'use strict';
var oracledb = require('oracledb');
var async = require('async');
var should = require('should');
var dbConfig = require('./dbconfig.js');
var random = require('./random.js');
describe('86. fetchClobAsString3.js', function() {
this.timeout(100000);
var connection = null;
var insertID = 1; // assume id for insert into db starts from 1
var proc_create_table2 = "BEGIN \n" +
" DECLARE \n" +
" e_table_missing EXCEPTION; \n" +
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
" BEGIN \n" +
" EXECUTE IMMEDIATE('DROP TABLE nodb_clob2 PURGE'); \n" +
" EXCEPTION \n" +
" WHEN e_table_missing \n" +
" THEN NULL; \n" +
" END; \n" +
" EXECUTE IMMEDIATE (' \n" +
" CREATE TABLE nodb_clob2 ( \n" +
" ID NUMBER, \n" +
" C1 CLOB, \n" +
" C2 CLOB \n" +
" ) \n" +
" '); \n" +
"END; ";
var drop_table2 = "DROP TABLE nodb_clob2 PURGE";
before('get one connection', function(done) {
oracledb.stmtCacheSize = 0;
oracledb.getConnection(dbConfig, function(err, conn) {
should.not.exist(err);
connection = conn;
done();
});
}); // before
after('release connection', function(done) {
connection.release(function(err) {
should.not.exist(err);
done();
});
}); // after
var insertIntoClobTable2 = function(id, content1, content2, callback) {
connection.execute(
"INSERT INTO nodb_clob2 VALUES (:ID, :C1, :C2)",
[ id, content1, content2 ],
function(err, result){
should.not.exist(err);
should.strictEqual(result.rowsAffected, 1);
callback();
}
);
};
describe('86.1 fetch multiple CLOBs', function() {
before('create Table and populate', function(done) {
connection.execute(
proc_create_table2,
function(err){
should.not.exist(err);
done() ;
}
);
}); // before
after('drop table', function(done) {
oracledb.fetchAsString = [];
connection.execute(
drop_table2,
function(err){
should.not.exist(err);
done();
}
);
}); // after
beforeEach('set oracledb.fetchAsString', function(done) {
oracledb.fetchAsString = [ oracledb.CLOB ];
done();
}); // beforeEach
afterEach('clear the By type specification', function(done) {
oracledb.fetchAsString = [];
done();
}); // afterEach
it('86.1.1 fetch multiple CLOB columns as String', function(done) {
var id = insertID++;
var specialStr_1 = '86.1.1_1';
var contentLength_1 = 26;
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
var specialStr_2 = '86.1.1_2';
var contentLength_2 = 100;
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
async.series([
function(cb) {
insertIntoClobTable2(id, content_1, content_2, cb);
},
function(cb) {
connection.execute(
"SELECT ID, C1, C2 from nodb_clob2",
function(err, result){
should.not.exist(err);
var specialStrLen_1 = specialStr_1.length;
var resultLen_1 = result.rows[0][1].length;
should.equal(result.rows[0][1].length, contentLength_1);
should.strictEqual(result.rows[0][1].substring(0, specialStrLen_1), specialStr_1);
should.strictEqual(result.rows[0][1].substring(resultLen_1 - specialStrLen_1, resultLen_1), specialStr_1);
var specialStrLen_2 = specialStr_2.length;
var resultLen_2 = result.rows[0][2].length;
should.equal(result.rows[0][2].length, contentLength_2);
should.strictEqual(result.rows[0][2].substring(0, specialStrLen_2), specialStr_2);
should.strictEqual(result.rows[0][2].substring(resultLen_2 - specialStrLen_2, resultLen_2), specialStr_2);
cb();
}
);
}
], done);
}); // 86.1.1
it('86.1.2 fetch two CLOB columns, one as string, another streamed', function(done) {
var id = insertID++;
var specialStr_1 = '86.1.2_1';
var contentLength_1 = 30;
var content_1 = random.getRandomString(contentLength_1, specialStr_1);
var specialStr_2 = '86.1.2_2';
var contentLength_2 = 50;
var content_2 = random.getRandomString(contentLength_2, specialStr_2);
async.series([
function(cb) {
insertIntoClobTable2(id, content_1, content_2, cb);
},
function(cb) {
connection.execute(
"SELECT ID, C1 from nodb_clob2 where ID = :id",
{ id: id },
function(err, result){
should.not.exist(err);
var specialStrLen_1 = specialStr_1.length;
var resultLen_1 = result.rows[0][1].length;
should.equal(result.rows[0][1].length, contentLength_1);
should.strictEqual(result.rows[0][1].substring(0, specialStrLen_1), specialStr_1);
should.strictEqual(result.rows[0][1].substring(resultLen_1 - specialStrLen_1, resultLen_1), specialStr_1);
cb();
}
);
},
function(cb) {
oracledb.fetchAsString = [];
connection.execute(
"SELECT C2 from nodb_clob2 where ID = :id",
{ id: id },
function(err, result){
should.not.exist(err);
(result.rows.length).should.not.eql(0);
var lob = result.rows[0][0];
should.exist(lob);
// set the encoding so we get a 'string' not a 'String'
lob.setEncoding('utf8');
var clobData = '';
lob.on('data', function(chunk) {
clobData += chunk;
});
lob.on('error', function(err) {
should.not.exist(err, "lob.on 'error' event.");
});
lob.on('end', function() {
should.not.exist(err);
var specialStrLen_2 = specialStr_2.length;
var resultLen_2 = clobData.length;
should.equal(clobData.length, contentLength_2);
should.strictEqual(clobData.substring(0, specialStrLen_2), specialStr_2);
should.strictEqual(clobData.substring(resultLen_2 - specialStrLen_2, resultLen_2), specialStr_2);
cb();
});
}
);
}
], done);
}); // 86.1.2
}); // 86.1
describe('86.2 types support for fetchAsString property', function() {
afterEach ('clear the by-type specification', function ( done ) {
oracledb.fetchAsString = [];
done ();
});
it('86.2.1 String not supported in fetchAsString', function(done) {
try {
oracledb.fetchAsString = [ oracledb.STRING ];
} catch(err) {
should.exist(err);
// NJS-021: invalid type for conversion specified
(err.message).should.startWith ('NJS-021:');
}
done();
}); // 86.2.1
it('86.2.2 BLOB not supported in fetchAsString', function(done) {
try {
oracledb.fetchAsString = [ oracledb.BLOB ];
} catch(err) {
should.exist(err);
// NJS-021: invalid type for conversion specified
(err.message).should.startWith ('NJS-021:');
}
done();
}); // 86.2.2
it('86.2.3 Cursor not supported in fetchAsString', function(done) {
try {
oracledb.fetchAsString = [ oracledb.CURSOR ];
} catch(err) {
should.exist(err);
// NJS-021: invalid type for conversion specified
(err.message).should.startWith ('NJS-021:');
}
done();
}); // 86.2.3
it('86.2.4 Buffer not supported in fetchAsString', function(done) {
try {
oracledb.fetchAsString = [ oracledb.Buffer ];
} catch(err) {
should.exist(err);
// NJS-021: invalid type for conversion specified
(err.message).should.startWith ('NJS-021:');
}
done();
}); // 86.2.4
it('86.2.5 Number supported in fetchAsString', function(done) {
try {
oracledb.fetchAsString = [ oracledb.NUMBER ];
} catch(err) {
should.not.exist(err);
}
should.strictEqual(oracledb.fetchAsString.length, 1);
should.strictEqual(oracledb.fetchAsString[0], oracledb.NUMBER);
done();
}); // 86.2.5
it('86.2.6 Date supported in fetchAsString', function(done) {
try {
oracledb.fetchAsString = [ oracledb.DATE ];
} catch(err) {
should.not.exist(err);
}
should.strictEqual(oracledb.fetchAsString.length, 1);
should.strictEqual(oracledb.fetchAsString[0], oracledb.DATE);
done();
}); // 86.2.6
it('86.2.7 CLOB supported in fetchAsString', function(done) {
try {
oracledb.fetchAsString = [ oracledb.CLOB ];
} catch(err) {
should.not.exist(err);
}
should.strictEqual(oracledb.fetchAsString.length, 1);
should.strictEqual(oracledb.fetchAsString[0], oracledb.CLOB);
done();
}); // 86.2.7
}); // 86.2
});

50
test/file.js Normal file
View File

@ -0,0 +1,50 @@
/* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. */
/******************************************************************************
*
* You may not use the identified files except in compliance with the Apache
* License, Version 2.0 (the "License.")
*
* You may obtain a copy of the License at
* http://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.
*
* The node-oracledb test suite uses 'mocha', 'should' and 'async'.
* See LICENSE.md for relevant licenses.
*
* NAME
* file.js
*
* DESCRIPTION
* file manipulate
*****************************************************************************/
'use strict';
var should = require('should');
var fs = require('fs');
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 diff suppressed because it is too large Load Diff

View File

@ -824,7 +824,7 @@ describe('71. lobBind1.js', function() {
function(err) {
should.exist(err);
// NJS-011: encountered bind value and type mismatch in parameter 2
(err.message).should.startWith('NJS-011');
(err.message).should.startWith('NJS-011:');
cb();
}
);

View File

@ -19,7 +19,7 @@
* See LICENSE.md for relevant licenses.
*
* NAME
* 78. lobBindAsStringBuffer.js
* 80. lobBindAsStringBuffer.js
*
* DESCRIPTION
* Testing CLOB/BLOB binding as String/Buffer.
@ -40,7 +40,7 @@ var dbConfig = require('./dbconfig.js');
var fs = require('fs');
var random = require('./random.js');
describe('78.lobBindAsStringBuffer.js', function() {
describe('80. lobBindAsStringBuffer.js', function() {
var connection = null;
var node6plus = false; // assume node runtime version is lower than 6
@ -336,7 +336,7 @@ describe('78.lobBindAsStringBuffer.js', function() {
);
};
describe('78.1 Multiple LOBs, BIND_IN', function() {
describe('80.1 Multiple LOBs, BIND_IN', function() {
var proc = "CREATE OR REPLACE PROCEDURE nodb_lobs_in_781 (id IN NUMBER, clob_in IN CLOB, blob_in IN BLOB)\n" +
"AS \n" +
"BEGIN \n" +
@ -353,8 +353,8 @@ describe('78.lobBindAsStringBuffer.js', function() {
executeSQL(proc_drop, done);
}); // after
it('78.1.1 PLSQL, CLOB&BLOB, bind a string and a buffer', function(done) {
var specialStr = "78.1.1";
it('80.1.1 PLSQL, CLOB&BLOB, bind a string and a buffer', function(done) {
var specialStr = "80.1.1";
var length = 50000;
var bigStr = random.getRandomString(length, specialStr);
var bigBuffer = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
@ -386,13 +386,13 @@ describe('78.lobBindAsStringBuffer.js', function() {
verifyBlobValueWithBuffer(sql_2, bigBuffer, specialStr, cb);
}
], done);
}); // 78.1.1
}); // 80.1.1
it('78.1.2 PLSQL, CLOB&BLOB, bind a string and a JPG file', function(done) {
it('80.1.2 PLSQL, CLOB&BLOB, bind a string and a JPG file', function(done) {
var preparedCLOBID = 701;
var sequence = 2;
var size = 40000;
var specialStr = "78.1.2";
var specialStr = "80.1.2";
var bigStr = random.getRandomString(size, specialStr);
async.series([
@ -432,13 +432,13 @@ describe('78.lobBindAsStringBuffer.js', function() {
verifyBlobValueWithFileData(sql_2, cb);
}
], done);
}); // 78.1.2
}); // 80.1.2
it('78.1.3 PLSQL, CLOB&BLOB, bind a txt file and a Buffer', function(done) {
it('80.1.3 PLSQL, CLOB&BLOB, bind a txt file and a Buffer', function(done) {
var preparedCLOBID = 200;
var sequence = 303;
var size = 40000;
var specialStr = "78.1.3";
var specialStr = "80.1.3";
var bigStr = random.getRandomString(size, specialStr);
var bigBuffer = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
@ -481,11 +481,11 @@ describe('78.lobBindAsStringBuffer.js', function() {
verifyBlobValueWithBuffer(sql_2, bigBuffer, specialStr,cb);
}
], done);
}); // 78.1.3
}); // 80.1.3
}); // 78.1
}); // 80.1
describe('78.2 Multiple LOBs, BIND_OUT', function() {
describe('80.2 Multiple LOBs, BIND_OUT', function() {
var proc = "CREATE OR REPLACE PROCEDURE nodb_lobs_out_782 (lob_id IN NUMBER, clob OUT CLOB, blob OUT BLOB) \n" +
"AS \n" +
"BEGIN \n" +
@ -521,9 +521,9 @@ describe('78.lobBindAsStringBuffer.js', function() {
);
};
it('78.2.1 PLSQL, CLOB&BLOB, bind a string and a buffer', function(done) {
it('80.2.1 PLSQL, CLOB&BLOB, bind a string and a buffer', function(done) {
var length = 50000;
var specialStr = "78.2.1";
var specialStr = "80.2.1";
var sequence = 311;
var bigStr = random.getRandomString(length, specialStr);
var bigBuffer = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
@ -565,11 +565,11 @@ describe('78.lobBindAsStringBuffer.js', function() {
}
], done);
}); // 78.2.1
}); // 80.2.1
it('78.2.2 PLSQL, CLOB&BLOB, bind a string and a JPG file', function(done) {
it('80.2.2 PLSQL, CLOB&BLOB, bind a string and a JPG file', function(done) {
var size = 40000;
var specialStr = "78.2.2";
var specialStr = "80.2.2";
var bigStr = random.getRandomString(size, specialStr);
var sequence = 312;
var bindVar = {
@ -644,11 +644,11 @@ describe('78.lobBindAsStringBuffer.js', function() {
}
], done);
}); // 78.2.2
}); // 80.2.2
it('78.2.3 PLSQL, CLOB&BLOB, bind a txt file and a buffer', function(done) {
it('80.2.3 PLSQL, CLOB&BLOB, bind a txt file and a buffer', function(done) {
var size = 40000;
var specialStr = "78.2.3";
var specialStr = "80.2.3";
var bigStr = random.getRandomString(size, specialStr);
var bigBuffer = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
var sequence = 313;
@ -719,11 +719,11 @@ describe('78.lobBindAsStringBuffer.js', function() {
});
}
], done);
}); // 78.2.3
}); // 80.2.3
}); // 78.2
}); // 80.2
describe('78.3 Multiple LOBs, BIND_INOUT', function() {
describe('80.3 Multiple LOBs, BIND_INOUT', function() {
var lobs_proc_inout = "CREATE OR REPLACE PROCEDURE nodb_lobs_in_out_783 (clob IN OUT CLOB, blob IN OUT BLOB) \n" +
"AS \n" +
"BEGIN \n" +
@ -741,8 +741,8 @@ describe('78.lobBindAsStringBuffer.js', function() {
executeSQL(proc_drop, done);
}); // after
it('78.3.1 PLSQL, BIND_INOUT, bind a 32K string and a 32K buffer', function(done) {
var specialStr = "78.3.1";
it('80.3.1 PLSQL, BIND_INOUT, bind a 32K string and a 32K buffer', function(done) {
var specialStr = "80.3.1";
var size = 32768;
var bigStr = random.getRandomString(size, specialStr);
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
@ -772,10 +772,10 @@ describe('78.lobBindAsStringBuffer.js', function() {
);
}
], done);
}); // 78.3.1
}); // 80.3.1
it('78.3.2 PLSQL, BIND_INOUT, bind a (64K - 1) string and a (64K - 1) buffer', function(done) {
var specialStr = "78.3.2";
it('80.3.2 PLSQL, BIND_INOUT, bind a (64K - 1) string and a (64K - 1) buffer', function(done) {
var specialStr = "80.3.2";
var size = 65535;
var bigStr = random.getRandomString(size, specialStr);
var bufferStr = node6plus ? Buffer.from(bigStr, "utf-8") : new Buffer(bigStr, "utf-8");
@ -805,8 +805,8 @@ describe('78.lobBindAsStringBuffer.js', function() {
);
}
], done);
}); // 78.3.2
}); // 80.3.2
}); // 78.3
}); // 80.3
});

View File

@ -19,7 +19,7 @@
* See LICENSE.md for relevant licenses.
*
* NAME
* 81. lobProperties2.js
* 83. lobProperties2.js
*
* DESCRIPTION
* Testing the properties of LOB that created by createLob().
@ -38,7 +38,7 @@ var should = require('should');
var async = require('async');
var dbConfig = require('./dbconfig.js');
describe("81. lobProperties2.js", function() {
describe("83. lobProperties2.js", function() {
var connection;
@ -80,11 +80,11 @@ describe("81. lobProperties2.js", function() {
});
}; // checkChunkSize
it("81.1 CLOB: chunkSize (read-only)", function(done) {
it("83.1 CLOB: chunkSize (read-only)", function(done) {
checkChunkSize(oracledb.CLOB, done);
});
it("81.2 BLOB: chunkSize (read-only)", function(done) {
it("83.2 BLOB: chunkSize (read-only)", function(done) {
checkChunkSize(oracledb.BLOB, done);
});
@ -110,11 +110,11 @@ describe("81. lobProperties2.js", function() {
});
}; // checkLength
it("81.3 CLOB: length (read-only)", function(done) {
it("83.3 CLOB: length (read-only)", function(done) {
checkLength(oracledb.CLOB, done);
});
it("81.4 BLOB: length (read-only)", function(done) {
it("83.4 BLOB: length (read-only)", function(done) {
checkLength(oracledb.BLOB, done);
});
@ -140,15 +140,15 @@ describe("81. lobProperties2.js", function() {
});
}; // checkType
it("81.5 CLOB: type (read-only)", function(done) {
it("83.5 CLOB: type (read-only)", function(done) {
checkType(oracledb.CLOB, done);
});
it("81.6 BLOB: type (read-only)", function(done) {
it("83.6 BLOB: type (read-only)", function(done) {
checkType(oracledb.CLOB, done);
});
describe("81.7 pieceSize", function() {
describe("83.7 pieceSize", function() {
var defaultChunkSize;
var clob, blob;
@ -186,7 +186,7 @@ describe("81. lobProperties2.js", function() {
], done);
}); // after
it("81.7.1 default value is chunkSize", function(done) {
it("83.7.1 default value is chunkSize", function(done) {
var t1 = clob.pieceSize,
t2 = blob.pieceSize;
@ -195,7 +195,7 @@ describe("81. lobProperties2.js", function() {
done();
});
it("81.7.2 can be increased", function(done) {
it("83.7.2 can be increased", function(done) {
var newValue = clob.pieceSize * 5;
clob.pieceSize = clob.pieceSize * 5;
@ -210,7 +210,7 @@ describe("81. lobProperties2.js", function() {
done();
});
it("81.7.3 can be decreased", function(done) {
it("83.7.3 can be decreased", function(done) {
if (defaultChunkSize <= 500) {
console.log('As default chunkSize is too small, this case is not applicable');
} else {
@ -228,7 +228,7 @@ describe("81. lobProperties2.js", function() {
return done();
});
it("81.7.4 can be zero", function(done) {
it("83.7.4 can be zero", function(done) {
clob.pieceSize = 0;
blob.pieceSize = 0;
@ -242,7 +242,7 @@ describe("81. lobProperties2.js", function() {
done();
});
it("81.7.5 cannot be less than zero", function(done) {
it("83.7.5 cannot be less than zero", function(done) {
try {
clob.pieceSize = -100;
} catch(err) {
@ -258,7 +258,7 @@ describe("81. lobProperties2.js", function() {
done();
});
it("81.7.6 cannot be null", function(done) {
it("83.7.6 cannot be null", function(done) {
try {
clob.pieceSize = null;
} catch(err) {
@ -274,7 +274,7 @@ describe("81. lobProperties2.js", function() {
done();
});
it("81.7.7 must be a number", function(done) {
it("83.7.7 must be a number", function(done) {
try {
clob.pieceSize = NaN;
} catch(err) {
@ -289,6 +289,6 @@ describe("81. lobProperties2.js", function() {
done();
});
}); // 81.7
}); // 83.7
});

View File

@ -78,10 +78,16 @@ test/poolPing.js
test/clobPlsqlBindAsString_bindin.js
test/clobPlsqlBindAsString_bindout.js
test/clobPlsqlBindAsString_bindinout.js
test/blobPlsqlBindAsBuffer.js
test/blobPlsqlBindAsBuffer_bindin.js
test/blobPlsqlBindAsBuffer_bindout.js
test/blobPlsqlBindAsBuffer_bindinout.js
test/lobBindAsStringBuffer.js
test/clobDMLBindAsString.js
test/blobDMLBindAsBuffer.js
test/lobProperties2.js
test/fetchClobAsString.js
test/fetchBlobAsBuffer.js
test/fetchClobAsString1.js
test/fetchClobAsString2.js
test/fetchClobAsString3.js
test/fetchBlobAsBuffer1.js
test/fetchBlobAsBuffer2.js
test/fetchBlobAsBuffer3.js

View File

@ -680,7 +680,7 @@ describe('44. plsqlBindIndexedTable2.js', function() {
},
function(err) {
should.exist(err);
(err.message).should.startWith('ORA-06502');
(err.message).should.startWith('ORA-06502:');
// ORA-06502: PL/SQL: numeric or value error: host bind array too small
callback();
}

View File

@ -229,7 +229,7 @@ describe('70. plsqlBindScalar.js', function() {
function(err) {
should.exist(err);
// console.log(result);
(err.message).should.startWith('NJS-011');
(err.message).should.startWith('NJS-011:');
done();
}
);
@ -335,7 +335,7 @@ describe('70. plsqlBindScalar.js', function() {
bindVar,
function(err) {
should.exist(err);
(err.message).should.startWith('NJS-011');
(err.message).should.startWith('NJS-011:');
// console.log(result);
done();
}
@ -3345,7 +3345,7 @@ describe('70. plsqlBindScalar.js', function() {
function(err) {
should.exist(err);
//ORA-01839: date not valid for month specified
(err.message).should.startWith("ORA-01839");
(err.message).should.startWith("ORA-01839:");
done();
}
);
@ -4143,7 +4143,7 @@ describe('70. plsqlBindScalar.js', function() {
function(err) {
should.exist(err);
//ORA-01839: date not valid for month specified
(err.message).should.startWith("ORA-01839");
(err.message).should.startWith("ORA-01839:");
done();
}
);
@ -4940,7 +4940,7 @@ describe('70. plsqlBindScalar.js', function() {
function(err) {
should.exist(err);
//ORA-01839: date not valid for month specified
(err.message).should.startWith("ORA-01839");
(err.message).should.startWith("ORA-01839:");
done();
}
);