Skip to content

Commit 4df45d7

Browse files
committed
Add PL/SQL Index-by array test
1 parent bb55e55 commit 4df45d7

File tree

1 file changed

+75
-6
lines changed

1 file changed

+75
-6
lines changed

test/plsqlBinding1.js

Lines changed: 75 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('43. plsqlBinding1.js', function() {
6464
});
6565
})
6666

67-
it('43.1.1 binding PL/SQL indexed table IN', function(done) {
67+
it('43.1.1 binding PL/SQL indexed table IN by name', function(done) {
6868
async.series([
6969
function(callback) {
7070
var proc = "CREATE OR REPLACE PACKAGE\n" +
@@ -138,7 +138,77 @@ describe('43. plsqlBinding1.js', function() {
138138
], done);
139139
});
140140

141-
it('43.1.2 binding PL/SQL indexed table IN OUT', function(done) {
141+
it('43.1.2 binding PL/SQL indexed table IN by position', function(done) {
142+
async.series([
143+
function(callback) {
144+
var proc = "CREATE OR REPLACE PACKAGE\n" +
145+
"oracledb_testpack\n" +
146+
"IS\n" +
147+
" TYPE stringsType IS TABLE OF VARCHAR2(30) INDEX BY BINARY_INTEGER;\n" +
148+
" TYPE numbersType IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;\n" +
149+
" PROCEDURE test(s IN stringsType, n IN numbersType);\n" +
150+
"END;";
151+
connection.should.be.ok;
152+
connection.execute(
153+
proc,
154+
function(err) {
155+
should.not.exist(err);
156+
callback();
157+
}
158+
);
159+
},
160+
function(callback) {
161+
var proc = "CREATE OR REPLACE PACKAGE BODY\n" +
162+
"oracledb_testpack\n" +
163+
"IS\n" +
164+
" PROCEDURE test(s IN stringsType, n IN numbersType)\n" +
165+
" IS\n" +
166+
" BEGIN\n" +
167+
" IF (s(1) IS NULL OR s(1) <> 'John') THEN\n" +
168+
" raise_application_error(-20000, 'Invalid s(1): \"' || s(1) || '\"');\n" +
169+
" END IF;\n" +
170+
" IF (s(2) IS NULL OR s(2) <> 'Doe') THEN\n" +
171+
" raise_application_error(-20000, 'Invalid s(2): \"' || s(2) || '\"');\n" +
172+
" END IF;\n" +
173+
" END;\n" +
174+
"END;";
175+
connection.should.be.ok;
176+
connection.execute(
177+
proc,
178+
function(err) {
179+
should.not.exist(err);
180+
callback();
181+
}
182+
);
183+
},
184+
function(callback) {
185+
var bindvars = [
186+
{type: oracledb.STRING, dir: oracledb.BIND_IN, val: ['John', 'Doe']},
187+
{type: oracledb.NUMBER, dir: oracledb.BIND_IN, val: [8, 11]}
188+
];
189+
connection.execute(
190+
"BEGIN oracledb_testpack.test(:1, :2); END;",
191+
bindvars,
192+
function(err, result) {
193+
should.not.exist(err);
194+
// console.log(result);
195+
callback();
196+
}
197+
);
198+
},
199+
function(callback) {
200+
connection.execute(
201+
"DROP PACKAGE oracledb_testpack",
202+
function(err) {
203+
should.not.exist(err);
204+
callback();
205+
}
206+
);
207+
}
208+
], done);
209+
});
210+
211+
it('43.1.3 binding PL/SQL indexed table IN OUT', function(done) {
142212
async.series([
143213
function(callback) {
144214
var proc = "CREATE OR REPLACE PACKAGE\n" +
@@ -211,7 +281,7 @@ describe('43. plsqlBinding1.js', function() {
211281
], done);
212282
});
213283

214-
it('43.1.3 binding PL/SQL indexed table OUT', function(done) {
284+
it('43.1.4 binding PL/SQL indexed table OUT', function(done) {
215285
async.series([
216286
function(callback) {
217287
var proc = "CREATE OR REPLACE PACKAGE\n" +
@@ -469,9 +539,8 @@ describe('43. plsqlBinding1.js', function() {
469539
"BEGIN oracledb_testpack.test4(:1); END;",
470540
bindvars,
471541
function(err, result) {
472-
should.exist(err);
473-
(err.message).should.startWith('ORA-06550'); // this causes a PL/SQL syntax error
474-
should.not.exist(result);
542+
should.not.exist(err);
543+
should.exist(result);
475544
done();
476545
}
477546
);

0 commit comments

Comments
 (0)