Test LONG PL/SQL binding
This commit is contained in:
parent
1234216407
commit
8fdd9655eb
|
@ -3416,4 +3416,58 @@ Overview of node-oracledb functional tests
|
|||
128.1 stream txt file into CLOB column
|
||||
128.1.1 works with 64KB txt file
|
||||
128.1.2 works with 64KB+1 txt file
|
||||
128.1.3 works with 1MB+1 txt file
|
||||
128.1.3 works with 1MB+1 txt file
|
||||
|
||||
129. longProcedureBind_inout.js
|
||||
129.1 PLSQL PROCEDURE BIND IN OUT AS LONG
|
||||
129.1.1 works with NULL
|
||||
129.1.2 works with undefined
|
||||
129.1.3 works with empty string
|
||||
129.1.4 works with data size 4000
|
||||
129.1.5 works with data size (32K - 1)
|
||||
129.1.6 set maxSize to size (32K - 1)
|
||||
129.1.7 set maxSize to size 1GB
|
||||
129.2 PLSQL PROCEDURE BIND IN OUT AS STRING
|
||||
129.2.1 works with NULL
|
||||
129.2.2 works with undefined
|
||||
129.2.3 works with empty string
|
||||
129.2.4 works with data size 4000
|
||||
129.2.5 works with data size (32K - 1)
|
||||
129.2.6 set maxSize to size (32K - 1)
|
||||
129.2.7 set maxSize to size 1GB
|
||||
|
||||
130. longProcedureBind_out.js
|
||||
130.1 PLSQL PROCEDURE BIND OUT AS LONG
|
||||
130.1.1 works with NULL
|
||||
130.1.2 works with undefined
|
||||
130.1.3 works with empty string
|
||||
130.1.4 works with data size 4000
|
||||
130.1.5 works with data size (32K - 1)
|
||||
130.1.6 set maxSize to size (32K - 1)
|
||||
130.1.7 set maxSize to size 1GB
|
||||
130.2 PLSQL PROCEDURE BIND OUT AS STRING
|
||||
130.2.1 works with NULL
|
||||
130.2.2 works with undefined
|
||||
130.2.3 works with empty string
|
||||
130.2.4 works with data size 4000
|
||||
130.2.5 works with data size (32K - 1)
|
||||
130.2.6 set maxSize to size (32K - 1)
|
||||
130.2.7 set maxSize to size 1GB
|
||||
|
||||
131. longProcedureBind_in.js
|
||||
131.1 PLSQL PROCEDURE BIND IN AS LONG
|
||||
131.1.1 works with NULL
|
||||
131.1.2 works with undefined
|
||||
131.1.3 works with empty string
|
||||
131.1.4 works with data size 4000
|
||||
131.1.5 works with data size (32K - 1)
|
||||
131.1.6 set maxSize to size (32K - 1)
|
||||
131.1.7 set maxSize to size 1GB
|
||||
131.2 PLSQL PROCEDURE BIND IN AS STRING
|
||||
131.2.1 works with NULL
|
||||
131.2.2 works with undefined
|
||||
131.2.3 works with empty string
|
||||
131.2.4 works with data size 4000
|
||||
131.2.5 works with data size (32K - 1)
|
||||
131.2.6 set maxSize to size (32K - 1)
|
||||
131.2.7 set maxSize to size 1GB
|
||||
|
|
|
@ -0,0 +1,279 @@
|
|||
/* 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
|
||||
* 131. longProcedureBind_in.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Test LONG type PLSQL procedure support.
|
||||
* Long column restrictions: http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements001.htm#SQLRF00201
|
||||
*
|
||||
* 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 should = require('should');
|
||||
var async = require('async');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
var random = require('./random.js');
|
||||
var sql = require('./sql.js');
|
||||
|
||||
describe('131. longProcedureBind_in.js', function() {
|
||||
this.timeout(100000);
|
||||
var connection = null;
|
||||
var tableName = "nodb_long_128";
|
||||
var insertID = 0;
|
||||
var table_create = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE " + tableName + " PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE " + tableName + " ( \n" +
|
||||
" id NUMBER, \n" +
|
||||
" content LONG \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
var table_drop = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function(cb) {
|
||||
sql.executeSql(connection, table_create, {}, {}, cb);
|
||||
}
|
||||
], done);
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
sql.executeSql(connection, table_drop, {}, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
}); // after
|
||||
|
||||
beforeEach(function(done) {
|
||||
insertID++;
|
||||
done();
|
||||
});
|
||||
|
||||
describe('131.1 PLSQL PROCEDURE BIND IN AS LONG', function() {
|
||||
var proc_bindin_name = "nodb_long_bindin_proc_1";
|
||||
var proc_bindin_create = "CREATE OR REPLACE PROCEDURE " + proc_bindin_name + " (ID IN NUMBER, CONTENT IN LONG) \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " values (ID, CONTENT); \n" +
|
||||
"END " + proc_bindin_name + ";";
|
||||
var proc_bindin_exec = "BEGIN " + proc_bindin_name + " (:i, :c); END;";
|
||||
var proc_bindin_drop = "DROP PROCEDURE " + proc_bindin_name;
|
||||
|
||||
before(function(done) {
|
||||
sql.executeSql(connection, proc_bindin_create, {}, {}, done);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
sql.executeSql(connection, proc_bindin_drop, {}, {}, done);
|
||||
});
|
||||
|
||||
it('131.1.1 works with NULL', function(done) {
|
||||
var insertedStr = null;
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
});
|
||||
|
||||
it('131.1.2 works with undefined', function(done) {
|
||||
var insertedStr = undefined;
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
});
|
||||
|
||||
it('131.1.3 works with empty string', function(done) {
|
||||
var insertedStr = "";
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
});
|
||||
|
||||
it('131.1.4 works with data size 4000', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(4000);
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
});
|
||||
|
||||
it('131.1.5 works with data size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(32767);
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
});
|
||||
|
||||
it('131.1.6 set maxSize to size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
long_bindin_maxSize(insertedStr, proc_bindin_exec, 32767, done);
|
||||
});
|
||||
|
||||
it('131.1.7 set maxSize to size 1GB', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
var maxsize = 1 * 1024 * 1024 * 1024;
|
||||
long_bindin_maxSize(insertedStr, proc_bindin_exec, maxsize, done);
|
||||
});
|
||||
|
||||
}); // 131.1
|
||||
|
||||
describe('131.2 PLSQL PROCEDURE BIND IN AS STRING', function() {
|
||||
var proc_bindin_name = "nodb_long_bindin_proc_2";
|
||||
var proc_bindin_create = "CREATE OR REPLACE PROCEDURE " + proc_bindin_name + " (ID IN NUMBER, CONTENT IN VARCHAR2) \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " values (ID, CONTENT); \n" +
|
||||
"END " + proc_bindin_name + ";";
|
||||
var proc_bindin_exec = "BEGIN " + proc_bindin_name + " (:i, :c); END;";
|
||||
var proc_bindin_drop = "DROP PROCEDURE " + proc_bindin_name;
|
||||
|
||||
before(function(done) {
|
||||
sql.executeSql(connection, proc_bindin_create, {}, {}, done);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
sql.executeSql(connection, proc_bindin_drop, {}, {}, done);
|
||||
});
|
||||
|
||||
it('131.2.1 works with NULL', function(done) {
|
||||
var insertedStr = null;
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
});
|
||||
|
||||
it('131.2.2 works with undefined', function(done) {
|
||||
var insertedStr = undefined;
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
});
|
||||
|
||||
it('131.2.3 works with empty string', function(done) {
|
||||
var insertedStr = "";
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
});
|
||||
|
||||
it('131.2.4 works with data size 4000', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(4000);
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
});
|
||||
|
||||
it('131.2.5 works with data size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(32767);
|
||||
long_bindin(insertedStr, proc_bindin_exec, done);
|
||||
});
|
||||
|
||||
it('131.2.6 set maxSize to size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
long_bindin_maxSize(insertedStr, proc_bindin_exec, 32767, done);
|
||||
});
|
||||
|
||||
it('131.2.7 set maxSize to size 1GB', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
var maxsize = 1 * 1024 * 1024 * 1024;
|
||||
long_bindin_maxSize(insertedStr, proc_bindin_exec, maxsize, done);
|
||||
});
|
||||
|
||||
}); // 131.2
|
||||
|
||||
var long_bindin = function(insertContent, proc_bindin_exec, callback) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
var bind_in_var = {
|
||||
i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { val: insertContent, dir: oracledb.BIND_IN, type: oracledb.STRING }
|
||||
};
|
||||
connection.execute(
|
||||
proc_bindin_exec,
|
||||
bind_in_var,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
var expected = insertContent;
|
||||
if(insertContent == "" || insertContent == undefined) {
|
||||
expected = null;
|
||||
}
|
||||
checkResult(expected, cb);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
var long_bindin_maxSize = function(insertContent, proc_bindin_exec, maxsize, callback) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
var bind_in_var = {
|
||||
i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { val: insertContent, dir: oracledb.BIND_IN, type: oracledb.STRING, maxSize: maxsize }
|
||||
};
|
||||
connection.execute(
|
||||
proc_bindin_exec,
|
||||
bind_in_var,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
var expected = insertContent;
|
||||
if(insertContent == "" || insertContent == undefined) {
|
||||
expected = null;
|
||||
}
|
||||
checkResult(expected, cb);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
var checkResult = function(expected, callback) {
|
||||
connection.execute(
|
||||
"select * from " + tableName + " where id = " + insertID,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rows[0][0], insertID);
|
||||
should.strictEqual(result.rows[0][1], expected);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
});
|
|
@ -0,0 +1,256 @@
|
|||
/* 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
|
||||
* 129. longProcedureBind_inout.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Test LONG type PLSQL procedure support.
|
||||
* Long column restrictions: http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements001.htm#SQLRF00201
|
||||
*
|
||||
* 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 should = require('should');
|
||||
var async = require('async');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
var random = require('./random.js');
|
||||
var sql = require('./sql.js');
|
||||
|
||||
describe('129. longProcedureBind_inout.js', function() {
|
||||
this.timeout(100000);
|
||||
var connection = null;
|
||||
var tableName = "nodb_long_129";
|
||||
var insertID = 0;
|
||||
var table_create = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE " + tableName + " PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE " + tableName + " ( \n" +
|
||||
" id NUMBER, \n" +
|
||||
" content LONG \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
var table_drop = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function(cb) {
|
||||
sql.executeSql(connection, table_create, {}, {}, cb);
|
||||
}
|
||||
], done);
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
sql.executeSql(connection, table_drop, {}, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
}); // after
|
||||
|
||||
beforeEach(function(done) {
|
||||
insertID++;
|
||||
done();
|
||||
});
|
||||
|
||||
describe('129.1 PLSQL PROCEDURE BIND IN OUT AS LONG', function() {
|
||||
var proc_bindinout_name = "nodb_long_bindinout_proc_1";
|
||||
var proc_bindinout_create = "CREATE OR REPLACE PROCEDURE " + proc_bindinout_name + " (num IN NUMBER, C IN OUT LONG) \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " values (num, C); \n" +
|
||||
" select content into C from " + tableName + " where num = ID; \n" +
|
||||
"END " + proc_bindinout_name + ";";
|
||||
var proc_bindinout_exec = "BEGIN " + proc_bindinout_name + " (:i, :c); END;";
|
||||
var proc_bindinout_drop = "DROP PROCEDURE " + proc_bindinout_name;
|
||||
|
||||
before(function(done) {
|
||||
sql.executeSql(connection, proc_bindinout_create, {}, {}, done);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
sql.executeSql(connection, proc_bindinout_drop, {}, {}, done);
|
||||
});
|
||||
|
||||
it('129.1.1 works with NULL', function(done) {
|
||||
var insertedStr = null;
|
||||
long_bindinout(insertedStr, proc_bindinout_exec, done);
|
||||
});
|
||||
|
||||
it('129.1.2 works with undefined', function(done) {
|
||||
var insertedStr = undefined;
|
||||
long_bindinout(insertedStr, proc_bindinout_exec, done);
|
||||
});
|
||||
|
||||
it('129.1.3 works with empty string', function(done) {
|
||||
var insertedStr = "";
|
||||
long_bindinout(insertedStr, proc_bindinout_exec, done);
|
||||
});
|
||||
|
||||
it('129.1.4 works with data size 4000', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(4000);
|
||||
long_bindinout(insertedStr, proc_bindinout_exec, done);
|
||||
});
|
||||
|
||||
it('129.1.5 works with data size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(32767);
|
||||
long_bindinout(insertedStr, proc_bindinout_exec, done);
|
||||
});
|
||||
|
||||
it('129.1.6 set maxSize to size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
long_bindinout_maxSize(insertedStr, proc_bindinout_exec, 32767, done);
|
||||
});
|
||||
|
||||
it('129.1.7 set maxSize to size 1GB', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
var maxsize = 1 * 1024 * 1024 * 1024;
|
||||
long_bindinout_maxSize(insertedStr, proc_bindinout_exec, maxsize, done);
|
||||
});
|
||||
|
||||
}); // 129.1
|
||||
|
||||
describe('129.2 PLSQL PROCEDURE BIND IN OUT AS STRING', function() {
|
||||
var proc_bindinout_name = "nodb_long_bindinout_proc_2";
|
||||
var proc_bindinout_create = "CREATE OR REPLACE PROCEDURE " + proc_bindinout_name + " (num IN NUMBER, C IN OUT VARCHAR2) \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " values (num, C); \n" +
|
||||
" select content into C from " + tableName + " where num = ID; \n" +
|
||||
"END " + proc_bindinout_name + ";";
|
||||
var proc_bindinout_exec = "BEGIN " + proc_bindinout_name + " (:i, :c); END;";
|
||||
var proc_bindinout_drop = "DROP PROCEDURE " + proc_bindinout_name;
|
||||
|
||||
before(function(done) {
|
||||
sql.executeSql(connection, proc_bindinout_create, {}, {}, done);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
sql.executeSql(connection, proc_bindinout_drop, {}, {}, done);
|
||||
});
|
||||
|
||||
it('129.2.1 works with NULL', function(done) {
|
||||
var insertedStr = null;
|
||||
long_bindinout(insertedStr, proc_bindinout_exec, done);
|
||||
});
|
||||
|
||||
it('129.2.2 works with undefined', function(done) {
|
||||
var insertedStr = undefined;
|
||||
long_bindinout(insertedStr, proc_bindinout_exec, done);
|
||||
});
|
||||
|
||||
it('129.2.3 works with empty string', function(done) {
|
||||
var insertedStr = "";
|
||||
long_bindinout(insertedStr, proc_bindinout_exec, done);
|
||||
});
|
||||
|
||||
it('129.2.4 works with data size 4000', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(4000);
|
||||
long_bindinout(insertedStr, proc_bindinout_exec, done);
|
||||
});
|
||||
|
||||
it('129.2.5 works with data size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(32767);
|
||||
long_bindinout(insertedStr, proc_bindinout_exec, done);
|
||||
});
|
||||
|
||||
it('129.2.6 set maxSize to size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
long_bindinout_maxSize(insertedStr, proc_bindinout_exec, 32767, done);
|
||||
});
|
||||
|
||||
it('129.2.7 set maxSize to size 1GB', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
var maxsize = 1 * 1024 * 1024 * 1024;
|
||||
long_bindinout_maxSize(insertedStr, proc_bindinout_exec, maxsize, done);
|
||||
});
|
||||
|
||||
}); // 129.2
|
||||
|
||||
var long_bindinout = function(insertContent, proc_bindinout_exec, callback) {
|
||||
var bind_in_var = {
|
||||
i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { val: insertContent, dir: oracledb.BIND_INOUT, type: oracledb.STRING }
|
||||
};
|
||||
connection.execute(
|
||||
proc_bindinout_exec,
|
||||
bind_in_var,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var expected = insertContent;
|
||||
if(insertContent == "" || insertContent == undefined) {
|
||||
expected = null;
|
||||
}
|
||||
should.strictEqual(result.outBinds.c, expected);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var long_bindinout_maxSize = function(insertContent, proc_bindinout_exec, maxsize, callback) {
|
||||
var bind_in_var = {
|
||||
i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { val: insertContent, dir: oracledb.BIND_INOUT, type: oracledb.STRING, maxSize: maxsize }
|
||||
};
|
||||
connection.execute(
|
||||
proc_bindinout_exec,
|
||||
bind_in_var,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var expected = insertContent;
|
||||
if(insertContent == "" || insertContent == undefined) {
|
||||
expected = null;
|
||||
}
|
||||
should.strictEqual(result.outBinds.c, expected);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
});
|
|
@ -0,0 +1,266 @@
|
|||
/* 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
|
||||
* 130. longProcedureBind_out.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Test LONG type PLSQL procedure support.
|
||||
* Long column restrictions: http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements001.htm#SQLRF00201
|
||||
*
|
||||
* 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 should = require('should');
|
||||
var async = require('async');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
var random = require('./random.js');
|
||||
var sql = require('./sql.js');
|
||||
|
||||
describe('130. longProcedureBind_out.js', function() {
|
||||
this.timeout(100000);
|
||||
var connection = null;
|
||||
var tableName = "nodb_long_130";
|
||||
var insertID = 0;
|
||||
var table_create = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); \n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE('DROP TABLE " + tableName + " PURGE'); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE (' \n" +
|
||||
" CREATE TABLE " + tableName + " ( \n" +
|
||||
" id NUMBER, \n" +
|
||||
" content LONG \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
var table_drop = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function(cb) {
|
||||
sql.executeSql(connection, table_create, {}, {}, cb);
|
||||
}
|
||||
], done);
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
sql.executeSql(connection, table_drop, {}, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
}); // after
|
||||
|
||||
beforeEach(function(done) {
|
||||
insertID++;
|
||||
done();
|
||||
});
|
||||
|
||||
describe('130.1 PLSQL PROCEDURE BIND OUT AS LONG', function() {
|
||||
var proc_bindout_name = "nodb_long_bindout_proc_1";
|
||||
var proc_bindout_create = "CREATE OR REPLACE PROCEDURE " + proc_bindout_name + " (num IN NUMBER, C OUT LONG) \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" select content into C from " + tableName + " where num = ID; \n" +
|
||||
"END " + proc_bindout_name + ";";
|
||||
var proc_bindout_exec = "BEGIN " + proc_bindout_name + " (:i, :c); END;";
|
||||
var proc_bindout_drop = "DROP PROCEDURE " + proc_bindout_name;
|
||||
|
||||
before(function(done) {
|
||||
sql.executeSql(connection, proc_bindout_create, {}, {}, done);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
sql.executeSql(connection, proc_bindout_drop, {}, {}, done);
|
||||
});
|
||||
|
||||
it('130.1.1 works with NULL', function(done) {
|
||||
var insertedStr = null;
|
||||
var maxsize = 10;
|
||||
long_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
});
|
||||
|
||||
it('130.1.2 works with undefined', function(done) {
|
||||
var insertedStr = undefined;
|
||||
var maxsize = 10;
|
||||
long_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
});
|
||||
|
||||
it('130.1.3 works with empty string', function(done) {
|
||||
var insertedStr = "";
|
||||
var maxsize = 10;
|
||||
long_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
});
|
||||
|
||||
it('130.1.4 works with data size 4000', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(4000);
|
||||
var maxsize = 4000;
|
||||
long_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
});
|
||||
|
||||
it('130.1.5 works with data size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(32767);
|
||||
var maxsize = 32767;
|
||||
long_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
});
|
||||
|
||||
it('130.1.6 set maxSize to size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
long_bindout(insertedStr, proc_bindout_exec, 32767, done);
|
||||
});
|
||||
|
||||
it('130.1.7 set maxSize to size 1GB', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
var maxsize = 1 * 1024 * 1024 * 1024;
|
||||
long_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
});
|
||||
|
||||
}); // 130.1
|
||||
|
||||
describe('130.2 PLSQL PROCEDURE BIND OUT AS STRING', function() {
|
||||
var proc_bindout_name = "nodb_long_bindout_proc_2";
|
||||
var proc_bindout_create = "CREATE OR REPLACE PROCEDURE " + proc_bindout_name + " (num IN NUMBER, C OUT VARCHAR2) \n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" select content into C from " + tableName + " where num = ID; \n" +
|
||||
"END " + proc_bindout_name + ";";
|
||||
var proc_bindout_exec = "BEGIN " + proc_bindout_name + " (:i, :c); END;";
|
||||
var proc_bindout_drop = "DROP PROCEDURE " + proc_bindout_name;
|
||||
|
||||
before(function(done) {
|
||||
sql.executeSql(connection, proc_bindout_create, {}, {}, done);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
sql.executeSql(connection, proc_bindout_drop, {}, {}, done);
|
||||
});
|
||||
|
||||
it('130.2.1 works with NULL', function(done) {
|
||||
var insertedStr = null;
|
||||
var maxsize = 10;
|
||||
long_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
});
|
||||
|
||||
it('130.2.2 works with undefined', function(done) {
|
||||
var insertedStr = undefined;
|
||||
var maxsize = 10;
|
||||
long_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
});
|
||||
|
||||
it('130.2.3 works with empty string', function(done) {
|
||||
var insertedStr = "";
|
||||
var maxsize = 10;
|
||||
long_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
});
|
||||
|
||||
it('130.2.4 works with data size 4000', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(4000);
|
||||
var maxsize = 4000;
|
||||
long_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
});
|
||||
|
||||
it('130.2.5 works with data size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(32767);
|
||||
var maxsize = 32767;
|
||||
long_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
});
|
||||
|
||||
it('130.2.6 set maxSize to size (32K - 1)', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
long_bindout(insertedStr, proc_bindout_exec, 32767, done);
|
||||
});
|
||||
|
||||
it('130.2.7 set maxSize to size 1GB', function(done) {
|
||||
var insertedStr = random.getRandomLengthString(100);
|
||||
var maxsize = 1 * 1024 * 1024 * 1024;
|
||||
long_bindout(insertedStr, proc_bindout_exec, maxsize, done);
|
||||
});
|
||||
|
||||
}); // 130.2
|
||||
|
||||
var long_bindout = function(insertContent, proc_bindin_exec, maxsize, callback) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
insert(insertContent, cb);
|
||||
},
|
||||
function(cb) {
|
||||
var bind_in_var = {
|
||||
i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: maxsize }
|
||||
};
|
||||
connection.execute(
|
||||
proc_bindin_exec,
|
||||
bind_in_var,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var expected = insertContent;
|
||||
if(insertContent == "" || insertContent == undefined) {
|
||||
expected = null;
|
||||
}
|
||||
should.strictEqual(result.outBinds.c, expected);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
var insert = function(insertStr, callback) {
|
||||
connection.execute(
|
||||
"insert into " + tableName + " values (:i, :c)",
|
||||
{
|
||||
i: { val: insertID, dir: oracledb.BIND_IN, type: oracledb.NUMBER },
|
||||
c: { val: insertStr, type: oracledb.STRING, dir: oracledb.BIND_IN }
|
||||
},
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rowsAffected, 1);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
});
|
|
@ -58,8 +58,8 @@ test/resultSetClose.js
|
|||
test/resultSet2.js
|
||||
test/fetchAs.js
|
||||
test/nestedCursor.js
|
||||
|
||||
test/properties.js
|
||||
|
||||
test/lobResultSet.js
|
||||
test/clobPlsqlString.js
|
||||
test/checkClassesTypes.js
|
||||
|
@ -70,6 +70,7 @@ test/uninitializedLob.js
|
|||
test/writableProperties.js
|
||||
test/poolCache.js
|
||||
test/multipleLobInsertion.js
|
||||
|
||||
test/driverName.js
|
||||
test/plsqlBindScalar.js
|
||||
test/lobBind1.js
|
||||
|
@ -80,6 +81,7 @@ test/clobPlsqlBindAsString_bindout.js
|
|||
test/clobPlsqlBindAsString_bindinout.js
|
||||
test/blobPlsqlBindAsBuffer_bindin.js
|
||||
test/blobPlsqlBindAsBuffer_bindout.js
|
||||
|
||||
test/blobPlsqlBindAsBuffer_bindinout.js
|
||||
test/lobBindAsStringBuffer.js
|
||||
test/clobDMLBindAsString.js
|
||||
|
@ -90,6 +92,7 @@ test/fetchClobAsString2.js
|
|||
test/fetchClobAsString3.js
|
||||
test/fetchBlobAsBuffer1.js
|
||||
test/fetchBlobAsBuffer2.js
|
||||
|
||||
test/fetchBlobAsBuffer3.js
|
||||
test/fetchClobAsString4.js
|
||||
test/fetchBlobAsBuffer4.js
|
||||
|
@ -100,6 +103,7 @@ test/binding_functionBindInout.js
|
|||
test/binding_procedureBindOut.js
|
||||
test/binding_functionBindOut.js
|
||||
test/binding_DMLReturningInto.js
|
||||
|
||||
test/binding_functionBindIn.js
|
||||
test/binding_defaultBindIn.js
|
||||
test/binding_defaultBindInout.js
|
||||
|
@ -110,6 +114,7 @@ test/fetchRowidAsString.js
|
|||
test/rowidDMLBindAsString.js
|
||||
test/rowidProcedureBindAsString_bindin.js
|
||||
test/rowidFunctionBindAsString_bind.js
|
||||
|
||||
test/rowidProcedureBindAsString_bindout.js
|
||||
test/rowidProcedureBindAsString_bindinout.js
|
||||
test/rowidFunctionBindAsString_bindinout.js
|
||||
|
@ -120,12 +125,17 @@ test/fetchUrowidAsString.js
|
|||
test/fetchUrowidAsString_indexed.js
|
||||
test/urowidProcedureBindAsString_bindin.js
|
||||
test/urowidProcedureBindAsString_bindout.js
|
||||
|
||||
test/urowidProcedureBindAsString_bindinout.js
|
||||
test/urowidFunctionBindAsString_bind.js
|
||||
test/urowidFunctionBindAsString_bindinout.js
|
||||
test/dataTypeNclob.js
|
||||
test/nclobDMLBindAsString.js
|
||||
test/blobStream.js
|
||||
test/clobStream.js
|
||||
test/longDMLBind.js
|
||||
test/longrawDMLBind.js
|
||||
test/blobStream.js
|
||||
test/clobStream.js
|
||||
test/longProcedureBind_inout.js
|
||||
|
||||
test/longProcedureBind_out.js
|
||||
test/longProcedureBind_in.js
|
||||
|
|
|
@ -678,6 +678,7 @@ describe('115. urowidDMLBindAsString_indexed.js', function() {
|
|||
"insert into " + tableName_normal + " (ID, content) values (:i, :c) returning content into :o",
|
||||
bindVar,
|
||||
function(err, result) {
|
||||
should.not.exist(result);
|
||||
should.exist(err);
|
||||
should.strictEqual(err.message, "NJS-016: buffer is too small for OUT binds");
|
||||
cb();
|
||||
|
|
Loading…
Reference in New Issue