node-oracledb/test/resultSet2.js

579 lines
17 KiB
JavaScript
Raw Normal View History

2022-04-19 08:06:36 +08:00
/* Copyright (c) 2015, 2022, Oracle and/or its affiliates. */
2015-07-20 15:56:29 +08:00
/******************************************************************************
*
* This software is dual-licensed to you under the Universal Permissive License
* (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
* 2.0 as shown at https://www.apache.org/licenses/LICENSE-2.0. You may choose
* either license.
2015-07-20 15:56:29 +08:00
*
* If you elect to accept the software under the Apache License, Version 2.0,
* the following applies:
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
2015-07-20 15:56:29 +08:00
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
2015-07-20 15:56:29 +08:00
*
* 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.
2015-07-20 15:56:29 +08:00
* See the License for the specific language governing permissions and
* limitations under the License.
*
* NAME
* 55. resultSet2.js
*
* DESCRIPTION
* Testing driver resultSet feature.
*
*****************************************************************************/
2017-06-17 07:40:09 +08:00
"use strict";
2023-02-21 10:49:28 +08:00
const oracledb = require('oracledb');
const assert = require('assert');
const dbConfig = require('./dbconfig.js');
2017-06-17 07:40:09 +08:00
describe('55. resultSet2.js', function() {
2023-02-21 10:49:28 +08:00
let connection = null;
const tableName = "nodb_rs2_emp";
const rowsAmount = 300;
before('get one connection', async function() {
connection = await oracledb.getConnection(dbConfig);
2017-06-17 07:40:09 +08:00
});
2016-03-24 14:09:53 +08:00
2023-02-21 10:49:28 +08:00
after('release connection', async function() {
await connection.close();
2017-06-17 07:40:09 +08:00
});
2016-03-24 14:09:53 +08:00
2017-06-17 07:40:09 +08:00
describe('55.1 query a RDBMS function', function() {
2016-03-24 14:09:53 +08:00
2023-02-21 10:49:28 +08:00
it('55.1.1 LPAD function', async function() {
const result = await connection.execute(
2015-07-20 15:56:29 +08:00
"select lpad('a',100,'x') from dual",
[],
2023-02-21 10:49:28 +08:00
{ resultSet: true });
const row = await result.resultSet.getRow();
assert.strictEqual(row[0].length, 100);
await result.resultSet.close();
2017-06-17 07:40:09 +08:00
});
2023-02-21 10:49:28 +08:00
2017-06-17 07:40:09 +08:00
}); // 55.1
describe('55.2 binding variables', function() {
2023-02-21 10:49:28 +08:00
before(async function() {
await setUp(connection, tableName);
2017-06-17 07:40:09 +08:00
});
2023-02-21 10:49:28 +08:00
after(async function() {
await clearUp(connection, tableName);
2017-06-17 07:40:09 +08:00
});
2023-02-21 10:49:28 +08:00
it('55.2.1 query with one binding variable', async function() {
let rowCount = 0;
const result = await connection.execute(
2017-06-14 09:54:15 +08:00
"SELECT * FROM nodb_rs2_emp WHERE employees_id > :1",
2015-07-20 15:56:29 +08:00
[200],
2023-02-21 10:49:28 +08:00
{ resultSet: true });
while (true) { // eslint-disable-line
const row = await result.resultSet.getRow();
if (!row)
break;
rowCount++;
2017-06-17 07:40:09 +08:00
}
2023-02-21 10:49:28 +08:00
await result.resultSet.close();
assert.strictEqual(rowCount, 100);
2017-06-17 07:40:09 +08:00
});
2017-06-14 09:54:15 +08:00
2017-06-17 07:40:09 +08:00
});
2017-06-14 09:54:15 +08:00
2017-06-17 07:40:09 +08:00
describe('55.3 alternating getRow() & getRows() function', function() {
2023-02-21 10:49:28 +08:00
before(async function() {
await setUp(connection, tableName);
2017-06-17 07:40:09 +08:00
});
2017-06-14 09:54:15 +08:00
2023-02-21 10:49:28 +08:00
after(async function() {
await clearUp(connection, tableName);
2017-06-17 07:40:09 +08:00
});
2017-06-14 09:54:15 +08:00
2023-02-21 10:49:28 +08:00
it('55.3.1 result set', async function() {
const numRows = 4;
let accessCount = 0;
let getRow = true;
const result = await connection.execute(
2017-06-14 09:54:15 +08:00
"SELECT * FROM nodb_rs2_emp WHERE employees_id > :1",
2015-07-20 15:56:29 +08:00
[200],
2023-02-21 10:49:28 +08:00
{ resultSet: true });
while (true) { // eslint-disable-line
if (getRow) {
const row = await result.resultSet.getRow();
if (!row)
break;
getRow = false;
accessCount++;
} else {
const rows = await result.resultSet.getRows(numRows);
if (rows.length === 0)
break;
getRow = true;
accessCount++;
2017-06-17 07:40:09 +08:00
}
}
2023-02-21 10:49:28 +08:00
await result.resultSet.close();
assert.strictEqual(accessCount, (100 / (numRows + 1)) * 2);
2017-06-17 07:40:09 +08:00
});
2017-06-14 09:54:15 +08:00
2023-02-21 10:49:28 +08:00
it('55.3.2 REF Cursor', async function() {
const numRows = 4;
let accessCount = 0;
let getRow = true;
2017-06-14 09:54:15 +08:00
2023-02-21 10:49:28 +08:00
const result = await connection.execute(
2017-06-14 09:54:15 +08:00
"BEGIN nodb_rs2_get_emp(:in, :out); END;",
2017-06-17 07:40:09 +08:00
{
in: 200,
out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
2023-02-21 10:49:28 +08:00
});
const rs = result.outBinds.out;
while (true) { // eslint-disable-line
if (getRow) {
const row = await rs.getRow();
if (!row)
break;
getRow = false;
accessCount++;
} else {
const rows = await rs.getRows(numRows);
if (rows.length === 0)
break;
getRow = true;
accessCount++;
2017-06-17 07:40:09 +08:00
}
}
2023-02-21 10:49:28 +08:00
await rs.close();
assert.strictEqual(accessCount, (100 / (numRows + 1)) * 2);
2017-06-17 07:40:09 +08:00
});
2023-02-21 10:49:28 +08:00
2017-06-17 07:40:09 +08:00
});
describe('55.4 automatically close result sets and LOBs when the connection is closed', function() {
2023-02-21 10:49:28 +08:00
before(async function() {
await setUp(connection, tableName);
2017-06-17 07:40:09 +08:00
});
2023-02-21 10:49:28 +08:00
after(async function() {
await clearUp(connection, tableName);
2017-06-17 07:40:09 +08:00
});
2023-02-21 10:49:28 +08:00
let testConn = null;
beforeEach(async function() {
testConn = await oracledb.getConnection(dbConfig);
2017-06-17 07:40:09 +08:00
});
2023-02-21 10:49:28 +08:00
async function fetchRowFromRS(rs) {
while (true) { // eslint-disable-line
const row = await rs.getRow();
if (!row)
break;
}
await testConn.close();
2023-02-21 11:45:10 +08:00
await assert.rejects(
2023-02-21 10:49:28 +08:00
async () => await rs.close(),
/NJS-018:/
);
2017-06-17 07:40:09 +08:00
}
2017-06-14 09:54:15 +08:00
2023-02-21 10:49:28 +08:00
it('55.4.1 resultSet gets closed automatically', async function() {
const result = await testConn.execute(
2017-06-14 09:54:15 +08:00
"SELECT * FROM nodb_rs2_emp ORDER BY employees_id",
2015-07-20 15:56:29 +08:00
[],
2023-02-21 10:49:28 +08:00
{ resultSet: true });
await fetchRowFromRS(result.resultSet);
2017-06-17 07:40:09 +08:00
});
2016-03-24 14:09:53 +08:00
2023-02-21 10:49:28 +08:00
it('55.4.2 REF Cursor gets closed automatically', async function() {
const result = await testConn.execute(
2017-06-14 09:54:15 +08:00
"BEGIN nodb_rs2_get_emp(:in, :out); END;",
2017-06-17 07:40:09 +08:00
{
in: 200,
out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
2023-02-21 10:49:28 +08:00
});
await fetchRowFromRS(result.outBinds.out);
2017-06-17 07:40:09 +08:00
});
2023-02-21 10:49:28 +08:00
2017-06-17 07:40:09 +08:00
});
describe('55.5 the content of resultSet should be consistent', function() {
2023-02-21 10:49:28 +08:00
before(async function() {
await setUp(connection, tableName);
2017-06-17 07:40:09 +08:00
});
2023-02-21 10:49:28 +08:00
after(async function() {
await clearUp(connection, tableName);
2017-06-17 07:40:09 +08:00
});
2023-02-21 10:49:28 +08:00
it('55.5.1 (1) get RS (2) modify data in that table and commit (3) check RS', async function() {
let rowsCount = 0;
const result = await connection.execute(
"SELECT * FROM nodb_rs2_emp ORDER BY employees_id",
[],
{ resultSet: true });
const rs = result.resultSet;
await connection.execute("TRUNCATE TABLE nodb_rs2_emp");
while (true) { // eslint-disable-line
const row = await rs.getRow();
if (!row)
break;
rowsCount++;
2017-06-17 07:40:09 +08:00
}
2023-02-21 10:49:28 +08:00
assert.strictEqual(rowsCount, rowsAmount);
await rs.close();
2017-06-17 07:40:09 +08:00
});
2017-06-14 09:54:15 +08:00
2017-06-17 07:40:09 +08:00
});
2017-06-14 09:54:15 +08:00
2017-06-17 07:40:09 +08:00
describe('55.6 access resultSet simultaneously', function() {
2023-02-21 10:49:28 +08:00
before(async function() {
await setUp(connection, tableName);
2017-06-17 07:40:09 +08:00
});
2017-06-14 09:54:15 +08:00
2023-02-21 10:49:28 +08:00
after(async function() {
await clearUp(connection, tableName);
});
2023-02-21 10:49:28 +08:00
it('55.6.1 concurrent operations on resultSet are not allowed (using getRows())', async function() {
const result = await connection.execute(
"SELECT * FROM nodb_rs2_emp ORDER BY employees_id",
[],
{ resultSet: true });
const rs = result.resultSet;
const promises = [
rs.getRows(),
rs.getRows()
];
const values = await Promise.allSettled(promises);
assert.strictEqual(values[1].status, 'rejected');
assert.match(values[1].reason.message, /NJS-017:/);
});
it('55.6.2 concurrent operation on REF Cursor are not allowed', async function() {
const result = await connection.execute(
"BEGIN nodb_rs2_get_emp(:in, :out); END;",
{
in: 0,
out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
});
const rs = result.outBinds.out;
const promises = [
rs.getRows(),
rs.getRows()
];
const values = await Promise.allSettled(promises);
assert.strictEqual(values[1].status, 'rejected');
assert.match(values[1].reason.message, /NJS-017:/);
});
it('55.6.3 concurrent operations on resultSet are not allowed (using getRow())', async function() {
const result = await connection.execute(
"SELECT * FROM nodb_rs2_emp ORDER BY employees_id",
[],
{ resultSet: true });
const rs = result.resultSet;
const promises = [
rs.getRow(),
rs.getRow()
];
const values = await Promise.allSettled(promises);
assert.strictEqual(values[1].status, 'rejected');
assert.match(values[1].reason.message, /NJS-017:/);
});
it('55.6.4 concurrently closing resultSet not allowed', async function() {
const result = await connection.execute(
"SELECT * FROM nodb_rs2_emp ORDER BY employees_id",
[],
{ resultSet: true });
const rs = result.resultSet;
const promises = [
rs.close(),
rs.close()
];
const values = await Promise.allSettled(promises);
assert.strictEqual(values[1].status, 'rejected');
assert.match(values[1].reason.message, /NJS-017:/);
});
2017-06-17 07:40:09 +08:00
});
2017-06-14 09:54:15 +08:00
2017-06-17 07:40:09 +08:00
describe('55.7 getting multiple resultSets', function() {
2023-02-21 10:49:28 +08:00
before(async function() {
await setUp(connection, tableName);
2017-06-17 07:40:09 +08:00
});
2017-06-14 09:54:15 +08:00
2023-02-21 10:49:28 +08:00
after(async function() {
await clearUp(connection, tableName);
2017-06-17 07:40:09 +08:00
});
2017-06-14 09:54:15 +08:00
2023-02-21 10:49:28 +08:00
const numRows = 10; // number of rows to return from each call to getRows()
2017-06-14 09:54:15 +08:00
2023-02-21 10:49:28 +08:00
async function doQuery() {
const result = await connection.execute(
"SELECT * FROM nodb_rs2_emp ORDER BY employees_id",
[],
{ resultSet: true });
const rs = result.resultSet;
while (true) { // eslint-disable-line
const rows = await rs.getRows(numRows);
if (rows.length == 0)
break;
}
await rs.close();
2017-06-17 07:40:09 +08:00
}
2023-02-21 10:49:28 +08:00
async function doRefCursor() {
const result = await connection.execute(
"BEGIN nodb_rs2_get_emp(:in, :out); END;",
{
in: 200,
out: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
});
const rs = result.outBinds.out;
while (true) { // eslint-disable-line
const rows = await rs.getRows(numRows);
if (rows.length == 0)
break;
}
await rs.close();
2017-06-17 07:40:09 +08:00
}
2023-02-21 10:49:28 +08:00
it('55.7.1 can access multiple resultSet on one connection', async function() {
const promises = [
doQuery(),
doQuery(),
];
const values = await Promise.allSettled(promises);
for (let i = 0; i < promises.length; i++) {
assert.strictEqual(values[i].status, 'fulfilled');
}
2017-06-17 07:40:09 +08:00
});
2017-06-14 09:54:15 +08:00
2023-02-21 10:49:28 +08:00
it('55.7.2 can access multiple REF Cursor', async function() {
const promises = [
doRefCursor(),
doRefCursor(),
];
const values = await Promise.allSettled(promises);
for (let i = 0; i < promises.length; i++) {
assert.strictEqual(values[i].status, 'fulfilled');
}
2017-06-17 07:40:09 +08:00
});
2023-02-21 10:49:28 +08:00
2017-06-17 07:40:09 +08:00
});
describe('55.9 test querying a PL/SQL function', function() {
2023-02-21 10:49:28 +08:00
before(async function() {
await setUp(connection, tableName);
2017-06-17 07:40:09 +08:00
});
2015-09-02 20:35:01 +08:00
2023-02-21 10:49:28 +08:00
after(async function() {
await clearUp(connection, tableName);
2017-06-17 07:40:09 +08:00
});
2015-09-02 20:35:01 +08:00
2023-02-21 10:49:28 +08:00
it('55.9.1 ', async function() {
const proc =
2017-06-14 09:54:15 +08:00
"CREATE OR REPLACE FUNCTION nodb_rs2_testfunc RETURN VARCHAR2 \
2015-08-17 14:19:36 +08:00
IS \
emp_name VARCHAR2(20); \
BEGIN \
SELECT 'Clark Kent' INTO emp_name FROM dual; \
RETURN emp_name; \
END; ";
2023-02-21 10:49:28 +08:00
await connection.execute(proc);
const result = await connection.execute(
"SELECT nodb_rs2_testfunc FROM dual",
[],
{ resultSet: true });
assert.strictEqual(result.resultSet.metaData[0].name,
'NODB_RS2_TESTFUNC');
const row = await result.resultSet.getRow();
assert.strictEqual(row[0], 'Clark Kent');
await result.resultSet.close();
await connection.execute("DROP FUNCTION nodb_rs2_testfunc");
2017-06-17 07:40:09 +08:00
});
});
2017-06-14 09:54:15 +08:00
2017-06-17 07:40:09 +08:00
describe('55.10 calls getRows() once and then close RS before getting more rows', function() {
2023-02-21 10:49:28 +08:00
before(async function() {
await setUp(connection, tableName);
2017-06-17 07:40:09 +08:00
});
2023-02-21 10:49:28 +08:00
after(async function() {
await clearUp(connection, tableName);
2017-06-17 07:40:09 +08:00
});
2017-06-14 09:54:15 +08:00
2023-02-21 10:49:28 +08:00
it('55.10.1 ', async function() {
const numRows = 10;
const result = await connection.execute(
2017-06-14 09:54:15 +08:00
"SELECT * FROM nodb_rs2_emp ORDER BY employees_id",
2015-07-20 15:56:29 +08:00
[],
2023-02-21 10:49:28 +08:00
{ resultSet: true });
const rs = result.resultSet;
await rs.getRows(numRows);
await rs.close();
2023-02-21 11:45:10 +08:00
await assert.rejects(
2023-02-21 10:49:28 +08:00
async () => await rs.getRows(numRows),
/NJS-018:/
2015-07-20 15:56:29 +08:00
);
2017-06-19 18:53:49 +08:00
});
});
2016-03-24 14:09:53 +08:00
2017-06-17 07:40:09 +08:00
describe('55.11 result set with unsupported data types', function() {
2023-02-21 10:49:28 +08:00
it('55.11.1 INTERVAL YEAR TO MONTH data type', async function() {
2023-02-21 11:45:10 +08:00
await assert.rejects(async () => {
2023-02-21 10:49:28 +08:00
await connection.execute(
"SELECT dummy, to_yminterval('1-3') FROM dual");
}, /NJS-010:/);
2017-06-17 07:40:09 +08:00
});
2015-07-20 15:56:29 +08:00
2017-06-17 07:40:09 +08:00
}); // 55.11
2016-03-24 14:09:53 +08:00
describe.skip('55.12 bind a cursor BIND_INOUT', function() {
2015-12-21 20:01:45 +08:00
2023-02-21 10:49:28 +08:00
before('prepare table nodb_rs2_emp', async function() {
await setUp(connection, tableName);
2017-06-17 07:40:09 +08:00
});
2015-12-21 20:01:45 +08:00
2023-02-21 10:49:28 +08:00
after('drop table', async function() {
await clearUp(connection, tableName);
2017-06-17 07:40:09 +08:00
});
2017-06-14 09:54:15 +08:00
2023-02-21 10:49:28 +08:00
it('55.12.1 has not supported binding a cursor with BIND_INOUT', async function() {
const proc =
2017-06-14 09:54:15 +08:00
"CREATE OR REPLACE PROCEDURE nodb_rs2_get_emp_inout (p_in IN NUMBER, p_out IN OUT SYS_REFCURSOR) \
AS \
BEGIN \
OPEN p_out FOR \
2017-06-14 09:54:15 +08:00
SELECT * FROM nodb_rs2_emp \
WHERE employees_id > p_in; \
2016-03-24 14:09:53 +08:00
END; ";
2023-02-21 10:49:28 +08:00
await connection.execute(proc);
2023-02-21 11:45:10 +08:00
await assert.rejects(async () => {
2023-02-21 10:49:28 +08:00
await connection.execute(
"BEGIN nodb_rs2_get_emp_inout(:in, :out); END;",
{
in: 200,
out: { type: oracledb.CURSOR, dir: oracledb.BIND_INOUT }
});
}, /NJS-0007:/);
await connection.execute("DROP PROCEDURE nodb_rs2_get_emp_inout");
2017-06-17 07:40:09 +08:00
});
2016-03-24 14:09:53 +08:00
2017-06-17 07:40:09 +08:00
}); // 55.12
2015-09-02 20:35:01 +08:00
2017-06-17 07:40:09 +08:00
describe('55.13 Invalid Ref Cursor', function() {
2023-02-21 10:49:28 +08:00
const proc =
2016-03-24 14:09:53 +08:00
"CREATE OR REPLACE PROCEDURE get_invalid_refcur ( p OUT SYS_REFCURSOR) " +
2015-09-02 20:35:01 +08:00
" AS " +
2016-03-24 14:09:53 +08:00
" BEGIN " +
" NULL; " +
2017-06-14 09:54:15 +08:00
" END;";
2023-02-21 10:49:28 +08:00
before(async function() {
await setUp(connection, tableName);
await connection.execute(proc);
2017-06-17 07:40:09 +08:00
});
2017-06-14 09:54:15 +08:00
2023-02-21 10:49:28 +08:00
after(async function() {
await connection.execute("DROP PROCEDURE get_invalid_refcur");
await clearUp(connection, tableName);
2017-06-17 07:40:09 +08:00
});
2016-03-24 14:09:53 +08:00
2023-02-21 10:49:28 +08:00
it('55.13.1 ', async function() {
2023-02-21 11:45:10 +08:00
await assert.rejects(async () => {
2023-02-21 10:49:28 +08:00
await connection.execute(
"BEGIN get_invalid_refcur ( :p ); END; ",
{
p : { type : oracledb.CURSOR, dir : oracledb.BIND_OUT }
});
2023-02-21 11:51:16 +08:00
}, /NJS-107:/);
2015-09-02 20:35:01 +08:00
2017-06-17 07:40:09 +08:00
}); // 55.13.1
}); // 55.13
2015-09-02 20:35:01 +08:00
2017-06-17 07:40:09 +08:00
});
2015-09-02 20:35:01 +08:00
/********************* Helper functions *************************/
2023-02-21 10:49:28 +08:00
async function setUp(connection, tableName) {
await createTable(connection, tableName);
await insertData(connection, tableName);
await createProc1(connection, tableName);
2017-06-17 07:40:09 +08:00
}
2023-02-21 10:49:28 +08:00
async function clearUp(connection, tableName) {
await dropProc1(connection);
await dropTable(connection, tableName);
2017-06-17 07:40:09 +08:00
}
2023-02-21 10:49:28 +08:00
async function createTable(connection, tableName) {
const sqlCreate =
2016-03-24 14:09:53 +08:00
"BEGIN " +
2015-09-02 20:35:01 +08:00
" DECLARE " +
2017-06-14 09:54:15 +08:00
" e_table_missing EXCEPTION; " +
" PRAGMA EXCEPTION_INIT(e_table_missing, -00942); " +
2015-09-02 20:35:01 +08:00
" BEGIN " +
2017-06-14 09:54:15 +08:00
" EXECUTE IMMEDIATE ('DROP TABLE " + tableName + " PURGE'); " +
2015-09-02 20:35:01 +08:00
" EXCEPTION " +
2017-06-14 09:54:15 +08:00
" WHEN e_table_missing " +
2015-09-02 20:35:01 +08:00
" THEN NULL; " +
" END; " +
" EXECUTE IMMEDIATE (' " +
2021-04-01 12:48:37 +08:00
" CREATE TABLE " + tableName + " ( " +
2016-03-24 14:09:53 +08:00
" employees_id NUMBER(10), " +
2015-09-02 20:35:01 +08:00
" employee_name VARCHAR2(20) " +
" )" +
2016-03-24 14:09:53 +08:00
" '); " +
2015-09-02 20:35:01 +08:00
"END; ";
2023-02-21 10:49:28 +08:00
await connection.execute(sqlCreate);
2017-06-17 07:40:09 +08:00
}
2015-09-02 20:35:01 +08:00
2023-02-21 10:49:28 +08:00
async function dropTable(connection, tableName) {
await connection.execute('DROP TABLE ' + tableName + ' PURGE');
2017-06-17 07:40:09 +08:00
}
2015-09-02 20:35:01 +08:00
2023-02-21 10:49:28 +08:00
async function insertData(connection, tableName) {
const sqlInsert =
2016-03-24 14:09:53 +08:00
"DECLARE " +
" x NUMBER := 0; " +
" n VARCHAR2(20); " +
2015-09-02 20:35:01 +08:00
"BEGIN " +
" FOR i IN 1..300 LOOP " +
2016-03-24 14:09:53 +08:00
" x := x + 1; " +
" n := 'staff ' || x; " +
" INSERT INTO " + tableName + " VALUES (x, n); " +
2015-09-02 20:35:01 +08:00
" END LOOP; " +
"END; ";
2016-03-24 14:09:53 +08:00
2023-02-21 10:49:28 +08:00
await connection.execute(sqlInsert, [], { autoCommit: true });
2017-06-17 07:40:09 +08:00
}
2015-09-02 20:35:01 +08:00
2023-02-21 10:49:28 +08:00
async function createProc1(connection, tableName) {
const sqlProc =
2017-06-14 09:54:15 +08:00
"CREATE OR REPLACE PROCEDURE nodb_rs2_get_emp (p_in IN NUMBER, p_out OUT SYS_REFCURSOR) " +
2016-03-24 14:09:53 +08:00
" AS " +
" BEGIN " +
" OPEN p_out FOR " +
" SELECT * FROM " + tableName + " WHERE employees_id > p_in; " +
2015-09-02 20:35:01 +08:00
" END; ";
2023-02-21 10:49:28 +08:00
await connection.execute(sqlProc);
2017-06-17 07:40:09 +08:00
}
2015-09-02 20:35:01 +08:00
2023-02-21 10:49:28 +08:00
async function dropProc1(connection) {
await connection.execute('DROP PROCEDURE nodb_rs2_get_emp');
2017-06-17 07:40:09 +08:00
}