@miatechnet/node-odbc 2.4.10-multiresult.1
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 +179 -0
- package/LICENSE +23 -0
- package/README.md +1314 -0
- package/binding.gyp +100 -0
- package/lib/Connection.js +521 -0
- package/lib/Cursor.js +92 -0
- package/lib/Pool.js +470 -0
- package/lib/Statement.js +207 -0
- package/lib/bindings/napi-v8/odbc.node +0 -0
- package/lib/odbc.d.ts +210 -0
- package/lib/odbc.js +56 -0
- package/package.json +69 -0
- package/src/dynodbc.cpp +189 -0
- package/src/dynodbc.h +383 -0
- package/src/odbc.cpp +850 -0
- package/src/odbc.h +362 -0
- package/src/odbc_connection.cpp +4312 -0
- package/src/odbc_connection.h +114 -0
- package/src/odbc_cursor.cpp +265 -0
- package/src/odbc_cursor.h +52 -0
- package/src/odbc_statement.cpp +610 -0
- package/src/odbc_statement.h +43 -0
package/lib/odbc.d.ts
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
declare namespace odbc {
|
|
2
|
+
|
|
3
|
+
class ColumnDefinition {
|
|
4
|
+
name: string;
|
|
5
|
+
dataType: number;
|
|
6
|
+
dataTypeName: string;
|
|
7
|
+
columnSize: number;
|
|
8
|
+
decimalDigits: number;
|
|
9
|
+
nullable: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
class Result<T> extends Array<T> {
|
|
13
|
+
count: number;
|
|
14
|
+
columns: Array<ColumnDefinition>;
|
|
15
|
+
statement: string;
|
|
16
|
+
parameters: Array<number|string>;
|
|
17
|
+
return: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class OdbcError {
|
|
21
|
+
message: string;
|
|
22
|
+
code: number;
|
|
23
|
+
state: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class NodeOdbcError extends Error {
|
|
27
|
+
odbcErrors: Array<OdbcError>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
class Statement {
|
|
31
|
+
|
|
32
|
+
////////////////////////////////////////////////////////////////////////////
|
|
33
|
+
// Callbacks ///////////////////////////////////////////////////////////
|
|
34
|
+
////////////////////////////////////////////////////////////////////////////
|
|
35
|
+
|
|
36
|
+
prepare(sql: string, callback: (error: NodeOdbcError) => undefined): undefined;
|
|
37
|
+
|
|
38
|
+
bind(parameters: Array<number|string>, callback: (error: NodeOdbcError) => undefined): undefined;
|
|
39
|
+
|
|
40
|
+
execute<T>(callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined;
|
|
41
|
+
|
|
42
|
+
close(callback: (error: NodeOdbcError) => undefined): undefined;
|
|
43
|
+
|
|
44
|
+
////////////////////////////////////////////////////////////////////////////
|
|
45
|
+
// Promises ////////////////////////////////////////////////////////////
|
|
46
|
+
////////////////////////////////////////////////////////////////////////////
|
|
47
|
+
|
|
48
|
+
prepare(sql: string): Promise<void>;
|
|
49
|
+
|
|
50
|
+
bind(parameters: Array<number|string>): Promise<void>;
|
|
51
|
+
|
|
52
|
+
execute<T>(): Promise<Result<T>>;
|
|
53
|
+
|
|
54
|
+
close(): Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface ConnectionParameters {
|
|
58
|
+
connectionString: string;
|
|
59
|
+
connectionTimeout?: number;
|
|
60
|
+
loginTimeout?: number;
|
|
61
|
+
}
|
|
62
|
+
interface PoolParameters {
|
|
63
|
+
connectionString: string;
|
|
64
|
+
connectionTimeout?: number;
|
|
65
|
+
loginTimeout?: number;
|
|
66
|
+
initialSize?: number;
|
|
67
|
+
incrementSize?: number;
|
|
68
|
+
maxSize?: number;
|
|
69
|
+
reuseConnections?: boolean;
|
|
70
|
+
shrink?: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface QueryOptions {
|
|
74
|
+
cursor?: boolean|string;
|
|
75
|
+
fetchSize?: number;
|
|
76
|
+
timeout?: number;
|
|
77
|
+
initialBufferSize?: number;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface CursorQueryOptions extends QueryOptions {
|
|
81
|
+
cursor: boolean|string
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
class Connection {
|
|
85
|
+
|
|
86
|
+
////////////////////////////////////////////////////////////////////////////
|
|
87
|
+
// Callbacks ///////////////////////////////////////////////////////////
|
|
88
|
+
////////////////////////////////////////////////////////////////////////////
|
|
89
|
+
query<T>(sql: string, callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined;
|
|
90
|
+
query<T>(sql: string, parameters: Array<number|string>, callback: (error: NodeOdbcError, result: Result<T> | Cursor) => undefined): undefined;
|
|
91
|
+
query<T, O extends QueryOptions>(sql: string, options: O, callback: (error: NodeOdbcError, result: O extends CursorQueryOptions ? Cursor : Result<T>) => undefined): undefined;
|
|
92
|
+
query<T, O extends QueryOptions>(sql: string, parameters: Array<number|string>, options: O, callback: (error: NodeOdbcError, result: O extends CursorQueryOptions ? Cursor : Result<T>) => undefined): undefined;
|
|
93
|
+
|
|
94
|
+
callProcedure<T>(catalog: string|null, schema: string|null, name: string, callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined;
|
|
95
|
+
callProcedure<T>(catalog: string|null, schema: string|null, name: string, parameters: Array<number|string>, callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined;
|
|
96
|
+
|
|
97
|
+
createStatement(callback: (error: NodeOdbcError, statement: Statement) => undefined): undefined;
|
|
98
|
+
|
|
99
|
+
primaryKeys<T>(catalog: string|null, schema: string|null, table: string|null, callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined;
|
|
100
|
+
|
|
101
|
+
foreignKeys<T>(pkCatalog: string|null, pkSchema: string|null, pkTable: string|null, fkCatalog: string|null, fkSchema: string|null, fkTable: string|null, callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined;
|
|
102
|
+
|
|
103
|
+
tables<T>(catalog: string|null, schema: string|null, table: string|null, type: string|null, callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined;
|
|
104
|
+
|
|
105
|
+
columns<T>(catalog: string|null, schema: string|null, table: string|null, column: string|null, callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined;
|
|
106
|
+
|
|
107
|
+
setIsolationLevel(level: number, callback: (error: NodeOdbcError) => undefined): undefined;
|
|
108
|
+
|
|
109
|
+
beginTransaction(callback: (error: NodeOdbcError) => undefined): undefined;
|
|
110
|
+
|
|
111
|
+
commit(callback: (error: NodeOdbcError) => undefined): undefined;
|
|
112
|
+
|
|
113
|
+
rollback(callback: (error: NodeOdbcError) => undefined): undefined;
|
|
114
|
+
|
|
115
|
+
close(callback: (error: NodeOdbcError) => undefined): undefined;
|
|
116
|
+
|
|
117
|
+
////////////////////////////////////////////////////////////////////////////
|
|
118
|
+
// Promises ////////////////////////////////////////////////////////////
|
|
119
|
+
////////////////////////////////////////////////////////////////////////////
|
|
120
|
+
query<T>(sql: string): Promise<Result<T>>;
|
|
121
|
+
query<T>(sql: string, parameters: Array<number|string>): Promise<Result<T>>;
|
|
122
|
+
query<T, O extends QueryOptions>(sql: string, options: O): O extends CursorQueryOptions ? Promise<Cursor> : Promise<Result<T>>;
|
|
123
|
+
query<T, O extends QueryOptions>(sql: string, parameters: Array<number|string>, options: O): O extends CursorQueryOptions ? Promise<Cursor> : Promise<Result<T>>;
|
|
124
|
+
|
|
125
|
+
callProcedure<T>(catalog: string|null, schema: string|null, name: string, parameters?: Array<number|string>): Promise<Result<T>>;
|
|
126
|
+
|
|
127
|
+
createStatement(): Promise<Statement>;
|
|
128
|
+
|
|
129
|
+
primaryKeys<T>(catalog: string|null, schema: string|null, table: string|null): Promise<Result<T>>;
|
|
130
|
+
|
|
131
|
+
foreignKeys<T>(pkCatalog: string|null, pkSchema: string|null, pkTable: string|null, fkCatalog: string|null, fkSchema: string|null, fkTable: string|null): Promise<Result<T>>;
|
|
132
|
+
|
|
133
|
+
tables<T>(catalog: string|null, schema: string|null, table: string|null, type: string|null): Promise<Result<T>>;
|
|
134
|
+
|
|
135
|
+
columns<T>(catalog: string|null, schema: string|null, table: string|null, column: string|null): Promise<Result<T>>;
|
|
136
|
+
|
|
137
|
+
setIsolationLevel(level: number): Promise<void>;
|
|
138
|
+
|
|
139
|
+
beginTransaction(): Promise<void>;
|
|
140
|
+
|
|
141
|
+
commit(): Promise<void>;
|
|
142
|
+
|
|
143
|
+
rollback(): Promise<void>;
|
|
144
|
+
|
|
145
|
+
close(): Promise<void>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
class Pool {
|
|
149
|
+
|
|
150
|
+
////////////////////////////////////////////////////////////////////////////
|
|
151
|
+
// Callbacks ///////////////////////////////////////////////////////////
|
|
152
|
+
////////////////////////////////////////////////////////////////////////////
|
|
153
|
+
connect(callback: (error: NodeOdbcError, connection: Connection) => undefined): undefined;
|
|
154
|
+
|
|
155
|
+
query<T>(sql: string, callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined;
|
|
156
|
+
query<T>(sql: string, parameters: Array<number|string>, callback: (error: NodeOdbcError, result: Result<T> | Cursor) => undefined): undefined;
|
|
157
|
+
query<T, O extends QueryOptions>(sql: string, options: O, callback: (error: NodeOdbcError, result: O extends CursorQueryOptions ? Cursor : Result<T>) => undefined): undefined;
|
|
158
|
+
query<T, O extends QueryOptions>(sql: string, parameters: Array<number|string>, options: O, callback: (error: NodeOdbcError, result: O extends CursorQueryOptions ? Cursor : Result<T>) => undefined): undefined;
|
|
159
|
+
|
|
160
|
+
close(callback: (error: NodeOdbcError) => undefined): undefined;
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
////////////////////////////////////////////////////////////////////////////
|
|
164
|
+
// Promises ////////////////////////////////////////////////////////////
|
|
165
|
+
////////////////////////////////////////////////////////////////////////////
|
|
166
|
+
connect(): Promise<Connection>;
|
|
167
|
+
|
|
168
|
+
query<T>(sql: string): Promise<Result<T>>;
|
|
169
|
+
query<T>(sql: string, parameters: Array<number|string>): Promise<Result<T>>;
|
|
170
|
+
query<T, O extends QueryOptions>(sql: string, options: O): O extends CursorQueryOptions ? Promise<Cursor> : Promise<Result<T>>;
|
|
171
|
+
query<T, O extends QueryOptions>(sql: string, parameters: Array<number|string>, options: O): O extends CursorQueryOptions ? Promise<Cursor> : Promise<Result<T>>;
|
|
172
|
+
|
|
173
|
+
close(): Promise<void>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
class Cursor {
|
|
177
|
+
noData: boolean
|
|
178
|
+
|
|
179
|
+
////////////////////////////////////////////////////////////////////////////
|
|
180
|
+
// Promises ////////////////////////////////////////////////////////////
|
|
181
|
+
////////////////////////////////////////////////////////////////////////////
|
|
182
|
+
|
|
183
|
+
fetch<T>(): Promise<Result<T>>
|
|
184
|
+
|
|
185
|
+
close(): Promise<void>
|
|
186
|
+
|
|
187
|
+
////////////////////////////////////////////////////////////////////////////
|
|
188
|
+
// Callbacks ///////////////////////////////////////////////////////////
|
|
189
|
+
////////////////////////////////////////////////////////////////////////////
|
|
190
|
+
|
|
191
|
+
fetch<T>(callback: (error: NodeOdbcError, result: Result<T>) => undefined): undefined
|
|
192
|
+
|
|
193
|
+
close(callback: (error: NodeOdbcError) => undefined): undefined
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function connect(connectionString: string, callback: (error: NodeOdbcError, connection: Connection) => undefined): undefined;
|
|
197
|
+
function connect(connectionObject: ConnectionParameters, callback: (error: NodeOdbcError, connection: Connection) => undefined): undefined;
|
|
198
|
+
|
|
199
|
+
function connect(connectionString: string): Promise<Connection>;
|
|
200
|
+
function connect(connectionObject: ConnectionParameters): Promise<Connection>;
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
function pool(connectionString: string, callback: (error: NodeOdbcError, pool: Pool) => undefined): undefined;
|
|
204
|
+
function pool(connectionObject: PoolParameters, callback: (error: NodeOdbcError, pool: Pool) => undefined): undefined;
|
|
205
|
+
|
|
206
|
+
function pool(connectionString: string): Promise<Pool>;
|
|
207
|
+
function pool(connectionObject: PoolParameters): Promise<Pool>;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export = odbc;
|
package/lib/odbc.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const binary = require('@mapbox/node-pre-gyp');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const bindingPath = binary.find(path.resolve(path.join(__dirname, '../package.json')));
|
|
5
|
+
|
|
6
|
+
const nativeOdbc = require(bindingPath);
|
|
7
|
+
|
|
8
|
+
const { Connection } = require('./Connection');
|
|
9
|
+
const { Pool } = require('./Pool');
|
|
10
|
+
|
|
11
|
+
function connect(connectionString, callback) {
|
|
12
|
+
if (typeof callback !== 'function') {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
nativeOdbc.connect(connectionString, (error, odbcConnection) => {
|
|
15
|
+
if (error) {
|
|
16
|
+
reject(error);
|
|
17
|
+
} else {
|
|
18
|
+
const connection = new Connection(odbcConnection);
|
|
19
|
+
resolve(connection);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return nativeOdbc.connect(connectionString, (error, odbcConnection) => {
|
|
26
|
+
if (!error) {
|
|
27
|
+
return callback(error, new Connection(odbcConnection));
|
|
28
|
+
}
|
|
29
|
+
return callback(error, null);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function pool(options, callback) {
|
|
34
|
+
const poolObj = new Pool(options);
|
|
35
|
+
|
|
36
|
+
if (typeof callback !== 'function') {
|
|
37
|
+
return new Promise(async (resolve, reject) => {
|
|
38
|
+
try {
|
|
39
|
+
await poolObj.init();
|
|
40
|
+
resolve(poolObj);
|
|
41
|
+
} catch(e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return poolObj.init((error) => {
|
|
48
|
+
callback(error, poolObj);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
module.exports = {
|
|
53
|
+
pool,
|
|
54
|
+
connect,
|
|
55
|
+
...nativeOdbc.odbcConstants,
|
|
56
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@miatechnet/node-odbc",
|
|
3
|
+
"description": "unixodbc bindings for node - Fork with multi-result set support for stored procedures",
|
|
4
|
+
"version": "2.4.10-multiresult.1",
|
|
5
|
+
"homepage": "https://github.com/ppimentela/node-odbc/",
|
|
6
|
+
"main": "lib/odbc.js",
|
|
7
|
+
"types": "lib/odbc.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"src/",
|
|
10
|
+
"lib/",
|
|
11
|
+
"CHANGELOG.md",
|
|
12
|
+
"binding.gyp"
|
|
13
|
+
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git://github.com/ppimentela/node-odbc.git"
|
|
17
|
+
},
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/ppimentela/node-odbc/issues"
|
|
20
|
+
},
|
|
21
|
+
"contributors": [
|
|
22
|
+
{
|
|
23
|
+
"name": "Mark Irish",
|
|
24
|
+
"email": "mirish@ibm.com"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "Dan VerWeire",
|
|
28
|
+
"email": "dverweire@gmail.com"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "Lee Smith",
|
|
32
|
+
"email": "notwink@gmail.com"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"directories": {
|
|
37
|
+
"lib": "."
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18.18.0"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "node-pre-gyp install --build-from-source",
|
|
44
|
+
"install": "node-pre-gyp install --fallback-to-build",
|
|
45
|
+
"test": "echo \"Warning: no test specified\" && exit 0"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@mapbox/node-pre-gyp": "^2.0.0",
|
|
49
|
+
"async": "^3.0.1",
|
|
50
|
+
"node-addon-api": "^3.0.2"
|
|
51
|
+
},
|
|
52
|
+
"gypfile": true,
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"dotenv": "^6.2.0",
|
|
55
|
+
"eslint": "^8.11.0",
|
|
56
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
57
|
+
"eslint-plugin-import": "^2.25.4",
|
|
58
|
+
"mocha": "^11.7.4"
|
|
59
|
+
},
|
|
60
|
+
"binary": {
|
|
61
|
+
"module_name": "odbc",
|
|
62
|
+
"module_path": "./lib/bindings/napi-v{napi_build_version}",
|
|
63
|
+
"host": "https://github.com/ppimentela/node-odbc/releases/download/v{version}",
|
|
64
|
+
"package_name": "{module_name}-v{version}-{platform}-{arch}-napi-v{napi_build_version}.tar.gz",
|
|
65
|
+
"napi_versions": [
|
|
66
|
+
8
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
}
|
package/src/dynodbc.cpp
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
#ifdef dynodbc
|
|
2
|
+
|
|
3
|
+
#include "dynodbc.h"
|
|
4
|
+
#include <stdio.h>
|
|
5
|
+
|
|
6
|
+
#ifdef _WIN32
|
|
7
|
+
#include <windows.h>
|
|
8
|
+
#elif defined(__GNUC__) // GNU compiler
|
|
9
|
+
#include <dlfcn.h>
|
|
10
|
+
#else
|
|
11
|
+
#error define your copiler
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
#include<string>
|
|
15
|
+
/*
|
|
16
|
+
#define RTLD_LAZY 1
|
|
17
|
+
#define RTLD_NOW 2
|
|
18
|
+
#define RTLD_GLOBAL 4
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
void* LoadSharedLibrary(char *pcDllname, int iMode = 2)
|
|
22
|
+
{
|
|
23
|
+
std::string sDllName = pcDllname;
|
|
24
|
+
#ifdef _WIN32
|
|
25
|
+
sDllName += ".dll";
|
|
26
|
+
return (void*)LoadLibraryA(pcDllname);
|
|
27
|
+
#elif defined(__GNUC__) // GNU compiler
|
|
28
|
+
sDllName += ".so";
|
|
29
|
+
void* handle = dlopen(sDllName.c_str(),iMode);
|
|
30
|
+
|
|
31
|
+
if (!handle) {
|
|
32
|
+
printf("node-odbc: error loading ODBC library: %s\n", dlerror());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return handle;
|
|
36
|
+
#endif
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
void* GetFunction(void *Lib, char *Fnname)
|
|
40
|
+
{
|
|
41
|
+
#if defined(_MSC_VER) // Microsoft compiler
|
|
42
|
+
return (void*)GetProcAddress((HINSTANCE)Lib,Fnname);
|
|
43
|
+
#elif defined(__GNUC__) // GNU compiler
|
|
44
|
+
void * tmp = dlsym(Lib, Fnname);
|
|
45
|
+
if (!tmp) {
|
|
46
|
+
printf("node-odbc: error loading function: %s\n", Fnname);
|
|
47
|
+
}
|
|
48
|
+
return tmp;
|
|
49
|
+
#endif
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
bool FreeSharedLibrary(void *hDLL)
|
|
53
|
+
{
|
|
54
|
+
#if defined(_MSC_VER) // Microsoft compiler
|
|
55
|
+
return (FreeLibrary((HINSTANCE)hDLL)!=0);
|
|
56
|
+
#elif defined(__GNUC__) // GNU compiler
|
|
57
|
+
return dlclose(hDLL);
|
|
58
|
+
#endif
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
pfnSQLGetData pSQLGetData;
|
|
62
|
+
pfnSQLGetFunctions pSQLGetFunctions;
|
|
63
|
+
pfnSQLAllocConnect pSQLAllocConnect;
|
|
64
|
+
pfnSQLAllocEnv pSQLAllocEnv;
|
|
65
|
+
pfnSQLAllocStmt pSQLAllocStmt;
|
|
66
|
+
pfnSQLBindCol pSQLBindCol;
|
|
67
|
+
pfnSQLCancel pSQLCancel;
|
|
68
|
+
pfnSQLColAttributes pSQLColAttributes;
|
|
69
|
+
pfnSQLConnect pSQLConnect;
|
|
70
|
+
pfnSQLDescribeCol pSQLDescribeCol;
|
|
71
|
+
pfnSQLDisconnect pSQLDisconnect;
|
|
72
|
+
pfnSQLError pSQLError;
|
|
73
|
+
pfnSQLExecDirect pSQLExecDirect;
|
|
74
|
+
pfnSQLExecute pSQLExecute;
|
|
75
|
+
pfnSQLFetch pSQLFetch;
|
|
76
|
+
pfnSQLGetDiagRec pSQLGetDiagRec;
|
|
77
|
+
pfnSQLGetDiagField pSQLGetDiagField;
|
|
78
|
+
pfnSQLFreeHandle pSQLFreeHandle;
|
|
79
|
+
pfnSQLFetchScroll pSQLFetchScroll;
|
|
80
|
+
pfnSQLColAttribute pSQLColAttribute;
|
|
81
|
+
pfnSQLSetConnectAttr pSQLSetConnectAttr;
|
|
82
|
+
pfnSQLDriverConnect pSQLDriverConnect;
|
|
83
|
+
pfnSQLAllocHandle pSQLAllocHandle;
|
|
84
|
+
pfnSQLRowCount pSQLRowCount;
|
|
85
|
+
pfnSQLNumResultCols pSQLNumResultCols;
|
|
86
|
+
pfnSQLEndTran pSQLEndTran;
|
|
87
|
+
pfnSQLTables pSQLTables;
|
|
88
|
+
pfnSQLColumns pSQLColumns;
|
|
89
|
+
pfnSQLBindParameter pSQLBindParameter;
|
|
90
|
+
pfnSQLPrimaryKeys pSQLPrimaryKeys;
|
|
91
|
+
pfnSQLSetEnvAttr pSQLSetEnvAttr ;
|
|
92
|
+
pfnSQLFreeConnect pSQLFreeConnect;
|
|
93
|
+
pfnSQLFreeEnv pSQLFreeEnv;
|
|
94
|
+
pfnSQLFreeStmt pSQLFreeStmt;
|
|
95
|
+
pfnSQLGetCursorName pSQLGetCursorName;
|
|
96
|
+
pfnSQLPrepare pSQLPrepare;
|
|
97
|
+
pfnSQLSetCursorName pSQLSetCursorName;
|
|
98
|
+
pfnSQLTransact pSQLTransact;
|
|
99
|
+
pfnSQLSetConnectOption pSQLSetConnectOption;
|
|
100
|
+
pfnSQLDrivers pSQLDrivers;
|
|
101
|
+
pfnSQLDataSources pSQLDataSources;
|
|
102
|
+
pfnSQLGetInfo pSQLGetInfo;
|
|
103
|
+
pfnSQLMoreResults pSQLMoreResults;
|
|
104
|
+
|
|
105
|
+
//#define LOAD_ENTRY( hMod, Name ) (p##Name = (pfn##Name) GetProcAddress( (hMod), #Name ))
|
|
106
|
+
#define LOAD_ENTRY( hMod, Name ) (p##Name = (pfn##Name) GetFunction( (hMod), #Name ))
|
|
107
|
+
|
|
108
|
+
static BOOL s_fODBCLoaded = false;
|
|
109
|
+
|
|
110
|
+
BOOL DynLoadODBC( char* odbcModuleName )
|
|
111
|
+
{
|
|
112
|
+
#ifdef _WIN32
|
|
113
|
+
HMODULE hMod;
|
|
114
|
+
#elif defined(__GNUC__) // GNU compiler
|
|
115
|
+
void* hMod;
|
|
116
|
+
#endif
|
|
117
|
+
|
|
118
|
+
if ( s_fODBCLoaded )
|
|
119
|
+
return true;
|
|
120
|
+
|
|
121
|
+
// if ( (hMod = (HMODULE) LoadLibrary( odbcModuleName ))) {
|
|
122
|
+
#ifdef _WIN32
|
|
123
|
+
if ( (hMod = (HMODULE) LoadSharedLibrary( odbcModuleName ))) {
|
|
124
|
+
#elif defined(__GNUC__) // GNU compiler
|
|
125
|
+
if ( (hMod = (void *) LoadSharedLibrary( odbcModuleName ))) {
|
|
126
|
+
#endif
|
|
127
|
+
|
|
128
|
+
//#if (ODBCVER < 0x0300)
|
|
129
|
+
if (LOAD_ENTRY( hMod, SQLGetData ) )
|
|
130
|
+
if (LOAD_ENTRY( hMod, SQLGetFunctions ) )
|
|
131
|
+
//Unused-> if (LOAD_ENTRY( hMod, SQLAllocConnect ) )
|
|
132
|
+
//Unused-> if (LOAD_ENTRY( hMod, SQLAllocEnv ) )
|
|
133
|
+
//Unused-> if (LOAD_ENTRY( hMod, SQLAllocStmt ) )
|
|
134
|
+
//Unused-> if (LOAD_ENTRY( hMod, SQLColAttributes ) )
|
|
135
|
+
//Unused-> if (LOAD_ENTRY( hMod, SQLError ) )
|
|
136
|
+
//Unused-> if (LOAD_ENTRY( hMod, SQLFreeConnect ) )
|
|
137
|
+
//Unused-> if (LOAD_ENTRY( hMod, SQLFreeEnv ) )
|
|
138
|
+
//Unused-> if (LOAD_ENTRY( hMod, SQLTransact ) )
|
|
139
|
+
//Unused-> if (LOAD_ENTRY( hMod, SQLSetConnectOption ) )
|
|
140
|
+
/*
|
|
141
|
+
* NOTE: This is commented out because it wouldn't be used
|
|
142
|
+
* in a direct-to-driver situation and we currently never
|
|
143
|
+
* call SQLDrivers. But if we ever do we may need to have
|
|
144
|
+
* some type of flag to determine if we should try to load
|
|
145
|
+
* this function if the user is not doing a direct-to-driver
|
|
146
|
+
* and is specifying a specific libodbc library.
|
|
147
|
+
*/
|
|
148
|
+
//Unused-> if (LOAD_ENTRY( hMod, SQLDrivers ) )
|
|
149
|
+
|
|
150
|
+
//Unused-> if (LOAD_ENTRY( hMod, SQLDataSources ) )
|
|
151
|
+
//#endif
|
|
152
|
+
//Unused-> if (LOAD_ENTRY( hMod, SQLBindCol ) )
|
|
153
|
+
//Unused-> if (LOAD_ENTRY( hMod, SQLCancel ) )
|
|
154
|
+
//Unused-> if (LOAD_ENTRY( hMod, SQLConnect ) )
|
|
155
|
+
//Unused-> if (LOAD_ENTRY( hMod, SQLDescribeCol ) )
|
|
156
|
+
if (LOAD_ENTRY( hMod, SQLDisconnect ) )
|
|
157
|
+
if (LOAD_ENTRY( hMod, SQLExecDirect ) )
|
|
158
|
+
if (LOAD_ENTRY( hMod, SQLExecute ) )
|
|
159
|
+
if (LOAD_ENTRY( hMod, SQLFetch ) )
|
|
160
|
+
if (LOAD_ENTRY( hMod, SQLGetDiagRec ) )
|
|
161
|
+
if (LOAD_ENTRY( hMod, SQLGetDiagField ) )
|
|
162
|
+
if (LOAD_ENTRY( hMod, SQLFreeHandle ) )
|
|
163
|
+
//Unused-> if (LOAD_ENTRY( hMod, SQLFetchScroll ) )
|
|
164
|
+
if (LOAD_ENTRY( hMod, SQLColAttribute ) )
|
|
165
|
+
if (LOAD_ENTRY( hMod, SQLSetConnectAttr ) )
|
|
166
|
+
if (LOAD_ENTRY( hMod, SQLDriverConnect ) )
|
|
167
|
+
if (LOAD_ENTRY( hMod, SQLAllocHandle ) )
|
|
168
|
+
if (LOAD_ENTRY( hMod, SQLRowCount ) )
|
|
169
|
+
if (LOAD_ENTRY( hMod, SQLNumResultCols ) )
|
|
170
|
+
if (LOAD_ENTRY( hMod, SQLEndTran ) )
|
|
171
|
+
if (LOAD_ENTRY( hMod, SQLTables ) )
|
|
172
|
+
if (LOAD_ENTRY( hMod, SQLColumns ) )
|
|
173
|
+
if (LOAD_ENTRY( hMod, SQLBindParameter ) )
|
|
174
|
+
//Unused-> if (LOAD_ENTRY( hMod, SQLPrimaryKeys) )
|
|
175
|
+
if (LOAD_ENTRY( hMod, SQLSetEnvAttr ) )
|
|
176
|
+
if (LOAD_ENTRY( hMod, SQLFreeStmt ) )
|
|
177
|
+
if (LOAD_ENTRY( hMod, SQLPrepare ) )
|
|
178
|
+
//Unused-> if (LOAD_ENTRY( hMod, SQLGetInfo ) )
|
|
179
|
+
if (LOAD_ENTRY( hMod, SQLBindParameter ) )
|
|
180
|
+
if (LOAD_ENTRY( hMod, SQLMoreResults )
|
|
181
|
+
) {
|
|
182
|
+
|
|
183
|
+
s_fODBCLoaded = true;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return (s_fODBCLoaded);
|
|
188
|
+
}
|
|
189
|
+
#endif
|