Test updates
This commit is contained in:
parent
faeb8d6890
commit
a4afa33eda
|
@ -0,0 +1,278 @@
|
|||
/* 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
|
||||
* 52. connClose.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Negative cases against connection.
|
||||
*
|
||||
* 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 assist = require('./dataTypeAssist.js');
|
||||
|
||||
describe('52. connClose.js', function() {
|
||||
|
||||
it('52.1 can not set property value after connection closes', function(done) {
|
||||
oracledb.getConnection(
|
||||
dbConfig,
|
||||
function(err, connection) {
|
||||
should.not.exist(err);
|
||||
var defaultSize = 30;
|
||||
should.strictEqual(connection.stmtCacheSize, defaultSize);
|
||||
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
should.throws(
|
||||
function() {
|
||||
connection.stmtCacheSize = 10;
|
||||
},
|
||||
/NJS-003: invalid connection/
|
||||
);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
}); // 52.1
|
||||
|
||||
it('52.2 can not get property value after connection closes', function(done) {
|
||||
oracledb.getConnection(
|
||||
dbConfig,
|
||||
function(err, connection) {
|
||||
should.not.exist(err);
|
||||
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
should.throws(
|
||||
function() {
|
||||
var newSize;
|
||||
newSize = connection.stmtCacheSize;
|
||||
should.not.exist(newSize);
|
||||
},
|
||||
/NJS-003: invalid connection/
|
||||
);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
}); // 52.2
|
||||
|
||||
it('52.3 can not set clientId property value', function(done) {
|
||||
oracledb.getConnection(
|
||||
dbConfig,
|
||||
function(err, connection) {
|
||||
should.not.exist(err);
|
||||
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
should.throws(
|
||||
function() {
|
||||
connection.clientId = "52.3";
|
||||
},
|
||||
/NJS-003: invalid connection/
|
||||
);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
}); // 52.3
|
||||
|
||||
it('52.4 can not set module property value', function(done) {
|
||||
oracledb.getConnection(
|
||||
dbConfig,
|
||||
function(err, connection) {
|
||||
should.not.exist(err);
|
||||
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
should.throws(
|
||||
function() {
|
||||
connection.module = "52.4";
|
||||
},
|
||||
/NJS-003: invalid connection/
|
||||
);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
}); // 52.4
|
||||
|
||||
it('52.5 can not set action property value', function(done) {
|
||||
oracledb.getConnection(
|
||||
dbConfig,
|
||||
function(err, connection) {
|
||||
should.not.exist(err);
|
||||
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
should.throws(
|
||||
function() {
|
||||
connection.module = "52.5";
|
||||
},
|
||||
/NJS-003: invalid connection/
|
||||
);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
}); // 52.5
|
||||
|
||||
it('52.6 can not get oracleServerVersion property value', function(done) {
|
||||
oracledb.getConnection(
|
||||
dbConfig,
|
||||
function(err, connection) {
|
||||
should.not.exist(err);
|
||||
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
should.throws(
|
||||
function() {
|
||||
var serverVer;
|
||||
serverVer = connection.oracleServerVersion;
|
||||
should.not.exist(serverVer);
|
||||
},
|
||||
/NJS-003: invalid connection/
|
||||
);
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
}); // 52.6
|
||||
|
||||
it('52.7 can not call execute() method', function(done) {
|
||||
oracledb.getConnection(
|
||||
dbConfig,
|
||||
function(err, connection) {
|
||||
should.not.exist(err);
|
||||
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
connection.execute(
|
||||
"select sysdate from dual",
|
||||
function(err, result) {
|
||||
should.not.exist(result);
|
||||
should.exist(err);
|
||||
should.strictEqual(
|
||||
err.message,
|
||||
"NJS-003: invalid connection"
|
||||
);
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
}); // 52.7
|
||||
|
||||
it('52.8 can not get metaData property after connection closes', function(done) {
|
||||
var tableName = "nodb_number";
|
||||
var numbers = assist.data.numbers;
|
||||
var connection = null;
|
||||
var resultSet = null;
|
||||
|
||||
async.series([
|
||||
function getConn(callback) {
|
||||
oracledb.getConnection(
|
||||
dbConfig,
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(callback) {
|
||||
assist.setUp(connection, tableName, numbers, callback);
|
||||
},
|
||||
function getResultSet(callback) {
|
||||
connection.execute(
|
||||
"SELECT * FROM " + tableName + " ORDER BY num",
|
||||
[],
|
||||
{ resultSet: true, outFormat: oracledb.OBJECT },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
resultSet = result.resultSet;
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function verifyMetaData(callback) {
|
||||
should.exist(resultSet.metaData);
|
||||
var t = resultSet.metaData;
|
||||
t.should.eql( [ { name: 'NUM' }, { name: 'CONTENT' } ] );
|
||||
callback();
|
||||
},
|
||||
function closeConn(callback) {
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
function getMetaData(callback) {
|
||||
should.throws(
|
||||
function() {
|
||||
var mdata;
|
||||
mdata = resultSet.metaData;
|
||||
should.not.exist(mdata);
|
||||
},
|
||||
/NJS-003: invalid connection/
|
||||
);
|
||||
callback();
|
||||
},
|
||||
function getConn(callback) {
|
||||
oracledb.getConnection(
|
||||
dbConfig,
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function dropTable(callback) {
|
||||
connection.execute(
|
||||
"DROP TABLE " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function closeConn(callback) {
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
},
|
||||
], done);
|
||||
});
|
||||
|
||||
});
|
|
@ -60,6 +60,7 @@ assist.allDataTypeNames =
|
|||
"nodb_timestamp5" : "TIMESTAMP WITH LOCAL TIME ZONE",
|
||||
"nodb_timestamp6" : "TIMESTAMP (9) WITH LOCAL TIME ZONE",
|
||||
"nodb_rowid" : "ROWID",
|
||||
"nodb_urowid" : "UROWID",
|
||||
"nodb_myclobs" : "CLOB",
|
||||
"nodb_myblobs" : "BLOB",
|
||||
"nodb_raw" : "RAW(2000)"
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
* DESCRIPTION
|
||||
* Testing Oracle data type support - ROWID.
|
||||
*
|
||||
* NOTE
|
||||
* Native ROWID support is still under enhancement request.
|
||||
*
|
||||
* NUMBERING RULE
|
||||
* Test numbers follow this numbering rule:
|
||||
* 1 - 20 are reserved for basic functional tests
|
||||
|
|
|
@ -0,0 +1,223 @@
|
|||
/* 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
|
||||
* 113. dataTypeUrowid.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Testing Oracle data type support - UROWID.
|
||||
*
|
||||
* 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 assist = require('./dataTypeAssist.js');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('113. dataTypeUrowid.js', function() {
|
||||
|
||||
var connection = null;
|
||||
var tableName = "nodb_urowid";
|
||||
var array = assist.data.numbersForBinaryFloat;
|
||||
var numRows = array.length; // number of rows to return from each call to getRows()
|
||||
|
||||
before('get one connection', function(done) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
after('release connection', function(done) {
|
||||
connection.release( function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('113.1 testing UROWID data type', function() {
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function makeTable(callback) {
|
||||
assist.createTable(connection, tableName, callback);
|
||||
},
|
||||
function insertOneRow(callback) {
|
||||
insertData(connection, tableName, callback);
|
||||
},
|
||||
function fillRowid(callback) {
|
||||
updateDate(connection, tableName, callback);
|
||||
}
|
||||
], done);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
connection.execute(
|
||||
"DROP table " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('113.1.1 query rowid', function(done) {
|
||||
connection.execute(
|
||||
"SELECT * FROM " + tableName,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
for(var i = 0; i < array.length; i++) {
|
||||
var resultVal = result.rows[i][1];
|
||||
should.strictEqual(typeof resultVal, "string");
|
||||
resultVal.should.not.be.null;
|
||||
should.exist(resultVal);
|
||||
}
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('113.1.2 works well with result set', function(done) {
|
||||
connection.execute(
|
||||
"SELECT * FROM " + tableName,
|
||||
[],
|
||||
{ resultSet: true, outFormat: oracledb.OBJECT },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.resultSet.metaData[0]).name.should.eql('NUM');
|
||||
(result.resultSet.metaData[1]).name.should.eql('CONTENT');
|
||||
fetchRowsFromRS(result.resultSet, done);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('113.1.3 works well with REF Cursor', function(done) {
|
||||
verifyRefCursor(connection, tableName, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('113.2 stores null value correctly', function() {
|
||||
it('113.2.1 testing Null, Empty string and Undefined', function(done) {
|
||||
assist.verifyNullValues(connection, tableName, done);
|
||||
});
|
||||
});
|
||||
|
||||
var insertData = function(connection, tableName, callback) {
|
||||
|
||||
async.forEach(array, function(element, cb) {
|
||||
var sql = "INSERT INTO " + tableName + "(num) VALUES(" + element + ")";
|
||||
connection.execute(
|
||||
sql,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
var updateDate = function(connection, tableName, callback) {
|
||||
async.forEach(array, function(element, cb) {
|
||||
var sql = "UPDATE " + tableName + " T SET content = T.ROWID where num = " + element;
|
||||
connection.execute(
|
||||
sql,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}, function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
var verifyRefCursor = function(connection, tableName, done) {
|
||||
var createProc =
|
||||
"CREATE OR REPLACE PROCEDURE testproc (p_out OUT SYS_REFCURSOR) " +
|
||||
"AS " +
|
||||
"BEGIN " +
|
||||
" OPEN p_out FOR " +
|
||||
" SELECT * FROM " + tableName + "; " +
|
||||
"END; ";
|
||||
async.series([
|
||||
function createProcedure(callback) {
|
||||
connection.execute(
|
||||
createProc,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
},
|
||||
function verify(callback) {
|
||||
connection.execute(
|
||||
"BEGIN testproc(:o); END;",
|
||||
[
|
||||
{ type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
],
|
||||
{ outFormat: oracledb.OBJECT },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
fetchRowsFromRS(result.outBinds[0], callback);
|
||||
}
|
||||
);
|
||||
},
|
||||
function dropProcedure(callback) {
|
||||
connection.execute(
|
||||
"DROP PROCEDURE testproc",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
};
|
||||
var fetchRowsFromRS = function(rs, cb) {
|
||||
rs.getRows(numRows, function(err, rows) {
|
||||
if(rows.length > 0) {
|
||||
for(var i = 0; i < rows.length; i++) {
|
||||
var resultVal = rows[i].CONTENT;
|
||||
resultVal.should.not.be.null;
|
||||
should.exist(resultVal);
|
||||
}
|
||||
return fetchRowsFromRS(rs, cb);
|
||||
} else {
|
||||
rs.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
});
|
|
@ -242,10 +242,10 @@
|
|||
12.7.1 maxRows option is ignored when resultSet option is true
|
||||
12.7.2 maxRows option is ignored with REF Cursor
|
||||
12.8 Testing errInvalidResultSet
|
||||
- 12.8.1 Negative: UPDATE BIND out with oracledb.CURSOR - bind by name
|
||||
- 12.8.2 Negative: UPDATE BIND out with oracledb.CURSOR - bind by position
|
||||
- 12.8.3 Negative: INSERT BIND out with oracledb.CURSOR - bind by name
|
||||
- 12.8.4 Negative: INSERT BIND out with oracledb.CURSOR - bind by position
|
||||
12.8.1 Negative: UPDATE BIND out with oracledb.CURSOR - bind by name
|
||||
12.8.2 Negative: UPDATE BIND out with oracledb.CURSOR - bind by position
|
||||
12.8.3 Negative: INSERT BIND out with oracledb.CURSOR - bind by name
|
||||
12.8.4 Negative: INSERT BIND out with oracledb.CURSOR - bind by position
|
||||
|
||||
13. stream1.js
|
||||
13.1 Testing QueryStream
|
||||
|
@ -572,7 +572,12 @@
|
|||
39.1 testing ROWID data type
|
||||
39.1.1 query rowid
|
||||
39.1.2 works well with result set
|
||||
39.1.3 works well with REF Cursor
|
||||
39.1.3 ROWID couldn't update
|
||||
39.1.4 can get data object number correctly
|
||||
39.1.5 can get datafile number correctly
|
||||
39.1.6 can get data block number correctly
|
||||
39.1.7 can get row number correctly
|
||||
39.1.8 works well with REF Cursor
|
||||
39.2 stores null value correctly
|
||||
39.2.1 testing Null, Empty string and Undefined
|
||||
|
||||
|
@ -708,7 +713,8 @@
|
|||
56.12 Negative - null
|
||||
56.13 Negative - undefined
|
||||
56.14 Negative - NaN
|
||||
56.xx Negative - invalid type of value
|
||||
56.15 Negative - invalid type of value, number
|
||||
56.16 Negative - invalid type of value, string
|
||||
|
||||
57. nestedCursor.js
|
||||
57.1 testing nested cursor support - result set
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
* See LICENSE.md for relevant licenses.
|
||||
*
|
||||
* NAME
|
||||
* 51. poolTerminate.js
|
||||
* 51. poolClose.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Negative cases about pool.terminate().
|
||||
|
@ -38,7 +38,7 @@ var should = require('should');
|
|||
var async = require('async');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
|
||||
describe('51. poolTerminate.js', function(){
|
||||
describe('51. poolClose.js', function(){
|
||||
|
||||
it('51.1 can not get/set the attributes of terminated pool', function(done) {
|
||||
var pMin = 2;
|
||||
|
@ -116,7 +116,7 @@ describe('51. poolTerminate.js', function(){
|
|||
); // createPool()
|
||||
}); // 51.2
|
||||
|
||||
it.skip('51.3 can not terminate the same pool multiple times', function(done) {
|
||||
it('51.3 can not terminate the same pool multiple times', function(done) {
|
||||
oracledb.createPool(
|
||||
dbConfig,
|
||||
function(err, pool) {
|
||||
|
@ -137,7 +137,7 @@ describe('51. poolTerminate.js', function(){
|
|||
); // createPool()
|
||||
}); // 51.3
|
||||
|
||||
it.skip('51.4 can not close the same pool multiple times', function(done) {
|
||||
it('51.4 can not close the same pool multiple times', function(done) {
|
||||
oracledb.createPool(
|
||||
dbConfig,
|
||||
function(err, pool) {
|
|
@ -0,0 +1,220 @@
|
|||
/* 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
|
||||
* 53. resultSetClose.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Negative cases against resulstSet.
|
||||
*
|
||||
* 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 assist = require('./dataTypeAssist.js');
|
||||
|
||||
describe('53. resultSetClose.js', function() {
|
||||
|
||||
var connection = null;
|
||||
var resultSet = null;
|
||||
var tableName = "nodb_number";
|
||||
var numbers = assist.data.numbers;
|
||||
|
||||
before(function(done) {
|
||||
async.series([
|
||||
function getConn(cb) {
|
||||
oracledb.getConnection(
|
||||
dbConfig,
|
||||
function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
assist.setUp(connection, tableName, numbers, cb);
|
||||
},
|
||||
function getResultSet(cb) {
|
||||
connection.execute(
|
||||
"SELECT * FROM " + tableName + " ORDER BY num",
|
||||
[],
|
||||
{ resultSet: true, outFormat: oracledb.OBJECT },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
resultSet = result.resultSet;
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function verifyMetaData(cb) {
|
||||
should.exist(resultSet.metaData);
|
||||
var t = resultSet.metaData;
|
||||
t.should.eql( [ { name: 'NUM' }, { name: 'CONTENT' } ] );
|
||||
cb();
|
||||
},
|
||||
function closeRS(cb) {
|
||||
resultSet.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
}); // before
|
||||
|
||||
after(function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"DROP TABLE " + tableName + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.release(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
}); // after
|
||||
|
||||
it('53.1 can not get metaData property', function() {
|
||||
should.throws(
|
||||
function() {
|
||||
var mdata;
|
||||
mdata = resultSet.metaData;
|
||||
should.not.exist(mdata);
|
||||
},
|
||||
/NJS-018: invalid ResultSet/
|
||||
);
|
||||
}); // 53.1
|
||||
|
||||
it('53.2 can not call close() again', function(done) {
|
||||
resultSet.close(function(err) {
|
||||
should.exist(err);
|
||||
should.strictEqual(
|
||||
err.message,
|
||||
'NJS-018: invalid ResultSet'
|
||||
);
|
||||
done();
|
||||
});
|
||||
}); // 53.2
|
||||
|
||||
it('53.3 can not call getRow()', function(done) {
|
||||
resultSet.getRow(function(err, row) {
|
||||
should.exist(err);
|
||||
should.not.exist(row);
|
||||
should.strictEqual(
|
||||
err.message,
|
||||
'NJS-018: invalid ResultSet'
|
||||
);
|
||||
done();
|
||||
});
|
||||
}); // 53.3
|
||||
|
||||
it('53.4 can not call getRows()', function(done) {
|
||||
var numRows = 3;
|
||||
resultSet.getRows(numRows, function(err, rows) {
|
||||
should.exist(err);
|
||||
should.not.exist(rows);
|
||||
should.strictEqual(
|
||||
err.message,
|
||||
'NJS-018: invalid ResultSet'
|
||||
);
|
||||
done();
|
||||
});
|
||||
}); // 53.4
|
||||
|
||||
it('53.5 can not call toQueryStream()', function() {
|
||||
should.throws(
|
||||
function() {
|
||||
var qstream;
|
||||
qstream = resultSet.toQueryStream();
|
||||
should.not.exist(qstream);
|
||||
},
|
||||
/NJS-041: cannot convert ResultSet to QueryStream after invoking methods/
|
||||
);
|
||||
}); // 53.5
|
||||
|
||||
it('53.6 can call getRow() again in the callback of getRow()', function(done) {
|
||||
|
||||
var rs2 = null;
|
||||
var tab = "nodb_float";
|
||||
|
||||
async.series([
|
||||
function(cb) {
|
||||
assist.setUp(connection, tab, numbers, cb);
|
||||
},
|
||||
function getResultSet(cb) {
|
||||
connection.execute(
|
||||
"SELECT * FROM " + tab + " ORDER BY num",
|
||||
[],
|
||||
{ resultSet: true, outFormat: oracledb.OBJECT },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
rs2 = result.resultSet;
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function test(cb) {
|
||||
rs2.getRow(function(err, row) {
|
||||
should.not.exist(err);
|
||||
should.exist(row);
|
||||
|
||||
rs2.getRow(function(err, row2) {
|
||||
should.not.exist(err);
|
||||
should.exist(row2);
|
||||
cb();
|
||||
});
|
||||
});
|
||||
},
|
||||
function closeRS(cb) {
|
||||
rs2.close(function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function dropTable(callback) {
|
||||
connection.execute(
|
||||
"DROP TABLE " + tab + " PURGE",
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
}
|
||||
], done);
|
||||
}); // 53.6
|
||||
|
||||
});
|
|
@ -37,6 +37,7 @@ var oracledb = require('oracledb');
|
|||
var should = require('should');
|
||||
var async = require('async');
|
||||
var dbConfig = require('./dbconfig.js');
|
||||
var sql = require('./sql.js');
|
||||
|
||||
describe('107. rowidDMLBindAsString.js', function() {
|
||||
var connection = null;
|
||||
|
@ -44,21 +45,21 @@ describe('107. rowidDMLBindAsString.js', function() {
|
|||
var insertID = 1;
|
||||
|
||||
var proc_create_table = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\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" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " PURGE' ); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE ( ' \n" +
|
||||
" CREATE TABLE " + tableName + " ( \n" +
|
||||
" ID NUMBER, \n" +
|
||||
" content ROWID \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
" CREATE TABLE " + tableName + " ( \n" +
|
||||
" ID NUMBER, \n" +
|
||||
" content ROWID \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
var drop_table = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
|
@ -72,13 +73,7 @@ describe('107. rowidDMLBindAsString.js', function() {
|
|||
});
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
proc_create_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
sql.executeSql(connection, proc_create_table, {}, {}, cb);
|
||||
}
|
||||
], done);
|
||||
});
|
||||
|
@ -86,13 +81,7 @@ describe('107. rowidDMLBindAsString.js', function() {
|
|||
after('release connection', function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
drop_table,
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
sql.executeSql(connection, drop_table, {}, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.release( function(err) {
|
||||
|
@ -389,6 +378,13 @@ describe('107. rowidDMLBindAsString.js', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('107.4 WHERE', function() {
|
||||
it('107.4.1 can bind in WHERE clause', function(done) {
|
||||
this.timeout(10000);
|
||||
where_select(done);
|
||||
});
|
||||
});
|
||||
|
||||
var dmlInsert = function(bindVar, expected, callback) {
|
||||
var sql_insert = "insert into " + tableName + "(id, content) values (:i, CHARTOROWID(:c))";
|
||||
var sql_select = "select * from " + tableName + " where id = :i";
|
||||
|
@ -569,4 +565,49 @@ describe('107. rowidDMLBindAsString.js', function() {
|
|||
], callback);
|
||||
};
|
||||
|
||||
var where_select = function(callback) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"insert into " + tableName + " T (ID) values (" + insertID + ")",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"UPDATE " + tableName + " T SET content = T.ROWID where ID = " + insertID,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"select content from " + tableName + " where ID = " + insertID,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.rows[0][0];
|
||||
connection.execute(
|
||||
"select * from " + tableName + " where ROWID = CHARTOROWID(:c)",
|
||||
{ c: { val: resultVal, dir : oracledb.BIND_IN, type : oracledb.STRING } },
|
||||
function(err_1, result_1) {
|
||||
should.not.exist(err_1);
|
||||
var resultVal_1 = result_1.rows[0][0];
|
||||
var resultVal_2 = result_1.rows[0][1];
|
||||
should.strictEqual(resultVal_1, insertID);
|
||||
should.strictEqual(resultVal_2, resultVal);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
});
|
||||
|
|
|
@ -39,7 +39,7 @@ var async = require('async');
|
|||
var dbConfig = require('./dbconfig.js');
|
||||
var sql = require('./sql.js');
|
||||
|
||||
describe.skip('109. rowidFunctionBindAsString_bind.js', function() {
|
||||
describe('109. rowidFunctionBindAsString_bind.js', function() {
|
||||
var connection = null;
|
||||
var tableName = "nodb_rowid_plsql_in";
|
||||
var insertID = 1;
|
||||
|
@ -97,13 +97,13 @@ describe.skip('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
done();
|
||||
});
|
||||
|
||||
describe('109.1 FUNCTION BIND_OUT as rowid', function() {
|
||||
var fun_create = "CREATE OR REPLACE FUNCTION nodb_rowid_bind (id IN NUMBER, content IN ROWID) RETURN ROWID\n" +
|
||||
describe('109.1 FUNCTION BIND_IN/OUT as rowid', function() {
|
||||
var fun_create = "CREATE OR REPLACE FUNCTION nodb_rowid_bind (ID_in IN NUMBER, content_in IN ROWID) RETURN ROWID\n" +
|
||||
"IS \n" +
|
||||
" tmp rowid; \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " (id, content) values (id, CHARTOROWID(content)); \n" +
|
||||
" select content into tmp from " + tableName + " where id = id; \n" +
|
||||
" insert into " + tableName + " (id, content) values (ID_in, CHARTOROWID(content_in)); \n" +
|
||||
" select content into tmp from " + tableName + " where id = ID_in; \n" +
|
||||
" return tmp; \n" +
|
||||
"END; ";
|
||||
var fun_execute = "BEGIN :o := nodb_rowid_bind (:i, :c); END;";
|
||||
|
@ -167,7 +167,7 @@ describe.skip('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
sql.executeSqlWithErr(connection, fun_create, bindVar, {}, function(err) {
|
||||
sql.executeSqlWithErr(connection, fun_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
done();
|
||||
});
|
||||
|
@ -175,22 +175,22 @@ describe.skip('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
|
||||
it('109.1.9 works with default bind type/dir - extended rowid', function(done) {
|
||||
var content = "AAAB1+AADAAAAwPAAA";
|
||||
funBindOut_default(fun_create, content, content, done);
|
||||
funBindOut_default(fun_execute, content, content, done);
|
||||
});
|
||||
|
||||
it('109.1.10 works with default bind type/dir - null value', function(done) {
|
||||
var content = null;
|
||||
funBindOut_default(fun_create, content, content, done);
|
||||
funBindOut_default(fun_execute, content, content, done);
|
||||
});
|
||||
|
||||
it('109.1.11 works with default bind type/dir - empty string', function(done) {
|
||||
var content = "";
|
||||
funBindOut_default(fun_create, content, null, done);
|
||||
funBindOut_default(fun_execute, content, null, done);
|
||||
});
|
||||
|
||||
it('109.1.12 works with default bind type/dir - undefined', function(done) {
|
||||
var content = undefined;
|
||||
funBindOut_default(fun_create, content, null, done);
|
||||
funBindOut_default(fun_execute, content, null, done);
|
||||
});
|
||||
|
||||
it('109.1.13 bind error: NJS-037', function(done) {
|
||||
|
@ -199,7 +199,7 @@ describe.skip('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
sql.executeSqlWithErr(connection, fun_create, bindVar, {}, function(err) {
|
||||
sql.executeSqlWithErr(connection, fun_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
done();
|
||||
});
|
||||
|
@ -207,21 +207,21 @@ describe.skip('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
|
||||
it('109.1.14 bind error: NJS-052', function(done) {
|
||||
var bindVar = [ { type: oracledb.STRING, dir: oracledb.BIND_OUT }, insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN } ];
|
||||
sql.executeSqlWithErr(connection, fun_create, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 2');
|
||||
sql.executeSqlWithErr(connection, fun_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 3');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('109.2 FUNCTION BIND_OUT as string', function() {
|
||||
var fun_create = "CREATE OR REPLACE FUNCTION nodb_rowid_bind (id IN NUMBER, content IN ROWID) RETURN VARCHAR2\n" +
|
||||
describe('109.2 FUNCTION BIND_IN/OUT as string', function() {
|
||||
var fun_create = "CREATE OR REPLACE FUNCTION nodb_rowid_bind (id_in IN NUMBER, content_in IN ROWID) RETURN VARCHAR2\n" +
|
||||
"IS \n" +
|
||||
" tmp rowid; \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " (id, content) values (id, CHARTOROWID(content)); \n" +
|
||||
" select content into tmp from " + tableName + " where id = id; \n" +
|
||||
" insert into " + tableName + " (id, content) values (id_in, CHARTOROWID(content_in)); \n" +
|
||||
" select content into tmp from " + tableName + " where id = id_in; \n" +
|
||||
" return tmp; \n" +
|
||||
"END; ";
|
||||
var fun_execute = "BEGIN :o := nodb_rowid_bind (:i, :c); END;";
|
||||
|
@ -257,7 +257,7 @@ describe.skip('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
sql.executeSqlWithErr(connection, fun_create, bindVar, {}, function(err) {
|
||||
sql.executeSqlWithErr(connection, fun_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
done();
|
||||
});
|
||||
|
@ -285,7 +285,7 @@ describe.skip('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
sql.executeSqlWithErr(connection, fun_create, bindVar, {}, function(err) {
|
||||
sql.executeSqlWithErr(connection, fun_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
done();
|
||||
});
|
||||
|
@ -293,22 +293,22 @@ describe.skip('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
|
||||
it('109.2.9 works with default bind type/dir - extended rowid', function(done) {
|
||||
var content = "AAAB1+AADAAAAwPAAA";
|
||||
funBindOut_default(fun_create, content, content, done);
|
||||
funBindOut_default(fun_execute, content, content, done);
|
||||
});
|
||||
|
||||
it('109.2.10 works with default bind type/dir - null value', function(done) {
|
||||
var content = null;
|
||||
funBindOut_default(fun_create, content, content, done);
|
||||
funBindOut_default(fun_execute, content, content, done);
|
||||
});
|
||||
|
||||
it('109.2.11 works with default bind type/dir - empty string', function(done) {
|
||||
var content = "";
|
||||
funBindOut_default(fun_create, content, null, done);
|
||||
funBindOut_default(fun_execute, content, null, done);
|
||||
});
|
||||
|
||||
it('109.2.12 works with default bind type/dir - undefined', function(done) {
|
||||
var content = undefined;
|
||||
funBindOut_default(fun_create, content, null, done);
|
||||
funBindOut_default(fun_execute, content, null, done);
|
||||
});
|
||||
|
||||
it('109.2.13 bind error: NJS-037', function(done) {
|
||||
|
@ -317,7 +317,7 @@ describe.skip('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
sql.executeSqlWithErr(connection, fun_create, bindVar, {}, function(err) {
|
||||
sql.executeSqlWithErr(connection, fun_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
done();
|
||||
});
|
||||
|
@ -325,8 +325,8 @@ describe.skip('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
|
||||
it('109.2.14 bind error: NJS-052', function(done) {
|
||||
var bindVar = [ { type: oracledb.STRING, dir: oracledb.BIND_OUT }, insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_IN } ];
|
||||
sql.executeSqlWithErr(connection, fun_create, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 2');
|
||||
sql.executeSqlWithErr(connection, fun_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 3');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -334,15 +334,15 @@ describe.skip('109. rowidFunctionBindAsString_bind.js', function() {
|
|||
});
|
||||
|
||||
describe('109.3 FUNCTION BIND_IN, UPDATE', function() {
|
||||
var fun_create = "CREATE OR REPLACE FUNCTION nodb_rowid_bind_1083 (id IN NUMBER, content_1 IN STRING, content_2 IN ROWID) RETURN ROWID\n" +
|
||||
"IS \n" +
|
||||
" tmp rowid; \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " (id, content) values (id, CHARTOROWID(content_1)); \n" +
|
||||
" update " + tableName + " set content = content_2 where id = id; \n" +
|
||||
" select content into tmp from " + tableName + " where id = id; \n" +
|
||||
" return tmp; \n" +
|
||||
"END; ";
|
||||
var fun_create = "CREATE OR REPLACE FUNCTION nodb_rowid_bind_1083 (id_in IN NUMBER, content_1 IN STRING, content_2 IN ROWID) RETURN ROWID\n" +
|
||||
"IS \n" +
|
||||
" tmp rowid; \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " (id, content) values (id_in, CHARTOROWID(content_1)); \n" +
|
||||
" update " + tableName + " set content = content_2 where id = id_in; \n" +
|
||||
" select content into tmp from " + tableName + " where id = id_in; \n" +
|
||||
" return tmp; \n" +
|
||||
"END; ";
|
||||
var fun_exec = "BEGIN :o := nodb_rowid_bind_1083 (:i, :c1, :c2); END;";
|
||||
var fun_drop = "DROP FUNCTION nodb_rowid_bind_1083";
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ var async = require('async');
|
|||
var dbConfig = require('./dbconfig.js');
|
||||
var sql = require('./sql.js');
|
||||
|
||||
describe.skip('112. rowidFunctionBindAsString_bindinout.js', function() {
|
||||
describe('112. rowidFunctionBindAsString_bindinout.js', function() {
|
||||
var connection = null;
|
||||
var tableName = "nodb_rowid_plsql_inout";
|
||||
var insertID = 1;
|
||||
|
@ -98,13 +98,13 @@ describe.skip('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
});
|
||||
|
||||
describe('112.1 FUNCTION BIND_INOUT as rowid', function() {
|
||||
var fun_create = "CREATE OR REPLACE FUNCTION nodb_rowid_bind_inout_1121 (id IN NUMBER, content IN OUT ROWID) RETURN ROWID\n" +
|
||||
var fun_create = "CREATE OR REPLACE FUNCTION nodb_rowid_bind_inout_1121 (id_in IN NUMBER, content_inout IN OUT ROWID) RETURN ROWID\n" +
|
||||
"IS \n" +
|
||||
" tmp rowid; \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " (id, content) values (id, CHARTOROWID(content)); \n" +
|
||||
" select content into tmp from " + tableName + " where id = id; \n" +
|
||||
" select CHARTOROWID('AAACiZAAFAAAAJEAAA') into content from dual; \n" +
|
||||
" insert into " + tableName + " (id, content) values (id_in, CHARTOROWID(content_inout)); \n" +
|
||||
" select content into tmp from " + tableName + " where id = id_in; \n" +
|
||||
" select CHARTOROWID('AAACiZAAFAAAAJEAAA') into content_inout from dual; \n" +
|
||||
" return tmp; \n" +
|
||||
"END; ";
|
||||
var fun_execute = "BEGIN :o := nodb_rowid_bind_inout_1121 (:i, :c); END;";
|
||||
|
@ -168,7 +168,7 @@ describe.skip('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
sql.executeSqlWithErr(connection, fun_create, bindVar, {}, function(err) {
|
||||
sql.executeSqlWithErr(connection, fun_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
done();
|
||||
});
|
||||
|
@ -176,40 +176,40 @@ describe.skip('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
|
||||
it('112.1.9 works with default bind type/dir - extended rowid', function(done) {
|
||||
var content = "AAAB1+AADAAAAwPAAA";
|
||||
funBindInOut_default(fun_create, content, content, done);
|
||||
funBindInOut_default(fun_execute, content, content, done);
|
||||
});
|
||||
|
||||
it('112.1.10 works with default bind type/dir - null value', function(done) {
|
||||
var content = null;
|
||||
funBindInOut_default(fun_create, content, content, done);
|
||||
funBindInOut_default(fun_execute, content, content, done);
|
||||
});
|
||||
|
||||
it('112.1.11 works with default bind type/dir - empty string', function(done) {
|
||||
var content = "";
|
||||
funBindInOut_default(fun_create, content, null, done);
|
||||
funBindInOut_default(fun_execute, content, null, done);
|
||||
});
|
||||
|
||||
it('112.1.12 works with default bind type/dir - undefined', function(done) {
|
||||
var content = undefined;
|
||||
funBindInOut_default(fun_create, content, null, done);
|
||||
funBindInOut_default(fun_execute, content, null, done);
|
||||
});
|
||||
|
||||
it('112.1.13 bind error: NJS-037', function(done) {
|
||||
var bindVar = {
|
||||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT },
|
||||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
sql.executeSqlWithErr(connection, fun_create, bindVar, {}, function(err) {
|
||||
sql.executeSqlWithErr(connection, fun_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('112.1.14 bind error: NJS-052', function(done) {
|
||||
var bindVar = [ { type: oracledb.STRING, dir: oracledb.BIND_OUT }, insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT } ];
|
||||
sql.executeSqlWithErr(connection, fun_create, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 2');
|
||||
var bindVar = [ { type: oracledb.STRING, dir: oracledb.BIND_OUT }, insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 } ];
|
||||
sql.executeSqlWithErr(connection, fun_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 3');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -217,13 +217,13 @@ describe.skip('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
});
|
||||
|
||||
describe('112.2 FUNCTION BIND_INOUT as string', function() {
|
||||
var fun_create = "CREATE OR REPLACE FUNCTION nodb_rowid_bind_inout_1121 (id IN NUMBER, content IN OUT VARCHAR2) RETURN ROWID\n" +
|
||||
var fun_create = "CREATE OR REPLACE FUNCTION nodb_rowid_bind_inout_1121 (id_in IN NUMBER, content_inout IN OUT VARCHAR2) RETURN ROWID\n" +
|
||||
"IS \n" +
|
||||
" tmp rowid; \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " (id, content) values (id, CHARTOROWID(content)); \n" +
|
||||
" select content into tmp from " + tableName + " where id = id; \n" +
|
||||
" select CHARTOROWID('AAACiZAAFAAAAJEAAA') into content from dual; \n" +
|
||||
" insert into " + tableName + " (id, content) values (id_in, CHARTOROWID(content_inout)); \n" +
|
||||
" select content into tmp from " + tableName + " where id = id_in; \n" +
|
||||
" select CHARTOROWID('AAACiZAAFAAAAJEAAA') into content_inout from dual; \n" +
|
||||
" return tmp; \n" +
|
||||
"END; ";
|
||||
var fun_execute = "BEGIN :o := nodb_rowid_bind_inout_1121 (:i, :c); END;";
|
||||
|
@ -259,7 +259,7 @@ describe.skip('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
sql.executeSqlWithErr(connection, fun_create, bindVar, {}, function(err) {
|
||||
sql.executeSqlWithErr(connection, fun_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
done();
|
||||
});
|
||||
|
@ -287,7 +287,7 @@ describe.skip('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
sql.executeSqlWithErr(connection, fun_create, bindVar, {}, function(err) {
|
||||
sql.executeSqlWithErr(connection, fun_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
done();
|
||||
});
|
||||
|
@ -295,40 +295,40 @@ describe.skip('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
|
||||
it('112.2.9 works with default bind type/dir - extended rowid', function(done) {
|
||||
var content = "AAAB1+AADAAAAwPAAA";
|
||||
funBindInOut_default(fun_create, content, content, done);
|
||||
funBindInOut_default(fun_execute, content, content, done);
|
||||
});
|
||||
|
||||
it('112.2.10 works with default bind type/dir - null value', function(done) {
|
||||
var content = null;
|
||||
funBindInOut_default(fun_create, content, content, done);
|
||||
funBindInOut_default(fun_execute, content, content, done);
|
||||
});
|
||||
|
||||
it('112.2.11 works with default bind type/dir - empty string', function(done) {
|
||||
var content = "";
|
||||
funBindInOut_default(fun_create, content, null, done);
|
||||
funBindInOut_default(fun_execute, content, null, done);
|
||||
});
|
||||
|
||||
it('112.2.12 works with default bind type/dir - undefined', function(done) {
|
||||
var content = undefined;
|
||||
funBindInOut_default(fun_create, content, null, done);
|
||||
funBindInOut_default(fun_execute, content, null, done);
|
||||
});
|
||||
|
||||
it('112.2.13 bind error: NJS-037', function(done) {
|
||||
var bindVar = {
|
||||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT },
|
||||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 },
|
||||
o: { type: oracledb.STRING, dir: oracledb.BIND_OUT }
|
||||
};
|
||||
sql.executeSqlWithErr(connection, fun_create, bindVar, {}, function(err) {
|
||||
sql.executeSqlWithErr(connection, fun_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('112.2.14 bind error: NJS-052', function(done) {
|
||||
var bindVar = [ { type: oracledb.STRING, dir: oracledb.BIND_OUT }, insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT } ];
|
||||
sql.executeSqlWithErr(connection, fun_create, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 2');
|
||||
var bindVar = [ { type: oracledb.STRING, dir: oracledb.BIND_OUT }, insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 } ];
|
||||
sql.executeSqlWithErr(connection, fun_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 3');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -336,16 +336,16 @@ describe.skip('112. rowidFunctionBindAsString_bindinout.js', function() {
|
|||
});
|
||||
|
||||
describe('112.3 FUNCTION BIND_INOUT, UPDATE', function() {
|
||||
var fun_create = "CREATE OR REPLACE FUNCTION nodb_rowid_bind_1083 (id IN NUMBER, content_1 IN OUT STRING, content_2 INOUT ROWID) RETURN rowid\n" +
|
||||
"IS \n" +
|
||||
" tmp rowid; \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " (id, content) values (id, CHARTOROWID(content_1)); \n" +
|
||||
" update " + tableName + " set content = content_2 where id = id; \n" +
|
||||
" select content into tmp from " + tableName + " where id = id; \n" +
|
||||
" select CHARTOROWID('AAACiZAAFAAAAJEAAA') into content_1 from dual; \n" +
|
||||
" return tmp; \n" +
|
||||
"END; ";
|
||||
var fun_create = "CREATE OR REPLACE FUNCTION nodb_rowid_bind_1083 (id_in IN NUMBER, content_1 IN OUT VARCHAR2, content_2 IN OUT ROWID) RETURN ROWID\n" +
|
||||
"IS \n" +
|
||||
" tmp rowid; \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " (id, content) values (id_in, CHARTOROWID(content_1)); \n" +
|
||||
" update " + tableName + " set content = content_2 where id = id_in; \n" +
|
||||
" select content into tmp from " + tableName + " where id = id_in; \n" +
|
||||
" select CHARTOROWID('AAACiZAAFAAAAJEAAA') into content_1 from dual; \n" +
|
||||
" return tmp; \n" +
|
||||
"END; ";
|
||||
var fun_execute = "BEGIN :o := nodb_rowid_bind_1083 (:i, :c1, :c2); END;";
|
||||
var fun_drop = "DROP FUNCTION nodb_rowid_bind_1083";
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ var async = require('async');
|
|||
var dbConfig = require('./dbconfig.js');
|
||||
var sql = require('./sql.js');
|
||||
|
||||
describe.skip('111. rowidProcedureBindAsString_bindinout.js', function() {
|
||||
describe('111. rowidProcedureBindAsString_bindinout.js', function() {
|
||||
var connection = null;
|
||||
var tableName = "nodb_rowid_plsql_inout";
|
||||
var insertID = 1;
|
||||
|
@ -98,11 +98,11 @@ describe.skip('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
});
|
||||
|
||||
describe('111.1 PROCEDURE BIND_INOUT as rowid', function() {
|
||||
var proc_create = "CREATE OR REPLACE PROCEDURE nodb_rowid_bind_inout (id IN NUMBER, content IN OUT ROWID)\n" +
|
||||
var proc_create = "CREATE OR REPLACE PROCEDURE nodb_rowid_bind_inout (id_in IN NUMBER, content IN OUT ROWID)\n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " (id, content) values (id, CHARTOROWID(content)); \n" +
|
||||
" select content into content from " + tableName + " where id = id; \n" +
|
||||
" insert into " + tableName + " (id, content) values (id_in, CHARTOROWID(content)); \n" +
|
||||
" select content into content from " + tableName + " where id = id_in; \n" +
|
||||
"END nodb_rowid_bind_inout; ";
|
||||
var proc_execute = "BEGIN nodb_rowid_bind_inout (:i, :c); END;";
|
||||
var proc_drop = "DROP PROCEDURE nodb_rowid_bind_inout";
|
||||
|
@ -134,7 +134,7 @@ describe.skip('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
var content = NaN;
|
||||
var bindVar = {
|
||||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT }
|
||||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 1000 }
|
||||
};
|
||||
sql.executeSqlWithErr(connection, proc_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
|
@ -161,7 +161,7 @@ describe.skip('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
var content = 0;
|
||||
var bindVar = {
|
||||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT }
|
||||
c: { val: content, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 1000 }
|
||||
};
|
||||
sql.executeSqlWithErr(connection, proc_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-011: encountered bind value and type mismatch');
|
||||
|
@ -192,7 +192,7 @@ describe.skip('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
it('111.1.13 bind error: NJS-037', function(done) {
|
||||
var bindVar = {
|
||||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT }
|
||||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 }
|
||||
};
|
||||
sql.executeSqlWithErr(connection, proc_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
|
@ -201,7 +201,7 @@ describe.skip('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
});
|
||||
|
||||
it('111.1.14 bind error: NJS-052', function(done) {
|
||||
var bindVar = [ insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT }];
|
||||
var bindVar = [ insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 }];
|
||||
sql.executeSqlWithErr(connection, proc_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 2');
|
||||
done();
|
||||
|
@ -211,11 +211,11 @@ describe.skip('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
});
|
||||
|
||||
describe('111.2 PROCEDURE BIND_INOUT as string', function() {
|
||||
var proc_create = "CREATE OR REPLACE PROCEDURE nodb_rowid_bind_inout (id IN NUMBER, content IN OUT VARCHAR2)\n" +
|
||||
var proc_create = "CREATE OR REPLACE PROCEDURE nodb_rowid_bind_inout (id_in IN NUMBER, content IN OUT VARCHAR2)\n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " (id, content) values (id, CHARTOROWID(content)); \n" +
|
||||
" select content into content from " + tableName + " where id = id; \n" +
|
||||
" insert into " + tableName + " (id, content) values (id_in, CHARTOROWID(content)); \n" +
|
||||
" select content into content from " + tableName + " where id = id_in; \n" +
|
||||
"END nodb_rowid_bind_inout; ";
|
||||
var proc_execute = "BEGIN nodb_rowid_bind_inout (:i, :c); END;";
|
||||
var proc_drop = "DROP PROCEDURE nodb_rowid_bind_inout";
|
||||
|
@ -305,7 +305,7 @@ describe.skip('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
it('111.2.13 bind error: NJS-037', function(done) {
|
||||
var bindVar = {
|
||||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT }
|
||||
c: { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 }
|
||||
};
|
||||
sql.executeSqlWithErr(connection, proc_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-037: invalid data type at array index 0 for bind ":c"');
|
||||
|
@ -314,7 +314,7 @@ describe.skip('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
});
|
||||
|
||||
it('111.2.14 bind error: NJS-052', function(done) {
|
||||
var bindVar = [ insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT }];
|
||||
var bindVar = [ insertID, { val: [0], type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxArraySize: 1000 }];
|
||||
sql.executeSqlWithErr(connection, proc_execute, bindVar, {}, function(err) {
|
||||
should.strictEqual(err.message, 'NJS-052: invalid data type at array index 0 for bind position 2');
|
||||
done();
|
||||
|
@ -324,12 +324,12 @@ describe.skip('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
});
|
||||
|
||||
describe('111.3 PROCEDURE BIND_IN, UPDATE', function() {
|
||||
var proc_create = "CREATE OR REPLACE PROCEDURE nodb_rowid_bind_1083 (id IN NUMBER, content_1 IN OUT STRING, content_2 IN OUT ROWID)\n" +
|
||||
var proc_create = "CREATE OR REPLACE PROCEDURE nodb_rowid_bind_1083 (id_in IN NUMBER, content_1 IN OUT ROWID, content_2 IN OUT ROWID)\n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " (id, content) values (id, CHARTOROWID(content_1)); \n" +
|
||||
" update " + tableName + " set content = content_2 where id = id; \n" +
|
||||
" select content into content_1 from " + tableName + " where id = id; \n" +
|
||||
" insert into " + tableName + " (id, content) values (id_in, CHARTOROWID(content_1)); \n" +
|
||||
" update " + tableName + " set content = content_2 where id = id_in; \n" +
|
||||
" select content into content_1 from " + tableName + " where id = id_in; \n" +
|
||||
"END nodb_rowid_bind_1083; ";
|
||||
var proc_execute = "BEGIN nodb_rowid_bind_1083 (:i, :c1, :c2); END;";
|
||||
var proc_drop = "DROP PROCEDURE nodb_rowid_bind_1083";
|
||||
|
@ -363,7 +363,7 @@ describe.skip('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
it('111.3.4 works with default bind type/dir', function(done) {
|
||||
var content_1 = "AAAB1+AADAAAAwPAAA";
|
||||
var content_2 = "0";
|
||||
procedureBindInout_update(proc_execute, content_1, content_2, "00000000.0000.0000", done);
|
||||
procedureBindInout_update(proc_execute, content_1, content_2, "0", done);
|
||||
});
|
||||
|
||||
it('111.3.5 works with default bind type/dir - null value', function(done) {
|
||||
|
@ -389,7 +389,7 @@ describe.skip('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
var procedureBindInout = function(proc_execute, content_in, expected, callback) {
|
||||
var bindVar_out = {
|
||||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c: { val: content_in, type: oracledb.STRING, dir: oracledb.BIND_INOUT }
|
||||
c: { val: content_in, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 1000 }
|
||||
};
|
||||
connection.execute(
|
||||
proc_execute,
|
||||
|
@ -406,7 +406,7 @@ describe.skip('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
var procedureBindInout_default = function(proc_execute, content_in, expected, callback) {
|
||||
var bindVar_out = {
|
||||
i: insertID,
|
||||
c: { val: content_in, type: oracledb.STRING, dir: oracledb.BIND_INOUT }
|
||||
c: { val: content_in, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 1000 }
|
||||
};
|
||||
connection.execute(
|
||||
proc_execute,
|
||||
|
@ -423,8 +423,8 @@ describe.skip('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
var procedureBindInout_update = function(proc_execute, content_1, content_2, expected, callback) {
|
||||
var bindVar_in = {
|
||||
i: { val: insertID, type: oracledb.NUMBER, dir: oracledb.BIND_IN },
|
||||
c1: { val: content_1, type: oracledb.STRING, dir: oracledb.BIND_INOUT },
|
||||
c2: { val: content_2, type: oracledb.STRING, dir: oracledb.BIND_INOUT }
|
||||
c1: { val: content_1, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 1000 },
|
||||
c2: { val: content_2, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 1000 }
|
||||
};
|
||||
connection.execute(
|
||||
proc_execute,
|
||||
|
@ -441,8 +441,8 @@ describe.skip('111. rowidProcedureBindAsString_bindinout.js', function() {
|
|||
var procedureBindInout_update_default = function(proc_execute, content_1, content_2, expected, callback) {
|
||||
var bindVar_in = {
|
||||
i: insertID,
|
||||
c1: { val: content_1, type: oracledb.STRING, dir: oracledb.BIND_INOUT },
|
||||
c2: { val: content_2, type: oracledb.STRING, dir: oracledb.BIND_INOUT }
|
||||
c1: { val: content_1, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 1000 },
|
||||
c2: { val: content_2, type: oracledb.STRING, dir: oracledb.BIND_INOUT, maxSize: 1000 }
|
||||
};
|
||||
connection.execute(
|
||||
proc_execute,
|
||||
|
|
|
@ -39,7 +39,7 @@ var async = require('async');
|
|||
var dbConfig = require('./dbconfig.js');
|
||||
var sql = require('./sql.js');
|
||||
|
||||
describe.skip('110. rowidProcedureBindAsString_bindout.js', function() {
|
||||
describe('110. rowidProcedureBindAsString_bindout.js', function() {
|
||||
var connection = null;
|
||||
var tableName = "nodb_rowid_plsql_out";
|
||||
var insertID = 1;
|
||||
|
@ -98,11 +98,11 @@ describe.skip('110. rowidProcedureBindAsString_bindout.js', function() {
|
|||
});
|
||||
|
||||
describe('110.1 PROCEDURE BIND_OUT as rowid', function() {
|
||||
var proc_create = "CREATE OR REPLACE PROCEDURE nodb_rowid_bind_out (id IN NUMBER, content_in IN ROWID, content_out OUT ROWID)\n" +
|
||||
var proc_create = "CREATE OR REPLACE PROCEDURE nodb_rowid_bind_out (id_in IN NUMBER, content_in IN ROWID, content_out OUT ROWID)\n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " (id, content) values (id, CHARTOROWID(content_in)); \n" +
|
||||
" select content into content_out from " + tableName + " where id = id; \n" +
|
||||
" insert into " + tableName + " (id, content) values (id_in, CHARTOROWID(content_in)); \n" +
|
||||
" select content into content_out from " + tableName + " where id = id_in; \n" +
|
||||
"END nodb_rowid_bind_out; ";
|
||||
var proc_execute = "BEGIN nodb_rowid_bind_out (:i, :c, :o); END;";
|
||||
var proc_drop = "DROP PROCEDURE nodb_rowid_bind_out";
|
||||
|
@ -214,11 +214,11 @@ describe.skip('110. rowidProcedureBindAsString_bindout.js', function() {
|
|||
});
|
||||
|
||||
describe('110.2 PROCEDURE BIND_OUT as string', function() {
|
||||
var proc_create = "CREATE OR REPLACE PROCEDURE nodb_rowid_bind_out (id IN NUMBER, content_in IN ROWID, content_out OUT VARCHAR2)\n" +
|
||||
var proc_create = "CREATE OR REPLACE PROCEDURE nodb_rowid_bind_out (id_in IN NUMBER, content_in IN ROWID, content_out OUT VARCHAR2)\n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " (id, content) values (id, CHARTOROWID(content_in)); \n" +
|
||||
" select content into content_out from " + tableName + " where id = id; \n" +
|
||||
" insert into " + tableName + " (id, content) values (id_in, CHARTOROWID(content_in)); \n" +
|
||||
" select content into content_out from " + tableName + " where id = id_in; \n" +
|
||||
"END nodb_rowid_bind_out; ";
|
||||
var proc_execute = "BEGIN nodb_rowid_bind_out (:i, :c, :o); END;";
|
||||
var proc_drop = "DROP PROCEDURE nodb_rowid_bind_out";
|
||||
|
@ -330,12 +330,12 @@ describe.skip('110. rowidProcedureBindAsString_bindout.js', function() {
|
|||
});
|
||||
|
||||
describe('110.3 PROCEDURE BIND_IN, UPDATE', function() {
|
||||
var proc_create = "CREATE OR REPLACE PROCEDURE nodb_rowid_bind_1083 (id IN NUMBER, content_1 IN STRING, content_2 IN ROWID, content_out OUT ROWID)\n" +
|
||||
var proc_create = "CREATE OR REPLACE PROCEDURE nodb_rowid_bind_1083 (id_in IN NUMBER, content_1 IN STRING, content_2 IN ROWID, content_out OUT ROWID)\n" +
|
||||
"AS \n" +
|
||||
"BEGIN \n" +
|
||||
" insert into " + tableName + " (id, content) values (id, CHARTOROWID(content_1)); \n" +
|
||||
" update " + tableName + " set content = content_2 where id = id; \n" +
|
||||
" select content into content_out from " + tableName + " where id = id; \n" +
|
||||
" insert into " + tableName + " (id, content) values (id_in, CHARTOROWID(content_1)); \n" +
|
||||
" update " + tableName + " set content = content_2 where id = id_in; \n" +
|
||||
" select content into content_out from " + tableName + " where id = id_in; \n" +
|
||||
"END nodb_rowid_bind_1083; ";
|
||||
var proc_execute = "BEGIN nodb_rowid_bind_1083 (:i, :c1, :c2, :o); END;";
|
||||
var proc_drop = "DROP PROCEDURE nodb_rowid_bind_1083";
|
||||
|
|
33
test/sql.js
33
test/sql.js
|
@ -124,6 +124,20 @@ sql.executeSql = function(connection, sql, bindVar, option, callback) {
|
|||
}
|
||||
);
|
||||
};
|
||||
|
||||
sql.executeInsert = function(connection, sql, bindVar, option, callback) {
|
||||
connection.execute(
|
||||
sql,
|
||||
bindVar,
|
||||
option,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
callback();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
sql.executeSqlWithErr = function(connection, sql, bindVar, option, callback) {
|
||||
connection.execute(
|
||||
sql,
|
||||
|
@ -135,6 +149,25 @@ sql.executeSqlWithErr = function(connection, sql, bindVar, option, callback) {
|
|||
}
|
||||
);
|
||||
};
|
||||
|
||||
sql.createRowid = function(connection, rowid_type, object_number, relative_fno, block_number, row_number, callback) {
|
||||
// Parameter Description
|
||||
// rowid_type Type (restricted or extended), set the rowid_type parameter to 0 for a restricted ROWID. Set it to 1 to create an extended ROWID.
|
||||
// If you specify rowid_type as 0, then the required object_number parameter is ignored, and ROWID_CREATE returns a restricted ROWID.
|
||||
// object_number The data object number for the ROWID. For a restricted ROWID, use the ROWID_OBJECT_UNDEFINED constant.
|
||||
// relative_fno The relative file number for the ROWID.
|
||||
// block_number The block number for the ROWID.
|
||||
// row_number The row number for the ROWID.
|
||||
var myRowid = "";
|
||||
connection.execute(
|
||||
"select DBMS_ROWID.ROWID_CREATE(" + rowid_type + ", " + object_number + ", " + relative_fno + ", " + block_number + ", " + row_number + ") create_rowid from dual",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
myRowid = result.rows[0][0];
|
||||
callback(myRowid);
|
||||
}
|
||||
);
|
||||
};
|
||||
var appendSql = function(sql, col_name, col_type, isLast) {
|
||||
if(isLast === true) {
|
||||
sql = sql + " " + col_name + " " + col_type + " \n";
|
||||
|
|
|
@ -0,0 +1,614 @@
|
|||
/* 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
|
||||
* 114. urowidDMLBindAsString.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Testing urowid binding as String with DML.
|
||||
* The Universal ROWID (UROWID) is a datatype that can store both logical and physical rowids of Oracle tables. Logical rowids are primary key-based logical identifiers for the rows of Index-Organized Tables (IOTs).
|
||||
* To use columns of the UROWID datatype, the value of the COMPATIBLE initialization parameter must be set to 8.1 or higher.
|
||||
*
|
||||
* 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 sql = require('./sql.js');
|
||||
|
||||
describe('114. urowidDMLBindAsString.js', function() {
|
||||
var connection = null;
|
||||
var tableName = "nodb_bind_urowid";
|
||||
var insertID = 1;
|
||||
|
||||
var proc_create_table = "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 UROWID(4000) \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
var drop_table = "DROP TABLE " + tableName + " PURGE";
|
||||
|
||||
before('get connection and create table', function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
oracledb.getConnection(dbConfig, function(err, conn) {
|
||||
should.not.exist(err);
|
||||
connection = conn;
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function(cb) {
|
||||
sql.executeSql(connection, proc_create_table, {}, {}, cb);
|
||||
}
|
||||
], done);
|
||||
});
|
||||
|
||||
after('release connection', function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
sql.executeSql(connection, drop_table, {}, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.release( function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
});
|
||||
|
||||
beforeEach(function(done) {
|
||||
insertID++;
|
||||
done();
|
||||
});
|
||||
|
||||
describe('114.1 INSERT & SELECT', function() {
|
||||
|
||||
it('114.1.1 works with null', function(done) {
|
||||
var content = null;
|
||||
var bindVar = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
dmlInsert(bindVar, content, done);
|
||||
});
|
||||
|
||||
it('114.1.2 works with empty string', function(done) {
|
||||
var content = "";
|
||||
var expected = null;
|
||||
var bindVar = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
dmlInsert(bindVar, expected, done);
|
||||
});
|
||||
|
||||
it('114.1.3 works with extended rowid', function(done) {
|
||||
var content = "AAABoqAADAAAAwPAAA";
|
||||
var bindVar = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
dmlInsert(bindVar, content, done);
|
||||
});
|
||||
|
||||
it('114.1.4 works with restricted rowid', function(done) {
|
||||
var content = "00000DD5.0000.0001";
|
||||
var bindVar = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
dmlInsert(bindVar, content, done);
|
||||
});
|
||||
|
||||
it('114.1.5 throws error with number 0', function(done) {
|
||||
var content = 0;
|
||||
var sql_insert = "insert into " + tableName + "(id, content) values (:i, CHARTOROWID(:c))";
|
||||
var bindVar = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
|
||||
connection.execute(
|
||||
sql_insert,
|
||||
bindVar,
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.equal("NJS-011: encountered bind value and type mismatch");
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('114.1.6 works with string 0', function(done) {
|
||||
var content = "0";
|
||||
var expected = "00000000.0000.0000";
|
||||
var bindVar = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
dmlInsert(bindVar, expected, done);
|
||||
});
|
||||
|
||||
it('114.1.7 works with substr', function(done) {
|
||||
var content = "AAAA8+AALAAAAQ/AAA";
|
||||
dmlInsert_substr(content, done);
|
||||
});
|
||||
|
||||
it('114.1.8 bind null with default type/dir - named bind', function(done) {
|
||||
var content = null;
|
||||
var bindVar_1 = {
|
||||
i: insertID,
|
||||
c: content
|
||||
};
|
||||
dmlInsert(bindVar_1, content, done);
|
||||
});
|
||||
|
||||
it('114.1.9 bind null with default type/dir - positional bind', function(done) {
|
||||
var content = null;
|
||||
var bindVar_1 = [ insertID, content ];
|
||||
dmlInsert(bindVar_1, content, done);
|
||||
});
|
||||
|
||||
it('114.1.10 bind extented rowid with default type/dir - named bind', function(done) {
|
||||
var content = "AAAA8+AALAAAAQ/AAA";
|
||||
var bindVar_1 = {
|
||||
i: insertID,
|
||||
c: content
|
||||
};
|
||||
dmlInsert(bindVar_1, content, done);
|
||||
});
|
||||
|
||||
it('114.1.11 bind extented rowid with default type/dir - positional bind', function(done) {
|
||||
var content = "AAAA8+AALAAAAQ/AAA";
|
||||
var bindVar_1 = [ insertID, content ];
|
||||
dmlInsert(bindVar_1, content, done);
|
||||
});
|
||||
|
||||
it('114.1.12 works with undefined', function(done) {
|
||||
var content = undefined;
|
||||
var bindVar = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
dmlInsert(bindVar, null, done);
|
||||
});
|
||||
|
||||
it('114.1.13 bind undefined with default type/dir - named bind', function(done) {
|
||||
var content = undefined;
|
||||
var bindVar_1 = {
|
||||
i: insertID,
|
||||
c: content
|
||||
};
|
||||
dmlInsert(bindVar_1, null, done);
|
||||
});
|
||||
|
||||
it('114.1.14 bind undefined with default type/dir - positional bind', function(done) {
|
||||
var content = undefined;
|
||||
var bindVar_1 = [ insertID, content ];
|
||||
dmlInsert(bindVar_1, null, done);
|
||||
});
|
||||
|
||||
it('114.1.15 works with NaN', function(done) {
|
||||
var content = NaN;
|
||||
var sql_insert = "insert into " + tableName + "(id, content) values (:i, CHARTOROWID(:c))";
|
||||
var bindVar = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
|
||||
connection.execute(
|
||||
sql_insert,
|
||||
bindVar,
|
||||
function(err) {
|
||||
should.exist(err);
|
||||
(err.message).should.equal("NJS-011: encountered bind value and type mismatch");
|
||||
done();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('114.2 UPDATE', function() {
|
||||
|
||||
it('114.2.1 UPDATE null column', function(done) {
|
||||
var content_insert = null;
|
||||
var content_update = "AAABiqAADAAAAwPAAA";
|
||||
dmlUpdate(content_insert, content_update, content_update, done);
|
||||
});
|
||||
|
||||
it('114.2.1 UPDATE extented rowid with restricted rowid', function(done) {
|
||||
var content_insert = "AAABioAADAAAAwPAAA";
|
||||
var content_update = "00000DD5.0010.0001";
|
||||
dmlUpdate(content_insert, content_update, content_update, done);
|
||||
});
|
||||
|
||||
it('114.2.3 UPDATE restricted rowid with null', function(done) {
|
||||
var content_insert = "00000DD5.0010.0002";
|
||||
var content_update = null;
|
||||
dmlUpdate(content_insert, content_update, content_update, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('114.3 RETURNING INTO', function() {
|
||||
it('114.3.1 INSERT null', function(done) {
|
||||
var content = null;
|
||||
var bindVar = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING },
|
||||
o: { dir : oracledb.BIND_OUT, type : oracledb.STRING }
|
||||
};
|
||||
insert_returning(bindVar, content, done);
|
||||
});
|
||||
|
||||
it('114.3.2 INSERT extented rowid', function(done) {
|
||||
var content = "AAAA++AALAAAAQ/AAA";
|
||||
var bindVar = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING },
|
||||
o: { dir : oracledb.BIND_OUT, type : oracledb.STRING }
|
||||
};
|
||||
insert_returning(bindVar, content, done);
|
||||
});
|
||||
|
||||
it('114.3.3 INSERT restricted rowid', function(done) {
|
||||
var content = "00000000.0100.0100";
|
||||
var bindVar = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING },
|
||||
o: { dir : oracledb.BIND_OUT, type : oracledb.STRING }
|
||||
};
|
||||
insert_returning(bindVar, content, done);
|
||||
});
|
||||
|
||||
it('114.3.7 UPDATE null with extented rowid', function(done) {
|
||||
var content_insert = null;
|
||||
var content_update = "AAABiqAADAAAAwPAAA";
|
||||
var bindVar_update = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : content_update, dir : oracledb.BIND_IN, type : oracledb.STRING },
|
||||
o: { dir : oracledb.BIND_OUT, type : oracledb.STRING }
|
||||
};
|
||||
update_returning(content_insert, bindVar_update, content_update, done);
|
||||
});
|
||||
|
||||
it('114.3.8 UPDATE extented rowid with null', function(done) {
|
||||
var content_insert = "AAABiqAADAAAAwPAAA";
|
||||
var content_update = null;
|
||||
var bindVar_update = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : content_update, dir : oracledb.BIND_IN, type : oracledb.STRING },
|
||||
o: { dir : oracledb.BIND_OUT, type : oracledb.STRING }
|
||||
};
|
||||
update_returning(content_insert, bindVar_update, content_update, done);
|
||||
});
|
||||
|
||||
it('114.3.9 UPDATE restricted rowid with empty string', function(done) {
|
||||
var content_insert = "00000000.0100.0100";
|
||||
var content_update = "";
|
||||
var bindVar_update = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : content_update, dir : oracledb.BIND_IN, type : oracledb.STRING },
|
||||
o: { dir : oracledb.BIND_OUT, type : oracledb.STRING }
|
||||
};
|
||||
update_returning(content_insert, bindVar_update, null, done);
|
||||
});
|
||||
|
||||
it('114.3.10 UPDATE restricted rowid with extented rowid', function(done) {
|
||||
var content_insert = "00000000.0100.0100";
|
||||
var content_update = "AAABiqAADAAAAwPAAA";
|
||||
var bindVar_update = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : content_update, dir : oracledb.BIND_IN, type : oracledb.STRING },
|
||||
o: { dir : oracledb.BIND_OUT, type : oracledb.STRING }
|
||||
};
|
||||
update_returning(content_insert, bindVar_update, content_update, done);
|
||||
});
|
||||
|
||||
it('114.3.11 INSERT with default type/dir - named bind', function(done) {
|
||||
var content = "00000000.0100.0100";
|
||||
var bindVar = {
|
||||
i: insertID,
|
||||
c: content,
|
||||
o: { dir : oracledb.BIND_OUT, type : oracledb.STRING }
|
||||
};
|
||||
insert_returning(bindVar, content, done);
|
||||
});
|
||||
|
||||
it('114.3.12 INSERT with default type/dir - positional bind', function(done) {
|
||||
var content = "00000000.0100.0100";
|
||||
var bindVar = [ insertID, content, { dir : oracledb.BIND_OUT, type : oracledb.STRING } ];
|
||||
insert_returning(bindVar, content, done);
|
||||
});
|
||||
|
||||
it('114.3.13 UPDATE with default type/dir - named bind', function(done) {
|
||||
var content_insert = "00000000.0100.0100";
|
||||
var content_update = "AAABiqAADAAAAwPAAA";
|
||||
var bindVar_update = {
|
||||
i: insertID,
|
||||
c: content_update,
|
||||
o: { dir : oracledb.BIND_OUT, type : oracledb.STRING }
|
||||
};
|
||||
update_returning(content_insert, bindVar_update, content_update, done);
|
||||
});
|
||||
|
||||
it('114.3.14 UPDATE with default type/dir - positional bind', function(done) {
|
||||
var content_insert = "00000000.0100.0100";
|
||||
var content_update = "AAABiqAADAAAAwPAAA";
|
||||
var bindVar_update = [ content_update, insertID, { dir : oracledb.BIND_OUT, type : oracledb.STRING } ];
|
||||
update_returning(content_insert, bindVar_update, content_update, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('107.4 WHERE', function() {
|
||||
it('107.4.1 can bind in WHERE clause', function(done) {
|
||||
this.timeout(10000);
|
||||
where_select(done);
|
||||
});
|
||||
});
|
||||
|
||||
var dmlInsert = function(bindVar, expected, callback) {
|
||||
var sql_insert = "insert into " + tableName + "(id, content) values (:i, CHARTOROWID(:c))";
|
||||
var sql_select = "select * from " + tableName + " where id = :i";
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sql_insert,
|
||||
bindVar,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sql_select,
|
||||
{ i: insertID },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.rows[0][1];
|
||||
should.strictEqual(resultVal, expected);
|
||||
// should.strictEqual(typeof resultVal, "string");
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
var dmlInsert_substr = function(content, callback) {
|
||||
var id = insertID++;
|
||||
var sql_insert = "insert into " + tableName + "(id, content) values (" + id + ", CHARTOROWID(:c))";
|
||||
var sql_select = "select content, SUBSTR(content,1,6) , SUBSTR(content,7,3), SUBSTR(content,10,6), SUBSTR(content,16,3) from " + tableName + " where id = " + id;
|
||||
var bindVar = { c: { val : content, dir : oracledb.BIND_IN, type : oracledb.STRING }};
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sql_insert,
|
||||
bindVar,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sql_select,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal_rowid = result.rows[0][0];
|
||||
var resultVal_object = result.rows[0][1];
|
||||
var resultVal_file = result.rows[0][2];
|
||||
var resultVal_block = result.rows[0][3];
|
||||
var resultVal_row = result.rows[0][4];
|
||||
should.strictEqual(typeof resultVal_rowid, "string");
|
||||
should.strictEqual(typeof resultVal_block, "string");
|
||||
should.strictEqual(typeof resultVal_row, "string");
|
||||
should.strictEqual(typeof resultVal_file, "string");
|
||||
should.strictEqual(typeof resultVal_object, "string");
|
||||
should.strictEqual(resultVal_rowid, content);
|
||||
should.strictEqual(resultVal_object, content.substring(0, 6));
|
||||
should.strictEqual(resultVal_file, content.substring(6, 9));
|
||||
should.strictEqual(resultVal_block, content.substring(9, 15));
|
||||
should.strictEqual(resultVal_row, content.substring(15, 18));
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
var dmlUpdate = function(content_insert, content_update, expected, callback) {
|
||||
var sql_insert = "insert into " + tableName + "(id, content) values (:i, CHARTOROWID(:c))";
|
||||
var sql_update = "update " + tableName + " set content = :c where id = :i";
|
||||
var sql_select = "select * from " + tableName + " where id = :i";
|
||||
var bindVar_insert = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : content_insert, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
var bindVar_update = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : content_update, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sql_insert,
|
||||
bindVar_insert,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sql_update,
|
||||
bindVar_update,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sql_select,
|
||||
{ i: insertID },
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.rows[0][1];
|
||||
should.strictEqual(resultVal, expected);
|
||||
// should.strictEqual(typeof resultVal, "string");
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
var insert_returning = function(bindVar, expected, callback) {
|
||||
var sql_returning = "insert into " + tableName + "(id, content) values (:i, CHARTOROWID(:c)) returning content into :o";
|
||||
connection.execute(
|
||||
sql_returning,
|
||||
bindVar,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal;
|
||||
if (typeof (result.outBinds.o) === 'undefined') resultVal = result.outBinds[0][0];
|
||||
else resultVal = result.outBinds.o[0];
|
||||
should.strictEqual(resultVal, expected);
|
||||
// should.strictEqual(typeof resultVal, "string");
|
||||
callback();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
var update_returning = function(content_insert, bindVar_update, expected, callback) {
|
||||
var sql_insert = "insert into " + tableName + "(id, content) values (:i, CHARTOROWID(:c))";
|
||||
var sql_update = "update " + tableName + " set content = :c where id = :i returning content into :o";
|
||||
var bindVar_insert = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : content_insert, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sql_insert,
|
||||
bindVar_insert,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
sql_update,
|
||||
bindVar_update,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal;
|
||||
if (typeof (result.outBinds.o) === 'undefined') resultVal = result.outBinds[0][0];
|
||||
else resultVal = result.outBinds.o[0];
|
||||
should.strictEqual(resultVal, expected);
|
||||
// should.strictEqual(typeof resultVal, "string");
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
var where_select = function(callback) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"insert into " + tableName + " T (ID) values (" + insertID + ")",
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
cb();
|
||||
}
|
||||
)
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"UPDATE " + tableName + " T SET content = T.ROWID where ID = " + insertID,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
cb();
|
||||
}
|
||||
)
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"select content from " + tableName + " where ID = " + insertID,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.rows[0][0];
|
||||
connection.execute(
|
||||
"select * from " + tableName + " where ROWID = CHARTOROWID(:c)",
|
||||
{ c: { val: resultVal, dir : oracledb.BIND_IN, type : oracledb.STRING } },
|
||||
function(err_1, result_1) {
|
||||
should.not.exist(err_1);
|
||||
var resultVal_1 = result_1.rows[0][0];
|
||||
var resultVal_2 = result_1.rows[0][1];
|
||||
should.strictEqual(resultVal_1, insertID);
|
||||
should.strictEqual(resultVal_2, resultVal);
|
||||
cb();
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
});
|
|
@ -0,0 +1,651 @@
|
|||
/* 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
|
||||
* 115. urowidDMLBindAsString_indexed.js
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Testing urowid binding as String with DML.
|
||||
* The Universal ROWID (UROWID) is a datatype that can store both logical and physical rowids of Oracle tables. Logical rowids are primary key-based logical identifiers for the rows of Index-Organized Tables (IOTs).
|
||||
* To use columns of the UROWID datatype, the value of the COMPATIBLE initialization parameter must be set to 8.1 or higher.
|
||||
*
|
||||
* 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 sql = require('./sql.js');
|
||||
var random = require('./random.js');
|
||||
|
||||
describe('115. urowidDMLBindAsString_indexed.js', function() {
|
||||
var connection = null;
|
||||
var tableName_indexed = "nodb_urowid_indexed";
|
||||
var tableName_normal = "nodb_urowid_normal";
|
||||
var insertID = 1;
|
||||
|
||||
var table_indexed = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName_indexed + " PURGE' ); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE ( ' \n" +
|
||||
" CREATE TABLE " + tableName_indexed + " ( \n" +
|
||||
" c1 NUMBER, \n" +
|
||||
" c2 VARCHAR2(3000), \n" +
|
||||
" primary key(c1, c2) \n" +
|
||||
" ) organization index \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
|
||||
var table_normal = "BEGIN \n" +
|
||||
" DECLARE \n" +
|
||||
" e_table_missing EXCEPTION; \n" +
|
||||
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942);\n" +
|
||||
" BEGIN \n" +
|
||||
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName_normal + " PURGE' ); \n" +
|
||||
" EXCEPTION \n" +
|
||||
" WHEN e_table_missing \n" +
|
||||
" THEN NULL; \n" +
|
||||
" END; \n" +
|
||||
" EXECUTE IMMEDIATE ( ' \n" +
|
||||
" CREATE TABLE " + tableName_normal + " ( \n" +
|
||||
" ID NUMBER, \n" +
|
||||
" content UROWID(4000) \n" +
|
||||
" ) \n" +
|
||||
" '); \n" +
|
||||
"END; ";
|
||||
|
||||
var drop_table_indexed = "DROP TABLE " + tableName_indexed + " PURGE";
|
||||
var drop_table_normal = "DROP TABLE " + tableName_normal + " PURGE";
|
||||
|
||||
before('get connection and create table', 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_indexed, {}, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
sql.executeSql(connection, table_normal, {}, {}, cb);
|
||||
}
|
||||
], done);
|
||||
});
|
||||
|
||||
after('release connection', function(done) {
|
||||
async.series([
|
||||
function(cb) {
|
||||
sql.executeSql(connection, drop_table_indexed, {}, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
sql.executeSql(connection, drop_table_normal, {}, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.release( function(err) {
|
||||
should.not.exist(err);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
});
|
||||
|
||||
beforeEach(function(done) {
|
||||
insertID++;
|
||||
done();
|
||||
});
|
||||
|
||||
describe('115.1 INSERT & SELECT', function() {
|
||||
|
||||
it('115.1.1 works with urowid length > 200', function(done) {
|
||||
var strLength = 200;
|
||||
var rowidLenExpected = 200;
|
||||
testBigUROWID(strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
it('115.1.2 works with urowid length > 500', function(done) {
|
||||
var strLength = 600;
|
||||
var rowidLenExpected = 500;
|
||||
testBigUROWID(strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
it.skip('115.1.3 get error when urowid length > 4000', function(done) {
|
||||
var strLength = 3000;
|
||||
var rowidLenExpected = 4000;
|
||||
testBigUROWID(strLength, rowidLenExpected, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('115.2 UPDATE', function() {
|
||||
|
||||
it('115.2.1 update null with urowid length > 200', function(done) {
|
||||
var strLength = 200;
|
||||
var rowidLenExpected = 200;
|
||||
testBigUROWID_update(null, strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
it('115.2.2 update enpty string with urowid length > 500', function(done) {
|
||||
var strLength = 600;
|
||||
var rowidLenExpected = 500;
|
||||
testBigUROWID_update("", strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
it('115.2.3 update with urowid length > 500', function(done) {
|
||||
var strLength = 600;
|
||||
var rowidLenExpected = 500;
|
||||
var rowid_org = "00000DD5.0000.0001";
|
||||
testBigUROWID_update(rowid_org, strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
it.skip('115.2.4 update with urowid length > 4000', function(done) {
|
||||
var strLength = 3000;
|
||||
var rowidLenExpected = 4000;
|
||||
var rowid_org = "00000DD5.0000.0001";
|
||||
testBigUROWID_update(rowid_org, strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('115.3 RETURNING INTO', function() {
|
||||
|
||||
it('115.3.1 urowid length > 200', function(done) {
|
||||
var strLength = 200;
|
||||
var rowidLenExpected = 200;
|
||||
testBigUROWID_returning(strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
it('115.3.2 urowid length > 500', function(done) {
|
||||
var strLength = 600;
|
||||
var rowidLenExpected = 500;
|
||||
testBigUROWID_returning(strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
it.skip('115.3.3 urowid length > 4000', function(done) {
|
||||
var strLength = 3000;
|
||||
var rowidLenExpected = 4000;
|
||||
testBigUROWID_returning(strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('115.4 WHERE', function() {
|
||||
|
||||
it('115.4.1 urowid length > 200', function(done) {
|
||||
var strLength = 200;
|
||||
var rowidLenExpected = 200;
|
||||
testBigUROWID_where(strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
it('115.4.2 urowid length > 500', function(done) {
|
||||
var strLength = 600;
|
||||
var rowidLenExpected = 500;
|
||||
testBigUROWID_where(strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
it.skip('115.4.3 urowid length > 4000', function(done) {
|
||||
var strLength = 3000;
|
||||
var rowidLenExpected = 4000;
|
||||
testBigUROWID_where(strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('115.5 queryStream() and oracledb.maxRows = actual rows', function() {
|
||||
|
||||
it('115.5.1 urowid length > 200', function(done) {
|
||||
var strLength = 200;
|
||||
var rowidLenExpected = 200;
|
||||
var maxRows = 2;
|
||||
testBigUROWID_stream(maxRows, strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
it('115.5.2 urowid length > 500', function(done) {
|
||||
var strLength = 600;
|
||||
var rowidLenExpected = 500;
|
||||
var maxRows = 2;
|
||||
testBigUROWID_stream(maxRows, strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
it.skip('115.5.3 urowid length > 4000', function(done) {
|
||||
var strLength = 3000;
|
||||
var rowidLenExpected = 4000;
|
||||
var maxRows = 2;
|
||||
testBigUROWID_stream(maxRows, strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('115.6 queryStream() and oracledb.maxRows > actual rows', function() {
|
||||
|
||||
it('115.6.1 urowid length > 200', function(done) {
|
||||
var strLength = 200;
|
||||
var rowidLenExpected = 200;
|
||||
var maxRows = 5;
|
||||
testBigUROWID_stream(maxRows, strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
it('115.6.2 urowid length > 500', function(done) {
|
||||
var strLength = 600;
|
||||
var rowidLenExpected = 500;
|
||||
var maxRows = 100;
|
||||
testBigUROWID_stream(maxRows, strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
it.skip('115.6.3 urowid length > 4000', function(done) {
|
||||
var strLength = 3000;
|
||||
var rowidLenExpected = 4000;
|
||||
var maxRows = 10;
|
||||
testBigUROWID_stream(maxRows, strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('115.7 queryStream() and oracledb.maxRows < actual rows', function() {
|
||||
|
||||
it('115.7.1 urowid length > 200', function(done) {
|
||||
var strLength = 200;
|
||||
var rowidLenExpected = 200;
|
||||
var maxRows = 1;
|
||||
testBigUROWID_stream(maxRows, strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
it('115.7.2 urowid length > 500', function(done) {
|
||||
var strLength = 600;
|
||||
var rowidLenExpected = 500;
|
||||
var maxRows = 1;
|
||||
testBigUROWID_stream(maxRows, strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
it.skip('115.7.3 urowid length > 4000', function(done) {
|
||||
var strLength = 3000;
|
||||
var rowidLenExpected = 4000;
|
||||
var maxRows = 1;
|
||||
testBigUROWID_stream(maxRows, strLength, rowidLenExpected, done);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
var testBigUROWID = function(strLength, rowidLenExpected, callback) {
|
||||
var str = random.getRandomLengthString(strLength);
|
||||
var urowid, urowidLen;
|
||||
async.series([
|
||||
function(cb) {
|
||||
var sql_insert = "insert into " + tableName_indexed + " values (" + insertID + ", '" + str + "')";
|
||||
sql.executeInsert(connection, sql_insert, {}, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"select ROWID from " + tableName_indexed + " where c1 = " + insertID,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
urowid = result.rows[0][0];
|
||||
urowidLen = urowid.length;
|
||||
urowidLen.should.be.above(rowidLenExpected);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
var bindVar = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : urowid, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
connection.execute(
|
||||
"insert into " + tableName_normal + " (ID, content) values (:i, :c)",
|
||||
bindVar,
|
||||
function(err, result) {
|
||||
if(urowidLen > 4000) {
|
||||
should.exist(err);
|
||||
should.strictEqual(err.message, "ORA-01704: string literal too long");
|
||||
} else {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
}
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"select * from " + tableName_normal + " where ID = " + insertID,
|
||||
function(err, result) {
|
||||
if(urowidLen < 4000) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.rows[0][1];
|
||||
should.strictEqual(resultVal, urowid);
|
||||
}
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
insertID++;
|
||||
connection.execute(
|
||||
"insert into " + tableName_normal + " (ID, content) values (" + insertID + ", '" + urowid + "')",
|
||||
function(err, result) {
|
||||
if(urowidLen > 4000) {
|
||||
should.exist(err);
|
||||
should.strictEqual(err.message, "ORA-01704: string literal too long");
|
||||
} else {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
}
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"select * from " + tableName_normal + " where ID = " + insertID,
|
||||
function(err, result) {
|
||||
if(urowidLen < 4000) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.rows[0][1];
|
||||
should.strictEqual(resultVal, urowid);
|
||||
}
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
var testBigUROWID_update = function(rowid_org, strLength, rowidLenExpected, callback) {
|
||||
var str = random.getRandomLengthString(strLength);
|
||||
var urowid, urowidLen;
|
||||
var id_1 = insertID++;
|
||||
var id_2 = insertID++;
|
||||
async.series([
|
||||
function(cb) {
|
||||
var sql_insert = "insert into " + tableName_normal + " (ID, content) values (:i, :c)";
|
||||
var bindVar = {
|
||||
i: { val : id_1, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : rowid_org, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
sql.executeInsert(connection, sql_insert, bindVar, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
var sql_insert = "insert into " + tableName_normal + " (ID, content) values (:i, :c)";
|
||||
var bindVar = {
|
||||
i: { val : id_2, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : rowid_org, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
sql.executeInsert(connection, sql_insert, bindVar, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
var sql_insert = "insert into " + tableName_indexed + " values (" + insertID + ", '" + str + "')";
|
||||
sql.executeInsert(connection, sql_insert, {}, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"select ROWID from " + tableName_indexed + " where c1 = " + insertID,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
urowid = result.rows[0][0];
|
||||
urowidLen = urowid.length;
|
||||
urowidLen.should.be.above(rowidLenExpected);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
var bindVar = {
|
||||
c: { val : urowid, dir : oracledb.BIND_IN, type : oracledb.STRING },
|
||||
i: { val : id_1, dir : oracledb.BIND_IN, type : oracledb.NUMBER }
|
||||
};
|
||||
connection.execute(
|
||||
"update " + tableName_normal + " set content = :c where ID = :i",
|
||||
bindVar,
|
||||
function(err, result) {
|
||||
if(urowidLen > 4000) {
|
||||
should.exist(err);
|
||||
should.strictEqual(err.message, "ORA-01704: string literal too long");
|
||||
} else {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
}
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"select * from " + tableName_normal + " where ID = " + id_1,
|
||||
function(err, result) {
|
||||
if(urowidLen < 4000) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.rows[0][1];
|
||||
should.strictEqual(resultVal, urowid);
|
||||
}
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"update " + tableName_normal + " set content = '" + urowid + "' where ID = " + id_2,
|
||||
function(err, result) {
|
||||
if(urowidLen > 4000) {
|
||||
should.exist(err);
|
||||
should.strictEqual(err.message, "ORA-01704: string literal too long");
|
||||
} else {
|
||||
should.not.exist(err);
|
||||
(result.rowsAffected).should.be.exactly(1);
|
||||
}
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"select * from " + tableName_normal + " where ID = " + id_2,
|
||||
function(err, result) {
|
||||
if(urowidLen < 4000) {
|
||||
should.not.exist(err);
|
||||
var resultVal = result.rows[0][1];
|
||||
should.strictEqual(resultVal, urowid);
|
||||
}
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
var testBigUROWID_returning = function(strLength, rowidLenExpected, callback) {
|
||||
var str = random.getRandomLengthString(strLength);
|
||||
var urowid, urowidLen;
|
||||
async.series([
|
||||
function(cb) {
|
||||
var sql_insert = "insert into " + tableName_indexed + " values (" + insertID + ", '" + str + "')";
|
||||
sql.executeInsert(connection, sql_insert, {}, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"select ROWID from " + tableName_indexed + " where c1 = " + insertID,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
urowid = result.rows[0][0];
|
||||
urowidLen = urowid.length;
|
||||
urowidLen.should.be.above(rowidLenExpected);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
var bindVar = {
|
||||
i: { val : insertID, dir : oracledb.BIND_IN, type : oracledb.NUMBER },
|
||||
c: { val : urowid, dir : oracledb.BIND_IN, type : oracledb.STRING },
|
||||
o: { dir : oracledb.BIND_OUT, type : oracledb.STRING, maxSize: urowidLen }
|
||||
};
|
||||
connection.execute(
|
||||
"insert into " + tableName_normal + " (ID, content) values (:i, :c) returning content into :o",
|
||||
bindVar,
|
||||
function(err, result) {
|
||||
if(urowidLen > 4000) {
|
||||
should.exist(err);
|
||||
should.strictEqual(err.message, "ORA-01704: string literal too long");
|
||||
} else {
|
||||
should.not.exist(err);
|
||||
var resultVal;
|
||||
if (typeof (result.outBinds.o) === 'undefined') resultVal = result.outBinds[0][0];
|
||||
else resultVal = result.outBinds.o[0];
|
||||
should.strictEqual(resultVal, urowid);
|
||||
}
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
var testBigUROWID_where = function(strLength, rowidLenExpected, callback) {
|
||||
var str = random.getRandomLengthString(strLength);
|
||||
var urowid, urowidLen;
|
||||
async.series([
|
||||
function(cb) {
|
||||
var sql_insert = "insert into " + tableName_indexed + " values (" + insertID + ", '" + str + "')";
|
||||
sql.executeInsert(connection, sql_insert, {}, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"select ROWID from " + tableName_indexed + " where c1 = " + insertID,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
urowid = result.rows[0][0];
|
||||
urowidLen = urowid.length;
|
||||
urowidLen.should.be.above(rowidLenExpected);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
var bindVar = {
|
||||
c: { val : urowid, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
connection.execute(
|
||||
"select * from " + tableName_indexed + " where ROWID = :c",
|
||||
bindVar,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
should.strictEqual(result.rows[0][0], insertID);
|
||||
should.strictEqual(result.rows[0][1], str);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
var testBigUROWID_stream = function(maxRows, strLength, rowidLenExpected, callback) {
|
||||
var str = random.getRandomLengthString(strLength);
|
||||
var urowid_1, urowidLen_1, urowid_2, urowidLen_2;
|
||||
var id_1 = insertID++;
|
||||
var id_2 = insertID++;
|
||||
var maxRowsBak = oracledb.maxRows;
|
||||
oracledb.maxRows = maxRows;
|
||||
async.series([
|
||||
function(cb) {
|
||||
var sql_insert = "insert into " + tableName_indexed + " values (" + id_1 + ", '" + str + "')";
|
||||
sql.executeInsert(connection, sql_insert, {}, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
var sql_insert = "insert into " + tableName_indexed + " values (" + id_2 + ", '" + str + "')";
|
||||
sql.executeInsert(connection, sql_insert, {}, {}, cb);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"select ROWID from " + tableName_indexed + " where c1 = " + id_1,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
urowid_1 = result.rows[0][0];
|
||||
urowidLen_1 = urowid_1.length;
|
||||
urowidLen_1.should.be.above(rowidLenExpected);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
connection.execute(
|
||||
"select ROWID from " + tableName_indexed + " where c1 = " + id_2,
|
||||
function(err, result) {
|
||||
should.not.exist(err);
|
||||
urowid_2 = result.rows[0][0];
|
||||
urowidLen_2 = urowid_2.length;
|
||||
urowidLen_2.should.be.above(rowidLenExpected);
|
||||
cb();
|
||||
}
|
||||
);
|
||||
},
|
||||
function(cb) {
|
||||
var counter = 0;
|
||||
var sql_select = "select c1, c2, ROWID from " + tableName_indexed + " where ROWID = :c1 or ROWID = :c2";
|
||||
var bindVar = {
|
||||
c1: { val : urowid_1, dir : oracledb.BIND_IN, type : oracledb.STRING },
|
||||
c2: { val : urowid_2, dir : oracledb.BIND_IN, type : oracledb.STRING }
|
||||
};
|
||||
var stream = connection.queryStream(sql_select, bindVar);
|
||||
stream.on('error', function (error) {
|
||||
should.not.exist(error);
|
||||
});
|
||||
|
||||
stream.on('data', function(data) {
|
||||
should.exist(data);
|
||||
counter++;
|
||||
if(counter == 1) {
|
||||
(data).should.deepEqual([ id_1, str, urowid_1 ]);
|
||||
} else {
|
||||
(data).should.deepEqual([ id_2, str, urowid_2 ]);
|
||||
}
|
||||
});
|
||||
|
||||
stream.on('metadata', function (metadata) {
|
||||
should.exist(metadata);
|
||||
(metadata).should.deepEqual([ { name: 'C1' }, { name: 'C2' }, { name: 'ROWID' } ]);
|
||||
});
|
||||
|
||||
stream.on('end', function (err) {
|
||||
should.not.exist(err);
|
||||
should.equal(counter, 2);
|
||||
oracledb.maxRows = maxRowsBak;
|
||||
cb();
|
||||
});
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
});
|
Loading…
Reference in New Issue