@zowe/db2-for-zowe-cli 6.1.17 → 6.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -10
- package/lib/Db2PluginLifeCycle.d.ts +11 -9
- package/lib/Db2PluginLifeCycle.js +18 -13
- package/lib/Db2PluginLifeCycle.js.map +1 -1
- package/node_modules/axios/CHANGELOG.md +62 -0
- package/node_modules/axios/README.md +233 -5
- package/node_modules/axios/dist/axios.js +387 -89
- package/node_modules/axios/dist/axios.min.js +3 -3
- package/node_modules/axios/dist/axios.min.js.map +1 -1
- package/node_modules/axios/dist/browser/axios.cjs +458 -98
- package/node_modules/axios/dist/esm/axios.js +458 -98
- package/node_modules/axios/dist/esm/axios.min.js +2 -2
- package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
- package/node_modules/axios/dist/node/axios.cjs +568 -116
- package/node_modules/axios/index.d.cts +4 -0
- package/node_modules/axios/index.d.ts +4 -0
- package/node_modules/axios/lib/adapters/fetch.js +64 -11
- package/node_modules/axios/lib/adapters/http.js +134 -50
- package/node_modules/axios/lib/adapters/xhr.js +52 -3
- package/node_modules/axios/lib/core/Axios.js +19 -14
- package/node_modules/axios/lib/core/InterceptorManager.js +107 -8
- package/node_modules/axios/lib/core/buildFullPath.js +1 -13
- package/node_modules/axios/lib/core/dispatchRequest.js +8 -2
- package/node_modules/axios/lib/core/mergeConfig.js +1 -1
- package/node_modules/axios/lib/core/methodList.js +17 -0
- package/node_modules/axios/lib/defaults/index.js +2 -1
- package/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/axios/lib/helpers/Http2Sessions.js +2 -0
- package/node_modules/axios/lib/helpers/HttpStatusCode.js +11 -1
- package/node_modules/axios/lib/helpers/fromDataURI.js +5 -4
- package/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
- package/node_modules/axios/lib/helpers/progressEventReducer.js +1 -1
- package/node_modules/axios/lib/helpers/resolveConfig.js +4 -2
- package/node_modules/axios/lib/helpers/shouldBypassProxy.js +182 -6
- package/node_modules/axios/lib/helpers/throttle.js +3 -2
- package/node_modules/axios/lib/helpers/toFormData.js +14 -21
- package/node_modules/axios/lib/utils.js +134 -13
- package/node_modules/axios/package.json +1 -1
- package/node_modules/ibm_db/APIDocumentation.md +2883 -2024
- package/node_modules/ibm_db/LICENSE +23 -23
- package/node_modules/ibm_db/README.md +735 -735
- package/node_modules/ibm_db/binding.gyp +99 -98
- package/node_modules/ibm_db/installer/driverInstall.js +984 -958
- package/node_modules/ibm_db/installer/ifx.sh +38 -38
- package/node_modules/ibm_db/installer/setenv.sh +23 -23
- package/node_modules/ibm_db/installer/testODBCConnection.bat +51 -51
- package/node_modules/ibm_db/installer/testODBCConnection.sh +61 -61
- package/node_modules/ibm_db/lib/climacros.js +431 -431
- package/node_modules/ibm_db/lib/odbc.js +4293 -3487
- package/node_modules/ibm_db/lib/simple-queue.js +41 -41
- package/node_modules/ibm_db/package.json +70 -70
- package/node_modules/ibm_db/src/odbc.cpp +1495 -1396
- package/node_modules/ibm_db/src/odbc.h +477 -473
- package/node_modules/ibm_db/src/odbc_connection.cpp +1762 -1612
- package/node_modules/ibm_db/src/odbc_connection.h +228 -215
- package/node_modules/ibm_db/src/odbc_result.cpp +1547 -1547
- package/node_modules/ibm_db/src/odbc_result.h +152 -152
- package/node_modules/ibm_db/src/odbc_statement.cpp +2047 -861
- package/node_modules/ibm_db/src/odbc_statement.h +257 -135
- package/node_modules/ibm_db/src/strptime.c +389 -389
- package/node_modules/ibm_db/src/strptime.h +46 -46
- package/node_modules/ibm_db/test/README +23 -23
- package/node_modules/ibm_db/test/bench-insert.js +62 -62
- package/node_modules/ibm_db/test/bench-insertBatch10.js +74 -74
- package/node_modules/ibm_db/test/bench-insertBatch100.js +75 -75
- package/node_modules/ibm_db/test/bench-insertBatch1000.js +75 -75
- package/node_modules/ibm_db/test/bench-insertBatch10000.js +75 -75
- package/node_modules/ibm_db/test/bench-prepare-bind-execute-closeSync.js +60 -60
- package/node_modules/ibm_db/test/bench-prepare-bind-executeNonQuery.js +53 -53
- package/node_modules/ibm_db/test/bench-prepare-bindSync-execute-closeSync.js +50 -50
- package/node_modules/ibm_db/test/bench-prepare-bindSync-executeNonQuery.js +48 -48
- package/node_modules/ibm_db/test/bench-prepare-execute-closeSync.js +51 -51
- package/node_modules/ibm_db/test/bench-prepare-executeNonQuery.js +47 -47
- package/node_modules/ibm_db/test/bench-prepare-not.js +43 -43
- package/node_modules/ibm_db/test/bench-query-fetch.js +59 -59
- package/node_modules/ibm_db/test/bench-query-fetchAll.js +49 -49
- package/node_modules/ibm_db/test/bench-query-fetchAllSync.js +43 -43
- package/node_modules/ibm_db/test/bench-query.js +40 -40
- package/node_modules/ibm_db/test/bench-querySync-fetchArray.js +28 -28
- package/node_modules/ibm_db/test/bench-querySync.js +29 -29
- package/node_modules/ibm_db/test/common.d.ts +10 -10
- package/node_modules/ibm_db/test/common.js +127 -127
- package/node_modules/ibm_db/test/config.json +7 -7
- package/node_modules/ibm_db/test/config.zos.json +4 -4
- package/node_modules/ibm_db/test/data/sample1.txt +9 -9
- package/node_modules/ibm_db/test/data/trc.fmt +30114 -30114
- package/node_modules/ibm_db/test/nodeEE-leak-huge-query.js +152 -152
- package/node_modules/ibm_db/test/nodeEE-leak-multiple-query-multiple-connections.js +148 -148
- package/node_modules/ibm_db/test/nodeEE-leak-multiple-query-pool-connections.js +154 -154
- package/node_modules/ibm_db/test/nodeEE-leak-multiple-query.js +133 -133
- package/node_modules/ibm_db/test/nodeEE-stress-async-waterfall-multiple-connections.js +174 -174
- package/node_modules/ibm_db/test/nodeEE-stress-async-waterfall.js +169 -169
- package/node_modules/ibm_db/test/nodeEE-stress-mixed-query-multiple-connections.js +159 -159
- package/node_modules/ibm_db/test/nodeEE-stress-mixed-query.js +148 -148
- package/node_modules/ibm_db/test/odbc-bench.c +123 -123
- package/node_modules/ibm_db/test/perfTest.js +53 -53
- package/node_modules/ibm_db/test/quick-example.sh +30 -30
- package/node_modules/ibm_db/test/quick-example.ts +80 -80
- package/node_modules/ibm_db/test/run-bench.js +96 -96
- package/node_modules/ibm_db/test/run-nodeEE.js +132 -132
- package/node_modules/ibm_db/test/run-tests.js +132 -138
- package/node_modules/ibm_db/test/sql-cli.js +28 -28
- package/node_modules/ibm_db/test/test-all-data-types.js +109 -109
- package/node_modules/ibm_db/test/test-array-insert.js +178 -178
- package/node_modules/ibm_db/test/test-async-await.js +105 -105
- package/node_modules/ibm_db/test/test-attributes.js +34 -34
- package/node_modules/ibm_db/test/test-bad-pool-connection-prepare-execute.js +57 -57
- package/node_modules/ibm_db/test/test-basic-test.js +138 -138
- package/node_modules/ibm_db/test/test-binary-array-insert.js +73 -73
- package/node_modules/ibm_db/test/test-blob-from-file.js +90 -90
- package/node_modules/ibm_db/test/test-blob-insert.js +144 -144
- package/node_modules/ibm_db/test/test-blob-stream-insert.js +321 -299
- package/node_modules/ibm_db/test/test-blob-to-file.js +370 -370
- package/node_modules/ibm_db/test/test-block-fetch.js +364 -364
- package/node_modules/ibm_db/test/test-blocking-issue210.js +123 -123
- package/node_modules/ibm_db/test/test-call-async.js +64 -64
- package/node_modules/ibm_db/test/test-call-stmt.js +53 -53
- package/node_modules/ibm_db/test/test-cancel.js +703 -0
- package/node_modules/ibm_db/test/test-chinese-char.js +59 -59
- package/node_modules/ibm_db/test/test-connection.js +306 -0
- package/node_modules/ibm_db/test/test-date.js +32 -32
- package/node_modules/ibm_db/test/test-dbclob.js +93 -93
- package/node_modules/ibm_db/test/test-decimals.js +135 -135
- package/node_modules/ibm_db/test/test-describe-metadata.js +148 -0
- package/node_modules/ibm_db/test/test-executeFile.js +167 -167
- package/node_modules/ibm_db/test/test-executeFileSync.js +85 -85
- package/node_modules/ibm_db/test/test-fetch-apis.js +146 -146
- package/node_modules/ibm_db/test/test-fetchN.js +130 -130
- package/node_modules/ibm_db/test/test-getinfo.js +197 -197
- package/node_modules/ibm_db/test/test-ibm-db-issue14.js +58 -58
- package/node_modules/ibm_db/test/test-ibm-db-issue17.js +54 -54
- package/node_modules/ibm_db/test/test-ibm-db-issue18.js +54 -54
- package/node_modules/ibm_db/test/test-issue-1059-fetchAll-undefined.js +67 -67
- package/node_modules/ibm_db/test/test-issue-1080-array-blob-insert.js +40 -0
- package/node_modules/ibm_db/test/test-issue-54.js +39 -39
- package/node_modules/ibm_db/test/test-issue-get-column-value-2.js +44 -44
- package/node_modules/ibm_db/test/test-issue211.js +80 -80
- package/node_modules/ibm_db/test/test-issue253.js +39 -39
- package/node_modules/ibm_db/test/test-max-pool-size.js +96 -96
- package/node_modules/ibm_db/test/test-memory-leaks-new-objects.js +32 -32
- package/node_modules/ibm_db/test/test-multi-open-query-close.js +75 -75
- package/node_modules/ibm_db/test/test-param-put-data.js +713 -0
- package/node_modules/ibm_db/test/test-pool-idle-connection.js +72 -72
- package/node_modules/ibm_db/test/test-pool-operations.js +325 -0
- package/node_modules/ibm_db/test/test-pool-stale-connections.js +111 -111
- package/node_modules/ibm_db/test/test-pool-uncommited.js +33 -33
- package/node_modules/ibm_db/test/test-prepare-execute.js +339 -0
- package/node_modules/ibm_db/test/test-prepareSync-multiple-execution.js +93 -93
- package/node_modules/ibm_db/test/test-primary-foreign-keys.js +246 -0
- package/node_modules/ibm_db/test/test-procedures.js +243 -0
- package/node_modules/ibm_db/test/test-promise-all-data-types.js +42 -42
- package/node_modules/ibm_db/test/test-query-operations.js +405 -0
- package/node_modules/ibm_db/test/test-quick-example.js +25 -25
- package/node_modules/ibm_db/test/test-row-array-insert.js +167 -167
- package/node_modules/ibm_db/test/test-sp-array.js +54 -54
- package/node_modules/ibm_db/test/test-sp-dbc-6000.js +88 -88
- package/node_modules/ibm_db/test/test-sp-memleak.js +136 -136
- package/node_modules/ibm_db/test/test-sp-resultset-execute.js +269 -269
- package/node_modules/ibm_db/test/test-sp-resultset.js +228 -228
- package/node_modules/ibm_db/test/test-transactions.js +261 -0
- package/node_modules/ibm_db/test/test-typescript.js +48 -48
- package/node_modules/ibm_db/test/test-xml-datatype.js +70 -70
- package/node_modules/ibm_db/test/testWebApp.js +56 -56
- package/node_modules/ibm_db/test/trace +51 -51
- package/node_modules/ibm_db/test/typescript-apis-test.js +978 -978
- package/node_modules/ibm_db/test/webapp.html +17 -17
- package/node_modules/ibm_db/test/webapp.js +79 -79
- package/node_modules/ibm_db/typescript/README.md +28 -28
- package/node_modules/ibm_db/typescript/dist/Database.d.ts +26 -0
- package/node_modules/ibm_db/typescript/dist/ODBCStatement.d.ts +93 -0
- package/package.json +10 -6
- package/node_modules/ibm_db/test/disabled/test-binding-statement-rebinding.js +0 -59
- package/node_modules/ibm_db/test/disabled/test-open-dont-close.js +0 -12
- package/node_modules/ibm_db/test/disabled/test-param-select-with-booleans-only.js +0 -21
- package/node_modules/ibm_db/test/disabled/test-param-select-with-decimals-only.js +0 -20
- package/node_modules/ibm_db/test/disabled/test-param-select-with-null.js +0 -21
- package/node_modules/ibm_db/test/disabled/test-param-select-with-nulls-mixed.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-param-select-with-numbers-mixed.js +0 -22
- package/node_modules/ibm_db/test/disabled/test-param-select-with-numbers-only.js +0 -24
- package/node_modules/ibm_db/test/disabled/test-param-select-with-strings-only.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-param-select-with-unicode.js +0 -15
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-closeSync.js +0 -62
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-error.js +0 -49
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-long-string.js +0 -63
- package/node_modules/ibm_db/test/disabled/test-prepare-bind-executeNonQuery.js +0 -63
- package/node_modules/ibm_db/test/disabled/test-prepare-bindSync-execute-closeSync.js +0 -46
- package/node_modules/ibm_db/test/disabled/test-prepare-bindSync-executeNonQuery.js +0 -50
- package/node_modules/ibm_db/test/disabled/test-prepare.js +0 -34
- package/node_modules/ibm_db/test/disabled/test-prepareSync.js +0 -29
- package/node_modules/ibm_db/test/disabled/test-query-select-fetchAll.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-query-select-fetchAllSync.js +0 -23
- package/node_modules/ibm_db/test/disabled/test-query-select-unicode.js +0 -15
- package/node_modules/ibm_db/test/disabled/test-querySync-select-unicode.js +0 -20
- package/node_modules/ibm_db/test/test-affected-rows.js +0 -55
- package/node_modules/ibm_db/test/test-bad-connection-string.js +0 -30
- package/node_modules/ibm_db/test/test-binding-connection-timeOut.js +0 -31
- package/node_modules/ibm_db/test/test-binding-statement-executeSync.js +0 -84
- package/node_modules/ibm_db/test/test-binding-transaction-commit.js +0 -79
- package/node_modules/ibm_db/test/test-binding-transaction-commitSync.js +0 -53
- package/node_modules/ibm_db/test/test-closed.js +0 -14
- package/node_modules/ibm_db/test/test-connection-object.js +0 -16
- package/node_modules/ibm_db/test/test-describe-column.js +0 -92
- package/node_modules/ibm_db/test/test-describe-database.js +0 -18
- package/node_modules/ibm_db/test/test-describe-table.js +0 -31
- package/node_modules/ibm_db/test/test-domains-open.js +0 -19
- package/node_modules/ibm_db/test/test-global-open-close.js +0 -11
- package/node_modules/ibm_db/test/test-instantiate-one-and-end.js +0 -9
- package/node_modules/ibm_db/test/test-multi-open-close.js +0 -45
- package/node_modules/ibm_db/test/test-multi-openSync-closeSync.js +0 -52
- package/node_modules/ibm_db/test/test-open-close.js +0 -29
- package/node_modules/ibm_db/test/test-open-connectTimeout.js +0 -33
- package/node_modules/ibm_db/test/test-openSync.js +0 -31
- package/node_modules/ibm_db/test/test-pool-close.js +0 -120
- package/node_modules/ibm_db/test/test-pool-connect.js +0 -36
- package/node_modules/ibm_db/test/test-pool-rollbackTransaction.js +0 -35
- package/node_modules/ibm_db/test/test-prepareSync-bad-sql.js +0 -34
- package/node_modules/ibm_db/test/test-promise-open-close.js +0 -33
- package/node_modules/ibm_db/test/test-query-create-table-fetchSync.js +0 -23
- package/node_modules/ibm_db/test/test-query-create-table.js +0 -12
- package/node_modules/ibm_db/test/test-query-drop-table.js +0 -13
- package/node_modules/ibm_db/test/test-query-insert.js +0 -38
- package/node_modules/ibm_db/test/test-query-select-fetch.js +0 -21
- package/node_modules/ibm_db/test/test-query-select-fetchMode-array.js +0 -17
- package/node_modules/ibm_db/test/test-query-select.js +0 -64
- package/node_modules/ibm_db/test/test-queryResult.js +0 -35
- package/node_modules/ibm_db/test/test-queryStream.js +0 -43
- package/node_modules/ibm_db/test/test-querySync-select-with-exception.js +0 -25
- package/node_modules/ibm_db/test/test-querySync-select.js +0 -28
- package/node_modules/ibm_db/test/test-require-and-end.js +0 -8
- package/node_modules/ibm_db/test/test-statement-close.js +0 -118
- package/node_modules/ibm_db/test/test-transaction-commit-sync.js +0 -54
- package/node_modules/ibm_db/test/test-transaction-commit.js +0 -79
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
|
|
2
|
-
// Test file to demonstrate use of fetch, fetchSynch, fetchAll and fetchAllSync APIs.
|
|
3
|
-
|
|
4
|
-
var common = require("./common")
|
|
5
|
-
, ibmdb = require("../")
|
|
6
|
-
, assert = require("assert")
|
|
7
|
-
, cn=common.connectionString
|
|
8
|
-
;
|
|
9
|
-
|
|
10
|
-
ibmdb.open(cn,function(err,conn){
|
|
11
|
-
conn.querySync("create table hits (col1 varchar(40), col2 int, col3 decimal(11,0))");
|
|
12
|
-
conn.querySync("insert into hits values ('something', 42, 343434)");
|
|
13
|
-
conn.querySync("insert into hits values ('für', 43, 35353535)");
|
|
14
|
-
|
|
15
|
-
// Fetch data Synchronously using fetchSync() API.
|
|
16
|
-
var stmt = conn.prepareSync("select * from hits");
|
|
17
|
-
stmt.setAttrSync(3, 2); //SQL_ATTR_MAX_LENGTH = 3
|
|
18
|
-
var result = stmt.executeSync();
|
|
19
|
-
var data = 0;
|
|
20
|
-
console.log("-------------------------------------------------------------");
|
|
21
|
-
console.log("result = ", result);
|
|
22
|
-
console.log("Selected data using fetchSync() API = ");
|
|
23
|
-
while( data = result.fetchSync({fetchMode:3}) ) {
|
|
24
|
-
console.log(data);
|
|
25
|
-
}
|
|
26
|
-
result.closeSync();
|
|
27
|
-
|
|
28
|
-
// Get column data in chunks using getDataSync API
|
|
29
|
-
stmt = conn.prepareSync("select * from hits");
|
|
30
|
-
result = stmt.executeSync();
|
|
31
|
-
console.log("Retrieve column data using getDataSync API:");
|
|
32
|
-
console.log(result.fetchSync({fetchMode:0}));
|
|
33
|
-
console.log("First Row Data = ");
|
|
34
|
-
console.log(result.getDataSync(1, 4));
|
|
35
|
-
console.log(result.getDataSync(1, 5));
|
|
36
|
-
console.log(result.getDataSync(2, 5));
|
|
37
|
-
console.log(result.getDataSync(3, 5));
|
|
38
|
-
result.fetchSync({fetchMode:0});
|
|
39
|
-
console.log("Second Row Data = ");
|
|
40
|
-
console.log(result.getDataSync(1, 4));
|
|
41
|
-
console.log(result.getDataSync(1, 5));
|
|
42
|
-
console.log(result.getDataSync(2, 5));
|
|
43
|
-
console.log(result.getDataSync(3, 5));
|
|
44
|
-
result.closeSync();
|
|
45
|
-
console.log("------------------");
|
|
46
|
-
|
|
47
|
-
// Fetch data Synchronously using fetchAllSync() API.
|
|
48
|
-
//stmt = conn.prepareSync("select * from hits");
|
|
49
|
-
result = stmt.executeSync();
|
|
50
|
-
data = result.fetchAllSync();
|
|
51
|
-
console.log("Selected rows using fetchAllSync() API = ", data);
|
|
52
|
-
result.closeSync();
|
|
53
|
-
|
|
54
|
-
// Fetch data Asynchronously using fetchAll() API.
|
|
55
|
-
result = stmt.executeSync();
|
|
56
|
-
result.fetchAll(function (err, data, colcount) {
|
|
57
|
-
if(err) { console.log(err); }
|
|
58
|
-
else {
|
|
59
|
-
console.log("Selected data using fetchAll() API = ", data);
|
|
60
|
-
console.log("No of columns in selected data = ", colcount);
|
|
61
|
-
assert.deepEqual(colcount, 3);
|
|
62
|
-
}
|
|
63
|
-
result.closeSync();
|
|
64
|
-
|
|
65
|
-
// Fetch data Asynchronously using Promisified fetch() API.
|
|
66
|
-
stmt.execute(function (err, result) {
|
|
67
|
-
if( err ) console.log(err);
|
|
68
|
-
result.fetch().then(row => {
|
|
69
|
-
console.log("\n\n--------------------------------------------");
|
|
70
|
-
console.log("Selected data using Promisified fetch() API: ");
|
|
71
|
-
console.log("--------------------------------------------");
|
|
72
|
-
console.log("Row1 = ", row);
|
|
73
|
-
return result.fetch({fetchMode:ibmdb.FETCH_ARRAY});
|
|
74
|
-
}).then(row => {
|
|
75
|
-
console.log("Row2 = ", row);
|
|
76
|
-
result.closeSync();
|
|
77
|
-
|
|
78
|
-
// Get column data in chunks using getData API
|
|
79
|
-
stmt = conn.prepareSync("select * from hits");
|
|
80
|
-
result = stmt.executeSync();
|
|
81
|
-
console.log("Retrieve column data using getData API:");
|
|
82
|
-
return result.fetch({fetchMode:0});
|
|
83
|
-
}).then(() => {
|
|
84
|
-
console.log("First Row Data = ");
|
|
85
|
-
return result.getData(1, 4);
|
|
86
|
-
}).then(data => {
|
|
87
|
-
console.log(data);
|
|
88
|
-
return result.getData(1, 5);
|
|
89
|
-
}).then(data => {
|
|
90
|
-
console.log(data);
|
|
91
|
-
return result.getData(2, 5);
|
|
92
|
-
}).then(data => {
|
|
93
|
-
console.log(data);
|
|
94
|
-
return result.getData(3, 5);
|
|
95
|
-
}).then(data => {
|
|
96
|
-
console.log(data);
|
|
97
|
-
result.fetchSync({fetchMode:0});
|
|
98
|
-
console.log("Second Row Data = ");
|
|
99
|
-
return result.getData(1, 4);
|
|
100
|
-
}).then( data => {
|
|
101
|
-
console.log(data);
|
|
102
|
-
return result.getData(1, 5);
|
|
103
|
-
}).then(data => {
|
|
104
|
-
console.log(data);
|
|
105
|
-
console.log(result.getDataSync(2, 2));
|
|
106
|
-
console.log(result.getDataSync(3, 3));
|
|
107
|
-
result.closeSync();
|
|
108
|
-
console.log("------------------");
|
|
109
|
-
return testAsync(conn);
|
|
110
|
-
}).then(() => {
|
|
111
|
-
conn.querySync("drop table hits");
|
|
112
|
-
//Close the connection
|
|
113
|
-
conn.close(function(err){
|
|
114
|
-
console.log("Connection Closed.");
|
|
115
|
-
console.log("---------------------------------------------------");
|
|
116
|
-
});
|
|
117
|
-
}).catch(err => console.log(err));
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
// Select data asynchronously using async-await
|
|
123
|
-
async function testAsync(conn) {
|
|
124
|
-
let stmt = conn.prepareSync("select * from hits");
|
|
125
|
-
let result = stmt.executeSync();
|
|
126
|
-
console.log("\n\n---------------------------------------");
|
|
127
|
-
console.log("Retrieve column data using async-await:");
|
|
128
|
-
console.log("---------------------------------------");
|
|
129
|
-
await result.fetch({fetchMode:0});
|
|
130
|
-
process.stdout.write("First Row Data = ");
|
|
131
|
-
let data = await result.getData(1, 4);
|
|
132
|
-
process.stdout.write(data);
|
|
133
|
-
data = await result.getData(1, 5);
|
|
134
|
-
process.stdout.write(data);
|
|
135
|
-
process.stdout.write(", " + await result.getData(2, 5));
|
|
136
|
-
console.log(", ", await result.getData(3, 5));
|
|
137
|
-
await result.fetch({fetchMode:ibmdb.FETCH_NODATA});
|
|
138
|
-
process.stdout.write("Second Row Data = ");
|
|
139
|
-
process.stdout.write(await result.getData(1, 4));
|
|
140
|
-
process.stdout.write(result.getDataSync(1, 5));
|
|
141
|
-
process.stdout.write(", " + await result.getData(2, 5));
|
|
142
|
-
console.log(", ", result.getDataSync(3, 5));
|
|
143
|
-
await result.close();
|
|
144
|
-
console.log("------ return from testAsync --------\n");
|
|
145
|
-
}
|
|
146
|
-
|
|
1
|
+
|
|
2
|
+
// Test file to demonstrate use of fetch, fetchSynch, fetchAll and fetchAllSync APIs.
|
|
3
|
+
|
|
4
|
+
var common = require("./common")
|
|
5
|
+
, ibmdb = require("../")
|
|
6
|
+
, assert = require("assert")
|
|
7
|
+
, cn=common.connectionString
|
|
8
|
+
;
|
|
9
|
+
|
|
10
|
+
ibmdb.open(cn,function(err,conn){
|
|
11
|
+
conn.querySync("create table hits (col1 varchar(40), col2 int, col3 decimal(11,0))");
|
|
12
|
+
conn.querySync("insert into hits values ('something', 42, 343434)");
|
|
13
|
+
conn.querySync("insert into hits values ('für', 43, 35353535)");
|
|
14
|
+
|
|
15
|
+
// Fetch data Synchronously using fetchSync() API.
|
|
16
|
+
var stmt = conn.prepareSync("select * from hits");
|
|
17
|
+
stmt.setAttrSync(3, 2); //SQL_ATTR_MAX_LENGTH = 3
|
|
18
|
+
var result = stmt.executeSync();
|
|
19
|
+
var data = 0;
|
|
20
|
+
console.log("-------------------------------------------------------------");
|
|
21
|
+
console.log("result = ", result);
|
|
22
|
+
console.log("Selected data using fetchSync() API = ");
|
|
23
|
+
while( data = result.fetchSync({fetchMode:3}) ) {
|
|
24
|
+
console.log(data);
|
|
25
|
+
}
|
|
26
|
+
result.closeSync();
|
|
27
|
+
|
|
28
|
+
// Get column data in chunks using getDataSync API
|
|
29
|
+
stmt = conn.prepareSync("select * from hits");
|
|
30
|
+
result = stmt.executeSync();
|
|
31
|
+
console.log("Retrieve column data using getDataSync API:");
|
|
32
|
+
console.log(result.fetchSync({fetchMode:0}));
|
|
33
|
+
console.log("First Row Data = ");
|
|
34
|
+
console.log(result.getDataSync(1, 4));
|
|
35
|
+
console.log(result.getDataSync(1, 5));
|
|
36
|
+
console.log(result.getDataSync(2, 5));
|
|
37
|
+
console.log(result.getDataSync(3, 5));
|
|
38
|
+
result.fetchSync({fetchMode:0});
|
|
39
|
+
console.log("Second Row Data = ");
|
|
40
|
+
console.log(result.getDataSync(1, 4));
|
|
41
|
+
console.log(result.getDataSync(1, 5));
|
|
42
|
+
console.log(result.getDataSync(2, 5));
|
|
43
|
+
console.log(result.getDataSync(3, 5));
|
|
44
|
+
result.closeSync();
|
|
45
|
+
console.log("------------------");
|
|
46
|
+
|
|
47
|
+
// Fetch data Synchronously using fetchAllSync() API.
|
|
48
|
+
//stmt = conn.prepareSync("select * from hits");
|
|
49
|
+
result = stmt.executeSync();
|
|
50
|
+
data = result.fetchAllSync();
|
|
51
|
+
console.log("Selected rows using fetchAllSync() API = ", data);
|
|
52
|
+
result.closeSync();
|
|
53
|
+
|
|
54
|
+
// Fetch data Asynchronously using fetchAll() API.
|
|
55
|
+
result = stmt.executeSync();
|
|
56
|
+
result.fetchAll(function (err, data, colcount) {
|
|
57
|
+
if(err) { console.log(err); }
|
|
58
|
+
else {
|
|
59
|
+
console.log("Selected data using fetchAll() API = ", data);
|
|
60
|
+
console.log("No of columns in selected data = ", colcount);
|
|
61
|
+
assert.deepEqual(colcount, 3);
|
|
62
|
+
}
|
|
63
|
+
result.closeSync();
|
|
64
|
+
|
|
65
|
+
// Fetch data Asynchronously using Promisified fetch() API.
|
|
66
|
+
stmt.execute(function (err, result) {
|
|
67
|
+
if( err ) console.log(err);
|
|
68
|
+
result.fetch().then(row => {
|
|
69
|
+
console.log("\n\n--------------------------------------------");
|
|
70
|
+
console.log("Selected data using Promisified fetch() API: ");
|
|
71
|
+
console.log("--------------------------------------------");
|
|
72
|
+
console.log("Row1 = ", row);
|
|
73
|
+
return result.fetch({fetchMode:ibmdb.FETCH_ARRAY});
|
|
74
|
+
}).then(row => {
|
|
75
|
+
console.log("Row2 = ", row);
|
|
76
|
+
result.closeSync();
|
|
77
|
+
|
|
78
|
+
// Get column data in chunks using getData API
|
|
79
|
+
stmt = conn.prepareSync("select * from hits");
|
|
80
|
+
result = stmt.executeSync();
|
|
81
|
+
console.log("Retrieve column data using getData API:");
|
|
82
|
+
return result.fetch({fetchMode:0});
|
|
83
|
+
}).then(() => {
|
|
84
|
+
console.log("First Row Data = ");
|
|
85
|
+
return result.getData(1, 4);
|
|
86
|
+
}).then(data => {
|
|
87
|
+
console.log(data);
|
|
88
|
+
return result.getData(1, 5);
|
|
89
|
+
}).then(data => {
|
|
90
|
+
console.log(data);
|
|
91
|
+
return result.getData(2, 5);
|
|
92
|
+
}).then(data => {
|
|
93
|
+
console.log(data);
|
|
94
|
+
return result.getData(3, 5);
|
|
95
|
+
}).then(data => {
|
|
96
|
+
console.log(data);
|
|
97
|
+
result.fetchSync({fetchMode:0});
|
|
98
|
+
console.log("Second Row Data = ");
|
|
99
|
+
return result.getData(1, 4);
|
|
100
|
+
}).then( data => {
|
|
101
|
+
console.log(data);
|
|
102
|
+
return result.getData(1, 5);
|
|
103
|
+
}).then(data => {
|
|
104
|
+
console.log(data);
|
|
105
|
+
console.log(result.getDataSync(2, 2));
|
|
106
|
+
console.log(result.getDataSync(3, 3));
|
|
107
|
+
result.closeSync();
|
|
108
|
+
console.log("------------------");
|
|
109
|
+
return testAsync(conn);
|
|
110
|
+
}).then(() => {
|
|
111
|
+
conn.querySync("drop table hits");
|
|
112
|
+
//Close the connection
|
|
113
|
+
conn.close(function(err){
|
|
114
|
+
console.log("Connection Closed.");
|
|
115
|
+
console.log("---------------------------------------------------");
|
|
116
|
+
});
|
|
117
|
+
}).catch(err => console.log(err));
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// Select data asynchronously using async-await
|
|
123
|
+
async function testAsync(conn) {
|
|
124
|
+
let stmt = conn.prepareSync("select * from hits");
|
|
125
|
+
let result = stmt.executeSync();
|
|
126
|
+
console.log("\n\n---------------------------------------");
|
|
127
|
+
console.log("Retrieve column data using async-await:");
|
|
128
|
+
console.log("---------------------------------------");
|
|
129
|
+
await result.fetch({fetchMode:0});
|
|
130
|
+
process.stdout.write("First Row Data = ");
|
|
131
|
+
let data = await result.getData(1, 4);
|
|
132
|
+
process.stdout.write(data);
|
|
133
|
+
data = await result.getData(1, 5);
|
|
134
|
+
process.stdout.write(data);
|
|
135
|
+
process.stdout.write(", " + await result.getData(2, 5));
|
|
136
|
+
console.log(", ", await result.getData(3, 5));
|
|
137
|
+
await result.fetch({fetchMode:ibmdb.FETCH_NODATA});
|
|
138
|
+
process.stdout.write("Second Row Data = ");
|
|
139
|
+
process.stdout.write(await result.getData(1, 4));
|
|
140
|
+
process.stdout.write(result.getDataSync(1, 5));
|
|
141
|
+
process.stdout.write(", " + await result.getData(2, 5));
|
|
142
|
+
console.log(", ", result.getDataSync(3, 5));
|
|
143
|
+
await result.close();
|
|
144
|
+
console.log("------ return from testAsync --------\n");
|
|
145
|
+
}
|
|
146
|
+
|
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
var common = require("./common")
|
|
2
|
-
, ibmdb = require("../")
|
|
3
|
-
, assert = require("assert")
|
|
4
|
-
;
|
|
5
|
-
|
|
6
|
-
// Test fetchN (batch fetch) feature (issue #977)
|
|
7
|
-
// Fetch rows in batches of N for efficient processing of large result sets.
|
|
8
|
-
|
|
9
|
-
ibmdb.open(common.connectionString, function(err, conn) {
|
|
10
|
-
if(err) {
|
|
11
|
-
console.log(err);
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Clean up any leftover table from previous failed runs
|
|
16
|
-
conn.querySync("drop table fetchntab");
|
|
17
|
-
|
|
18
|
-
// Create and populate test table
|
|
19
|
-
conn.querySync("create table fetchntab (c1 int, c2 varchar(20))");
|
|
20
|
-
for(var i = 1; i <= 10; i++) {
|
|
21
|
-
conn.querySync("insert into fetchntab values (" + i + ", 'Row " + i + "')");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Test 1: fetchNSync - fetch all 10 rows in batches of 3
|
|
25
|
-
console.log("Test 1: fetchNSync in batches of 3");
|
|
26
|
-
console.log("==================================");
|
|
27
|
-
var result1 = conn.queryResultSync("select * from fetchntab order by c1");
|
|
28
|
-
var allRows = [];
|
|
29
|
-
var batch;
|
|
30
|
-
|
|
31
|
-
batch = result1.fetchNSync(3);
|
|
32
|
-
assert.equal(batch.length, 3, "First batch should have 3 rows");
|
|
33
|
-
assert.equal(batch[0].C1, 1);
|
|
34
|
-
assert.equal(batch[2].C1, 3);
|
|
35
|
-
allRows = allRows.concat(batch);
|
|
36
|
-
|
|
37
|
-
batch = result1.fetchNSync(3);
|
|
38
|
-
assert.equal(batch.length, 3, "Second batch should have 3 rows");
|
|
39
|
-
assert.equal(batch[0].C1, 4);
|
|
40
|
-
assert.equal(batch[2].C1, 6);
|
|
41
|
-
allRows = allRows.concat(batch);
|
|
42
|
-
|
|
43
|
-
batch = result1.fetchNSync(3);
|
|
44
|
-
assert.equal(batch.length, 3, "Third batch should have 3 rows");
|
|
45
|
-
assert.equal(batch[0].C1, 7);
|
|
46
|
-
assert.equal(batch[2].C1, 9);
|
|
47
|
-
allRows = allRows.concat(batch);
|
|
48
|
-
|
|
49
|
-
batch = result1.fetchNSync(3);
|
|
50
|
-
assert.equal(batch.length, 1, "Fourth batch should have 1 remaining row");
|
|
51
|
-
assert.equal(batch[0].C1, 10);
|
|
52
|
-
allRows = allRows.concat(batch);
|
|
53
|
-
|
|
54
|
-
batch = result1.fetchNSync(3);
|
|
55
|
-
assert.equal(batch.length, 0, "Fifth batch should be empty (no more rows)");
|
|
56
|
-
|
|
57
|
-
result1.closeSync();
|
|
58
|
-
assert.equal(allRows.length, 10, "Total rows should be 10");
|
|
59
|
-
console.log("All batches:", allRows.map(function(r) { return r.C1; }));
|
|
60
|
-
console.log("All rows:", allRows);
|
|
61
|
-
console.log("Test 1 passed: fetchNSync works!\n");
|
|
62
|
-
|
|
63
|
-
// Test 2: fetchN (async) with Promise
|
|
64
|
-
console.log("Test 2: fetchN (async) with Promise");
|
|
65
|
-
console.log("====================================");
|
|
66
|
-
conn.queryResult("select * from fetchntab order by c1", async function(err, result2) {
|
|
67
|
-
if(err) { console.log(err); return; }
|
|
68
|
-
|
|
69
|
-
var batch1 = await result2.fetchN(5);
|
|
70
|
-
assert.equal(batch1.length, 5, "Async batch 1 should have 5 rows");
|
|
71
|
-
assert.equal(batch1[0].C1, 1);
|
|
72
|
-
assert.equal(batch1[4].C1, 5);
|
|
73
|
-
console.log("Batch 1:", batch1.map(function(r) { return r.C1; }));
|
|
74
|
-
|
|
75
|
-
var batch2 = await result2.fetchN(5);
|
|
76
|
-
assert.equal(batch2.length, 5, "Async batch 2 should have 5 rows");
|
|
77
|
-
assert.equal(batch2[0].C1, 6);
|
|
78
|
-
assert.equal(batch2[4].C1, 10);
|
|
79
|
-
console.log("Batch 2:", batch2.map(function(r) { return r.C1; }));
|
|
80
|
-
console.log("Batch 2 rows:", batch2);
|
|
81
|
-
|
|
82
|
-
var batch3 = await result2.fetchN(5);
|
|
83
|
-
assert.equal(batch3.length, 0, "Async batch 3 should be empty");
|
|
84
|
-
|
|
85
|
-
result2.closeSync();
|
|
86
|
-
console.log("Test 2 passed: fetchN async with Promise works!\n");
|
|
87
|
-
|
|
88
|
-
// Test 3: fetchN with callback
|
|
89
|
-
console.log("Test 3: fetchN with callback");
|
|
90
|
-
console.log("============================");
|
|
91
|
-
conn.queryResult("select * from fetchntab order by c1", function(err, result3) {
|
|
92
|
-
if(err) { console.log(err); return; }
|
|
93
|
-
|
|
94
|
-
result3.fetchN(4, function(err, batch) {
|
|
95
|
-
if(err) { console.log(err); return; }
|
|
96
|
-
assert.equal(batch.length, 4, "Callback batch should have 4 rows");
|
|
97
|
-
assert.equal(batch[0].C1, 1);
|
|
98
|
-
assert.equal(batch[3].C1, 4);
|
|
99
|
-
console.log("Callback batch:", batch.map(function(r) { return r.C1; }));
|
|
100
|
-
|
|
101
|
-
result3.fetchN(100, function(err, batch2) {
|
|
102
|
-
if(err) { console.log(err); return; }
|
|
103
|
-
assert.equal(batch2.length, 6, "Remaining batch should have 6 rows");
|
|
104
|
-
console.log("Remaining batch:", batch2.map(function(r) { return r.C1; }));
|
|
105
|
-
|
|
106
|
-
result3.closeSync();
|
|
107
|
-
console.log("Test 3 passed: fetchN with callback works!\n");
|
|
108
|
-
|
|
109
|
-
// Test 4: fetchNSync with fetchMode FETCH_ARRAY (3)
|
|
110
|
-
console.log("Test 4: fetchNSync with fetchMode FETCH_ARRAY");
|
|
111
|
-
console.log("==============================================");
|
|
112
|
-
var result4 = conn.queryResultSync("select c1, c2 from fetchntab order by c1");
|
|
113
|
-
var arrBatch = result4.fetchNSync(2, {fetchMode: 3});
|
|
114
|
-
assert.equal(arrBatch.length, 2, "Array mode batch should have 2 rows");
|
|
115
|
-
assert.ok(Array.isArray(arrBatch[0]), "Row should be an array in FETCH_ARRAY mode");
|
|
116
|
-
assert.equal(arrBatch[0][0], 1);
|
|
117
|
-
assert.equal(arrBatch[1][0], 2);
|
|
118
|
-
console.log("Array mode batch:", arrBatch);
|
|
119
|
-
result4.closeSync();
|
|
120
|
-
console.log("Test 4 passed: fetchNSync with FETCH_ARRAY works!\n");
|
|
121
|
-
|
|
122
|
-
// Cleanup
|
|
123
|
-
conn.querySync("drop table fetchntab");
|
|
124
|
-
conn.closeSync();
|
|
125
|
-
console.log("All fetchN tests passed!");
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
});
|
|
1
|
+
var common = require("./common")
|
|
2
|
+
, ibmdb = require("../")
|
|
3
|
+
, assert = require("assert")
|
|
4
|
+
;
|
|
5
|
+
|
|
6
|
+
// Test fetchN (batch fetch) feature (issue #977)
|
|
7
|
+
// Fetch rows in batches of N for efficient processing of large result sets.
|
|
8
|
+
|
|
9
|
+
ibmdb.open(common.connectionString, function(err, conn) {
|
|
10
|
+
if(err) {
|
|
11
|
+
console.log(err);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Clean up any leftover table from previous failed runs
|
|
16
|
+
conn.querySync("drop table fetchntab");
|
|
17
|
+
|
|
18
|
+
// Create and populate test table
|
|
19
|
+
conn.querySync("create table fetchntab (c1 int, c2 varchar(20))");
|
|
20
|
+
for(var i = 1; i <= 10; i++) {
|
|
21
|
+
conn.querySync("insert into fetchntab values (" + i + ", 'Row " + i + "')");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Test 1: fetchNSync - fetch all 10 rows in batches of 3
|
|
25
|
+
console.log("Test 1: fetchNSync in batches of 3");
|
|
26
|
+
console.log("==================================");
|
|
27
|
+
var result1 = conn.queryResultSync("select * from fetchntab order by c1");
|
|
28
|
+
var allRows = [];
|
|
29
|
+
var batch;
|
|
30
|
+
|
|
31
|
+
batch = result1.fetchNSync(3);
|
|
32
|
+
assert.equal(batch.length, 3, "First batch should have 3 rows");
|
|
33
|
+
assert.equal(batch[0].C1, 1);
|
|
34
|
+
assert.equal(batch[2].C1, 3);
|
|
35
|
+
allRows = allRows.concat(batch);
|
|
36
|
+
|
|
37
|
+
batch = result1.fetchNSync(3);
|
|
38
|
+
assert.equal(batch.length, 3, "Second batch should have 3 rows");
|
|
39
|
+
assert.equal(batch[0].C1, 4);
|
|
40
|
+
assert.equal(batch[2].C1, 6);
|
|
41
|
+
allRows = allRows.concat(batch);
|
|
42
|
+
|
|
43
|
+
batch = result1.fetchNSync(3);
|
|
44
|
+
assert.equal(batch.length, 3, "Third batch should have 3 rows");
|
|
45
|
+
assert.equal(batch[0].C1, 7);
|
|
46
|
+
assert.equal(batch[2].C1, 9);
|
|
47
|
+
allRows = allRows.concat(batch);
|
|
48
|
+
|
|
49
|
+
batch = result1.fetchNSync(3);
|
|
50
|
+
assert.equal(batch.length, 1, "Fourth batch should have 1 remaining row");
|
|
51
|
+
assert.equal(batch[0].C1, 10);
|
|
52
|
+
allRows = allRows.concat(batch);
|
|
53
|
+
|
|
54
|
+
batch = result1.fetchNSync(3);
|
|
55
|
+
assert.equal(batch.length, 0, "Fifth batch should be empty (no more rows)");
|
|
56
|
+
|
|
57
|
+
result1.closeSync();
|
|
58
|
+
assert.equal(allRows.length, 10, "Total rows should be 10");
|
|
59
|
+
console.log("All batches:", allRows.map(function(r) { return r.C1; }));
|
|
60
|
+
console.log("All rows:", allRows);
|
|
61
|
+
console.log("Test 1 passed: fetchNSync works!\n");
|
|
62
|
+
|
|
63
|
+
// Test 2: fetchN (async) with Promise
|
|
64
|
+
console.log("Test 2: fetchN (async) with Promise");
|
|
65
|
+
console.log("====================================");
|
|
66
|
+
conn.queryResult("select * from fetchntab order by c1", async function(err, result2) {
|
|
67
|
+
if(err) { console.log(err); return; }
|
|
68
|
+
|
|
69
|
+
var batch1 = await result2.fetchN(5);
|
|
70
|
+
assert.equal(batch1.length, 5, "Async batch 1 should have 5 rows");
|
|
71
|
+
assert.equal(batch1[0].C1, 1);
|
|
72
|
+
assert.equal(batch1[4].C1, 5);
|
|
73
|
+
console.log("Batch 1:", batch1.map(function(r) { return r.C1; }));
|
|
74
|
+
|
|
75
|
+
var batch2 = await result2.fetchN(5);
|
|
76
|
+
assert.equal(batch2.length, 5, "Async batch 2 should have 5 rows");
|
|
77
|
+
assert.equal(batch2[0].C1, 6);
|
|
78
|
+
assert.equal(batch2[4].C1, 10);
|
|
79
|
+
console.log("Batch 2:", batch2.map(function(r) { return r.C1; }));
|
|
80
|
+
console.log("Batch 2 rows:", batch2);
|
|
81
|
+
|
|
82
|
+
var batch3 = await result2.fetchN(5);
|
|
83
|
+
assert.equal(batch3.length, 0, "Async batch 3 should be empty");
|
|
84
|
+
|
|
85
|
+
result2.closeSync();
|
|
86
|
+
console.log("Test 2 passed: fetchN async with Promise works!\n");
|
|
87
|
+
|
|
88
|
+
// Test 3: fetchN with callback
|
|
89
|
+
console.log("Test 3: fetchN with callback");
|
|
90
|
+
console.log("============================");
|
|
91
|
+
conn.queryResult("select * from fetchntab order by c1", function(err, result3) {
|
|
92
|
+
if(err) { console.log(err); return; }
|
|
93
|
+
|
|
94
|
+
result3.fetchN(4, function(err, batch) {
|
|
95
|
+
if(err) { console.log(err); return; }
|
|
96
|
+
assert.equal(batch.length, 4, "Callback batch should have 4 rows");
|
|
97
|
+
assert.equal(batch[0].C1, 1);
|
|
98
|
+
assert.equal(batch[3].C1, 4);
|
|
99
|
+
console.log("Callback batch:", batch.map(function(r) { return r.C1; }));
|
|
100
|
+
|
|
101
|
+
result3.fetchN(100, function(err, batch2) {
|
|
102
|
+
if(err) { console.log(err); return; }
|
|
103
|
+
assert.equal(batch2.length, 6, "Remaining batch should have 6 rows");
|
|
104
|
+
console.log("Remaining batch:", batch2.map(function(r) { return r.C1; }));
|
|
105
|
+
|
|
106
|
+
result3.closeSync();
|
|
107
|
+
console.log("Test 3 passed: fetchN with callback works!\n");
|
|
108
|
+
|
|
109
|
+
// Test 4: fetchNSync with fetchMode FETCH_ARRAY (3)
|
|
110
|
+
console.log("Test 4: fetchNSync with fetchMode FETCH_ARRAY");
|
|
111
|
+
console.log("==============================================");
|
|
112
|
+
var result4 = conn.queryResultSync("select c1, c2 from fetchntab order by c1");
|
|
113
|
+
var arrBatch = result4.fetchNSync(2, {fetchMode: 3});
|
|
114
|
+
assert.equal(arrBatch.length, 2, "Array mode batch should have 2 rows");
|
|
115
|
+
assert.ok(Array.isArray(arrBatch[0]), "Row should be an array in FETCH_ARRAY mode");
|
|
116
|
+
assert.equal(arrBatch[0][0], 1);
|
|
117
|
+
assert.equal(arrBatch[1][0], 2);
|
|
118
|
+
console.log("Array mode batch:", arrBatch);
|
|
119
|
+
result4.closeSync();
|
|
120
|
+
console.log("Test 4 passed: fetchNSync with FETCH_ARRAY works!\n");
|
|
121
|
+
|
|
122
|
+
// Cleanup
|
|
123
|
+
conn.querySync("drop table fetchntab");
|
|
124
|
+
conn.closeSync();
|
|
125
|
+
console.log("All fetchN tests passed!");
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
});
|