@miatechnet/node-odbc 2.4.10-multiresult.1 → 2.4.12
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/CHANGELOG.md +178 -178
- package/LICENSE +23 -23
- package/README.md +1314 -1314
- package/binding.gyp +100 -100
- package/lib/Connection.js +521 -521
- package/lib/Cursor.js +92 -92
- package/lib/Pool.js +470 -470
- package/lib/Statement.js +207 -207
- package/lib/odbc.d.ts +210 -210
- package/lib/odbc.js +56 -56
- package/package.json +69 -69
- package/src/dynodbc.cpp +189 -189
- package/src/dynodbc.h +383 -383
- package/src/odbc.cpp +850 -850
- package/src/odbc.h +362 -362
- package/src/odbc_connection.cpp +4312 -4312
- package/src/odbc_connection.h +114 -114
- package/src/odbc_cursor.cpp +265 -265
- package/src/odbc_cursor.h +52 -52
- package/src/odbc_statement.cpp +610 -610
- package/src/odbc_statement.h +43 -43
- package/lib/bindings/napi-v8/odbc.node +0 -0
package/lib/Cursor.js
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
class Cursor {
|
|
2
|
-
|
|
3
|
-
static CURSOR_CLOSED_ERROR = 'Cursor has already been closed!';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* An cursor created following the execution of query that is ready to return a result set
|
|
7
|
-
* @constructor
|
|
8
|
-
* @param {object} odbcCursor - an odbcCursor object, defined in src/odbc_cursor.h/.cpp
|
|
9
|
-
*/
|
|
10
|
-
constructor(odbcCursor) {
|
|
11
|
-
this.odbcCursor = odbcCursor;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Return whether or not a call to SQLFetch has returned SQL_NO_DATA
|
|
16
|
-
* @returns {boolean}
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
get noData() {
|
|
20
|
-
if (!this.odbcCursor)
|
|
21
|
-
{
|
|
22
|
-
throw new Error(Cursor.CURSOR_CLOSED_ERROR);
|
|
23
|
-
}
|
|
24
|
-
return this.odbcCursor.noData;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Calls SQL_FETCH and returns the next result set
|
|
29
|
-
* @param {function} [cb] - The callback function to return an error and a result. If the callback is ommited, a Promise is returned.
|
|
30
|
-
* @returns {undefined|Promise}
|
|
31
|
-
*/
|
|
32
|
-
fetch(cb) {
|
|
33
|
-
|
|
34
|
-
let callback = cb;
|
|
35
|
-
|
|
36
|
-
if (typeof callback !== 'function') {
|
|
37
|
-
if (!this.odbcCursor) {
|
|
38
|
-
throw new Error(Cursor.CURSOR_CLOSED_ERROR);
|
|
39
|
-
}
|
|
40
|
-
return new Promise((resolve, reject) => {
|
|
41
|
-
this.odbcCursor.fetch((error, result) => {
|
|
42
|
-
if (error) {
|
|
43
|
-
reject(error);
|
|
44
|
-
} else {
|
|
45
|
-
resolve(result);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (!this.odbcCursor) {
|
|
52
|
-
callback(new Error(Cursor.CURSOR_CLOSED_ERROR));
|
|
53
|
-
} else {
|
|
54
|
-
this.odbcCursor.fetch(callback);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Closes the cursor and the underlying SQLHSTMT, freeing all memory
|
|
60
|
-
* @param {function} [callback] - The callback function to return an error. If the callback is ommited, a Promise is returned.
|
|
61
|
-
* @returns {undefined|Promise}
|
|
62
|
-
*/
|
|
63
|
-
close(callback = undefined) {
|
|
64
|
-
|
|
65
|
-
// promise...
|
|
66
|
-
if (typeof callback !== 'function') {
|
|
67
|
-
if (!this.odbcCursor) {
|
|
68
|
-
throw new Error(Cursor.CURSOR_CLOSED_ERROR);
|
|
69
|
-
}
|
|
70
|
-
return new Promise((resolve, reject) => {
|
|
71
|
-
this.odbcCursor.close((error) => {
|
|
72
|
-
if (error) {
|
|
73
|
-
reject(error);
|
|
74
|
-
} else {
|
|
75
|
-
this.odbcCursor = null;
|
|
76
|
-
resolve();
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// ...or callback
|
|
83
|
-
this.odbcCursor.close((error) => {
|
|
84
|
-
if (!error) {
|
|
85
|
-
this.odbcCursor = null;
|
|
86
|
-
}
|
|
87
|
-
callback(error);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
module.exports.Cursor = Cursor;
|
|
1
|
+
class Cursor {
|
|
2
|
+
|
|
3
|
+
static CURSOR_CLOSED_ERROR = 'Cursor has already been closed!';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* An cursor created following the execution of query that is ready to return a result set
|
|
7
|
+
* @constructor
|
|
8
|
+
* @param {object} odbcCursor - an odbcCursor object, defined in src/odbc_cursor.h/.cpp
|
|
9
|
+
*/
|
|
10
|
+
constructor(odbcCursor) {
|
|
11
|
+
this.odbcCursor = odbcCursor;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Return whether or not a call to SQLFetch has returned SQL_NO_DATA
|
|
16
|
+
* @returns {boolean}
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
get noData() {
|
|
20
|
+
if (!this.odbcCursor)
|
|
21
|
+
{
|
|
22
|
+
throw new Error(Cursor.CURSOR_CLOSED_ERROR);
|
|
23
|
+
}
|
|
24
|
+
return this.odbcCursor.noData;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Calls SQL_FETCH and returns the next result set
|
|
29
|
+
* @param {function} [cb] - The callback function to return an error and a result. If the callback is ommited, a Promise is returned.
|
|
30
|
+
* @returns {undefined|Promise}
|
|
31
|
+
*/
|
|
32
|
+
fetch(cb) {
|
|
33
|
+
|
|
34
|
+
let callback = cb;
|
|
35
|
+
|
|
36
|
+
if (typeof callback !== 'function') {
|
|
37
|
+
if (!this.odbcCursor) {
|
|
38
|
+
throw new Error(Cursor.CURSOR_CLOSED_ERROR);
|
|
39
|
+
}
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
this.odbcCursor.fetch((error, result) => {
|
|
42
|
+
if (error) {
|
|
43
|
+
reject(error);
|
|
44
|
+
} else {
|
|
45
|
+
resolve(result);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (!this.odbcCursor) {
|
|
52
|
+
callback(new Error(Cursor.CURSOR_CLOSED_ERROR));
|
|
53
|
+
} else {
|
|
54
|
+
this.odbcCursor.fetch(callback);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Closes the cursor and the underlying SQLHSTMT, freeing all memory
|
|
60
|
+
* @param {function} [callback] - The callback function to return an error. If the callback is ommited, a Promise is returned.
|
|
61
|
+
* @returns {undefined|Promise}
|
|
62
|
+
*/
|
|
63
|
+
close(callback = undefined) {
|
|
64
|
+
|
|
65
|
+
// promise...
|
|
66
|
+
if (typeof callback !== 'function') {
|
|
67
|
+
if (!this.odbcCursor) {
|
|
68
|
+
throw new Error(Cursor.CURSOR_CLOSED_ERROR);
|
|
69
|
+
}
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
this.odbcCursor.close((error) => {
|
|
72
|
+
if (error) {
|
|
73
|
+
reject(error);
|
|
74
|
+
} else {
|
|
75
|
+
this.odbcCursor = null;
|
|
76
|
+
resolve();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ...or callback
|
|
83
|
+
this.odbcCursor.close((error) => {
|
|
84
|
+
if (!error) {
|
|
85
|
+
this.odbcCursor = null;
|
|
86
|
+
}
|
|
87
|
+
callback(error);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
module.exports.Cursor = Cursor;
|