Skip to content

Commit d9e9590

Browse files
committed
LOB test updates
1 parent 0546aa7 commit d9e9590

File tree

3 files changed

+142
-3
lines changed

3 files changed

+142
-3
lines changed

test/clobPlsqlString.js

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */
2+
3+
/******************************************************************************
4+
*
5+
* You may not use the identified files except in compliance with the Apache
6+
* License, Version 2.0 (the "License.")
7+
*
8+
* You may obtain a copy of the License at
9+
* http://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
*
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* The node-oracledb test suite uses 'mocha', 'should' and 'async'.
19+
* See LICENSE.md for relevant licenses.
20+
*
21+
* NAME
22+
* 60. clobPlsqlString.js
23+
*
24+
* DESCRIPTION
25+
*
26+
* PL/SQL OUT CLOB parameters can also be bound as `STRING`
27+
* The returned length is limited to the maximum size of maxSize option.
28+
*
29+
* NUMBERING RULE
30+
* Test numbers follow this numbering rule:
31+
* 1 - 20 are reserved for basic functional tests
32+
* 21 - 50 are reserved for data type supporting tests
33+
* 51 onwards are for other tests
34+
*
35+
*****************************************************************************/
36+
"use strict";
37+
38+
var oracledb = require('oracledb');
39+
var async = require('async');
40+
var should = require('should');
41+
var dbConfig = require('./dbConfig.js');
42+
var assist = require('./dataTypeAssist.js');
43+
44+
describe('60. clobPlsqlString.js', function() {
45+
46+
if(dbConfig.externalAuth){
47+
var credential = { externalAuth: true, connectString: dbConfig.connectString };
48+
} else {
49+
var credential = dbConfig;
50+
}
51+
52+
var connection = null;
53+
var tableName = "oracledb_myclobs";
54+
55+
before('get one connection, prepare table', function(done) {
56+
async.series([
57+
function(callback) {
58+
oracledb.getConnection(
59+
credential,
60+
function(err, conn) {
61+
should.not.exist(err);
62+
connection = conn;
63+
callback();
64+
}
65+
);
66+
},
67+
function(callback) {
68+
assist.createTable(connection, tableName, callback);
69+
},
70+
function(callback) {
71+
connection.execute(
72+
"INSERT INTO oracledb_myclobs (num, content) VALUES (1, 'abcdefghijklmnopqrstuvwxyz')",
73+
function(err) {
74+
should.not.exist(err);
75+
callback();
76+
}
77+
);
78+
}
79+
], done);
80+
81+
})
82+
83+
after('release connection', function(done) {
84+
async.series([
85+
function(callback) {
86+
connection.execute(
87+
"DROP TABLE oracledb_myclobs",
88+
function(err) {
89+
should.not.exist(err);
90+
callback();
91+
}
92+
);
93+
},
94+
function(callback) {
95+
connection.release( function(err) {
96+
should.not.exist(err);
97+
callback();
98+
});
99+
}
100+
], done);
101+
102+
})
103+
104+
it('60.1 PL/SQL OUT CLOB parameters can also be bound as STRING', function(done) {
105+
connection.execute(
106+
"BEGIN SELECT content INTO :cbv FROM oracledb_myclobs WHERE num = :id; END;",
107+
{
108+
id: 1,
109+
cbv: { type: oracledb.STRING, dir: oracledb.BIND_OUT}
110+
},
111+
function(err, result) {
112+
should.not.exist(err);
113+
(result.outBinds.cbv).should.be.a.String;
114+
(result.outBinds.cbv).should.eql('abcdefghijklmnopqrstuvwxyz');
115+
done();
116+
}
117+
);
118+
})
119+
120+
it('60.2 The returned length is limited to the maximum size', function(done) {
121+
connection.execute(
122+
"BEGIN SELECT content INTO :cbv FROM oracledb_myclobs WHERE num = :id; END;",
123+
{
124+
id: 1,
125+
cbv: { type: oracledb.STRING, dir: oracledb.BIND_OUT, maxSize: 5 }
126+
},
127+
function(err, result) {
128+
should.exist(err);
129+
(err.message).should.startWith('ORA-06502'); // PL/SQL: numeric or value error
130+
done();
131+
}
132+
);
133+
})
134+
})

test/list.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,10 @@
477477
58.3.5 module (write-only)
478478
58.3.6 oracleServerVersion (read-only)
479479

480-
59. lob.js
480+
59. lobResultSet.js
481481
59.1 CLOB data
482482
59.1.1 reads clob data one by one row from result set
483+
484+
60. clobPlsqlString.js
485+
60.1 PL/SQL OUT CLOB parameters can also be bound as STRING
486+
60.2 The returned length is limited to the maximum size

test/lob.js renamed to test/lobResultSet.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
* See LICENSE.md for relevant licenses.
2020
*
2121
* NAME
22-
* 59. lob.js
22+
* 59. lobResultSet.js
2323
*
2424
* DESCRIPTION
2525
*
26+
* Inspired by https://github.com/oracle/node-oracledb/issues/210
2627
* Testing Lob data and result set.
2728
* Create a table contains Lob data. Read the Lob to result set. Get
2829
* rows one by one. Read the lob data on each row.
@@ -46,7 +47,7 @@ var assist = require('./dataTypeAssist.js');
4647

4748
var inFileName = './test/clobexample.txt';
4849

49-
describe('59. lob.js', function() {
50+
describe('59. lobResultSet.js', function() {
5051

5152
if(dbConfig.externalAuth){
5253
var credential = { externalAuth: true, connectString: dbConfig.connectString };

0 commit comments

Comments
 (0)