vsql-node 0.0.0-stage → 1.0.0
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/LICENSE +21 -0
- package/README.md +203 -2
- package/binding.gyp +61 -0
- package/index.d.ts +133 -0
- package/internal/amalgamation/LICENSE +21 -0
- package/internal/amalgamation/LICENSE-V +21 -0
- package/internal/amalgamation/afunix.h +26 -0
- package/internal/amalgamation/atomic.h +571 -0
- package/internal/amalgamation/core_windows.c +25 -0
- package/internal/amalgamation/core_windows.h +9 -0
- package/internal/amalgamation/execute_capture_nix.c +7 -0
- package/internal/amalgamation/execute_capture_nix.h +266 -0
- package/internal/amalgamation/gc/cord.h +426 -0
- package/internal/amalgamation/gc/cord_pos.h +151 -0
- package/internal/amalgamation/gc/ec.h +91 -0
- package/internal/amalgamation/gc/gc.h +2826 -0
- package/internal/amalgamation/gc/gc_allocator.h +480 -0
- package/internal/amalgamation/gc/gc_backptr.h +109 -0
- package/internal/amalgamation/gc/gc_config_macros.h +548 -0
- package/internal/amalgamation/gc/gc_disclaim.h +85 -0
- package/internal/amalgamation/gc/gc_gcj.h +123 -0
- package/internal/amalgamation/gc/gc_inline.h +261 -0
- package/internal/amalgamation/gc/gc_mark.h +516 -0
- package/internal/amalgamation/gc/gc_pthread_redirects.h +140 -0
- package/internal/amalgamation/gc/gc_tiny_fl.h +107 -0
- package/internal/amalgamation/gc/gc_typed.h +196 -0
- package/internal/amalgamation/gc/gc_version.h +55 -0
- package/internal/amalgamation/gc/javaxfc.h +76 -0
- package/internal/amalgamation/gc/leak_detector.h +120 -0
- package/internal/amalgamation/gc.c +45932 -0
- package/internal/amalgamation/gc.h +4 -0
- package/internal/amalgamation/gc_boehm_helpers.c +64 -0
- package/internal/amalgamation/gc_debugger_linux.h +61 -0
- package/internal/amalgamation/getrandom_linux.h +33 -0
- package/internal/amalgamation/ipv6_v6only.h +5 -0
- package/internal/amalgamation/libvsql.c +27 -0
- package/internal/amalgamation/libvsql.h +1772 -0
- package/internal/amalgamation/libvsql_linux_amd64.c +106591 -0
- package/internal/amalgamation/libvsql_linux_arm64.c +106571 -0
- package/internal/amalgamation/libvsql_macos_amd64.c +106728 -0
- package/internal/amalgamation/libvsql_macos_arm64.c +106708 -0
- package/internal/amalgamation/libvsql_windows_amd64.c +108235 -0
- package/internal/amalgamation/segfault_handler_nix.c +56 -0
- package/internal/amalgamation/segfault_handler_nix.h +449 -0
- package/internal/amalgamation/segfault_handler_windows.h +52 -0
- package/internal/amalgamation/thread_helper.c +12 -0
- package/internal/amalgamation/thread_helper.h +96 -0
- package/internal/amalgamation/ticks_windows.c +3 -0
- package/internal/amalgamation/ticks_windows.h +31 -0
- package/internal/amalgamation/ticks_windows_api.h +6 -0
- package/internal/amalgamation/vsql_runtime.c +14 -0
- package/internal/amalgamation/vsql_runtime_linux.c +6 -0
- package/internal/amalgamation/vsql_runtime_macos.c +6 -0
- package/internal/amalgamation/vsql_runtime_windows.c +6 -0
- package/lib/binding.js +13 -0
- package/lib/connection.js +492 -0
- package/lib/convert.js +213 -0
- package/lib/errors.js +17 -0
- package/lib/index.js +41 -0
- package/libvsql_flags.gypi +30 -0
- package/package.json +45 -4
- package/prebuilds/darwin-arm64/vsql-node.glibc.node +0 -0
- package/prebuilds/darwin-x64/vsql-node.glibc.node +0 -0
- package/prebuilds/linux-arm64/vsql-node.glibc.node +0 -0
- package/prebuilds/linux-x64/vsql-node.glibc.node +0 -0
- package/prebuilds/win32-x64/vsql-node.glibc.node +0 -0
- package/src/binding.c +773 -0
- package/src/runtime.c +20 -0
|
@@ -0,0 +1,1772 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* libvsql.h declares the SQL/CLI (ISO/IEC 9075-3) routines implemented by
|
|
3
|
+
* libvsql, the shared library for using vsql from C (and any language that can
|
|
4
|
+
* call C functions). The types and codes are the ones from Annex A, "Typical
|
|
5
|
+
* header files". The routines that aren't implemented yet are listed in
|
|
6
|
+
* https://vsql.readthedocs.io/en/latest/sql-compliance.html#cli-routines
|
|
7
|
+
*
|
|
8
|
+
* This header is C99, and also works with C++11.
|
|
9
|
+
*
|
|
10
|
+
* Project: https://github.com/elliotchance/vsql
|
|
11
|
+
* Releases: https://github.com/elliotchance/vsql/releases
|
|
12
|
+
* Docs: https://vsql.readthedocs.io/en/latest/language-c.html
|
|
13
|
+
* Issues: https://github.com/elliotchance/vsql/issues
|
|
14
|
+
*
|
|
15
|
+
* A complete program (error handling is left out, see SQLGetDiagRec):
|
|
16
|
+
*
|
|
17
|
+
* #include <stdio.h>
|
|
18
|
+
*
|
|
19
|
+
* #include "libvsql.h"
|
|
20
|
+
*
|
|
21
|
+
* int main(void) {
|
|
22
|
+
* SQLHENV env;
|
|
23
|
+
* SQLHDBC dbc;
|
|
24
|
+
* SQLHSTMT stmt;
|
|
25
|
+
* SQLDOUBLE x;
|
|
26
|
+
*
|
|
27
|
+
* SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
|
|
28
|
+
* SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
|
|
29
|
+
* SQLConnect(dbc, (SQLCHAR *)":memory:", SQL_NTS, NULL, 0, NULL, 0);
|
|
30
|
+
* SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
|
|
31
|
+
*
|
|
32
|
+
* SQLExecDirect(stmt, (SQLCHAR *)"CREATE TABLE foo (x DOUBLE PRECISION)",
|
|
33
|
+
* SQL_NTS);
|
|
34
|
+
* SQLExecDirect(stmt, (SQLCHAR *)"INSERT INTO foo (x) VALUES (1.23)",
|
|
35
|
+
* SQL_NTS);
|
|
36
|
+
* SQLEndTran(SQL_HANDLE_DBC, dbc, SQL_COMMIT);
|
|
37
|
+
*
|
|
38
|
+
* SQLExecDirect(stmt, (SQLCHAR *)"SELECT * FROM foo", SQL_NTS);
|
|
39
|
+
* while (SQLFetch(stmt) == SQL_SUCCESS) {
|
|
40
|
+
* SQLGetData(stmt, 1, SQL_DOUBLE, &x, 0, NULL);
|
|
41
|
+
* printf("%g\n", x);
|
|
42
|
+
* }
|
|
43
|
+
* SQLCloseCursor(stmt);
|
|
44
|
+
* SQLEndTran(SQL_HANDLE_DBC, dbc, SQL_COMMIT);
|
|
45
|
+
*
|
|
46
|
+
* SQLFreeHandle(SQL_HANDLE_STMT, stmt);
|
|
47
|
+
* SQLDisconnect(dbc);
|
|
48
|
+
* SQLFreeHandle(SQL_HANDLE_DBC, dbc);
|
|
49
|
+
* SQLFreeHandle(SQL_HANDLE_ENV, env);
|
|
50
|
+
*
|
|
51
|
+
* return 0;
|
|
52
|
+
* }
|
|
53
|
+
*
|
|
54
|
+
* From the folder of a release, build it with (on Windows, use gcc from MinGW,
|
|
55
|
+
* -Lbin instead of -Llib and leave out the -rpath):
|
|
56
|
+
*
|
|
57
|
+
* cc example.c -Iinclude -Llib -lvsql -Wl,-rpath,"$PWD/lib" -o example
|
|
58
|
+
*
|
|
59
|
+
* Threads
|
|
60
|
+
*
|
|
61
|
+
* The routines can be called from any thread, including threads that weren't
|
|
62
|
+
* created by libvsql (such as the threads of a Go program). Each environment
|
|
63
|
+
* (SQL_HANDLE_ENV) is its own SQL-agent: its routines run one at a time, and it
|
|
64
|
+
* has its own current connection, so a connection in one environment can have
|
|
65
|
+
* an active transaction while a connection in another environment is used. Use
|
|
66
|
+
* an environment for each thread (or each connection) that's used at the same
|
|
67
|
+
* time as the others. Connections to the same file share a lock, so they can
|
|
68
|
+
* be used at the same time.
|
|
69
|
+
*
|
|
70
|
+
* Data types
|
|
71
|
+
*
|
|
72
|
+
* Each vsql data type, the DataType from SQLDescribeCol, and the TargetTypes
|
|
73
|
+
* that SQLGetData can retrieve it as:
|
|
74
|
+
*
|
|
75
|
+
* SMALLINT SQL_SMALLINT numbers, SQL_CHAR
|
|
76
|
+
* INTEGER SQL_INTEGER numbers, SQL_CHAR
|
|
77
|
+
* BIGINT SQL_BIGINT numbers, SQL_CHAR
|
|
78
|
+
* REAL SQL_REAL numbers, SQL_CHAR
|
|
79
|
+
* DOUBLE PRECISION, FLOAT SQL_DOUBLE numbers, SQL_CHAR
|
|
80
|
+
* DECIMAL SQL_DECIMAL numbers, SQL_CHAR
|
|
81
|
+
* NUMERIC SQL_NUMERIC numbers, SQL_CHAR
|
|
82
|
+
* CHARACTER SQL_CHAR SQL_CHAR
|
|
83
|
+
* CHARACTER VARYING SQL_VARCHAR SQL_CHAR
|
|
84
|
+
* BOOLEAN SQL_BOOLEAN SQL_CHAR
|
|
85
|
+
* DATE SQL_TYPE_DATE SQL_CHAR
|
|
86
|
+
* TIME SQL_TYPE_TIME SQL_CHAR
|
|
87
|
+
* TIME WITH TIME ZONE SQL_TYPE_TIME_WITH_TIMEZONE SQL_CHAR
|
|
88
|
+
* TIMESTAMP SQL_TYPE_TIMESTAMP SQL_CHAR
|
|
89
|
+
* TIMESTAMP WITH TIME ZONE SQL_TYPE_TIMESTAMP_WITH_TIMEZONE SQL_CHAR
|
|
90
|
+
*
|
|
91
|
+
* "numbers" is SQL_SMALLINT, SQL_INTEGER, SQL_BIGINT, SQL_REAL or SQL_DOUBLE
|
|
92
|
+
* (a value out of range is 22003). SQL_DEFAULT retrieves a column as its own
|
|
93
|
+
* type, so it only works for the types that have a C type (SMALLINT, INTEGER,
|
|
94
|
+
* BIGINT, REAL, DOUBLE PRECISION and CHARACTER), otherwise it's 07002.
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
#ifndef LIBVSQL_H
|
|
98
|
+
#define LIBVSQL_H
|
|
99
|
+
|
|
100
|
+
#include <stdint.h>
|
|
101
|
+
|
|
102
|
+
#ifdef __cplusplus
|
|
103
|
+
extern "C" {
|
|
104
|
+
#endif
|
|
105
|
+
|
|
106
|
+
/*
|
|
107
|
+
* The standard makes SQLINTEGER a C long, but a long is 64 bits on macOS and
|
|
108
|
+
* Linux and 32 bits on Windows. These have the same width on every platform
|
|
109
|
+
* instead (the same as ODBC), so a binding from another language (such as Go)
|
|
110
|
+
* doesn't depend on the platform.
|
|
111
|
+
*/
|
|
112
|
+
typedef unsigned char SQLCHAR;
|
|
113
|
+
typedef int16_t SQLSMALLINT;
|
|
114
|
+
typedef int32_t SQLINTEGER;
|
|
115
|
+
typedef float SQLREAL;
|
|
116
|
+
typedef double SQLDOUBLE;
|
|
117
|
+
typedef void *SQLPOINTER;
|
|
118
|
+
|
|
119
|
+
typedef int64_t SQLBIGINT;
|
|
120
|
+
|
|
121
|
+
typedef SQLSMALLINT SQLRETURN;
|
|
122
|
+
|
|
123
|
+
/* Handles are integers that identify an allocated resource. */
|
|
124
|
+
typedef SQLINTEGER SQLHENV;
|
|
125
|
+
typedef SQLINTEGER SQLHDBC;
|
|
126
|
+
typedef SQLINTEGER SQLHSTMT;
|
|
127
|
+
typedef SQLINTEGER SQLHDESC;
|
|
128
|
+
|
|
129
|
+
/* Special length/indicator values. */
|
|
130
|
+
#define SQL_NULL_DATA (-1) /* the value is NULL */
|
|
131
|
+
#define SQL_NTS (-3) /* a null terminated string */
|
|
132
|
+
#define SQL_DATA_AT_EXEC (-2) /* given with SQLPutData */
|
|
133
|
+
|
|
134
|
+
/* Return codes. */
|
|
135
|
+
#define SQL_SUCCESS 0 /* completed */
|
|
136
|
+
#define SQL_SUCCESS_WITH_INFO 1 /* completed with a warning */
|
|
137
|
+
#define SQL_NEED_DATA 99 /* see SQLParamData */
|
|
138
|
+
#define SQL_NO_DATA 100 /* no more rows or records */
|
|
139
|
+
#define SQL_ERROR (-1) /* failed, see SQLGetDiagRec */
|
|
140
|
+
#define SQL_INVALID_HANDLE (-2) /* not an allocated handle */
|
|
141
|
+
|
|
142
|
+
/* Handle types. */
|
|
143
|
+
#define SQL_HANDLE_ENV 1 /* an environment */
|
|
144
|
+
#define SQL_HANDLE_DBC 2 /* a connection */
|
|
145
|
+
#define SQL_HANDLE_STMT 3 /* a statement */
|
|
146
|
+
#define SQL_HANDLE_DESC 4 /* a descriptor */
|
|
147
|
+
#define SQL_NULL_HANDLE 0L /* no handle */
|
|
148
|
+
|
|
149
|
+
/* Data type codes. */
|
|
150
|
+
#define SQL_CHAR 1 /* CHARACTER, or a C string */
|
|
151
|
+
#define SQL_NUMERIC 2 /* NUMERIC */
|
|
152
|
+
#define SQL_DECIMAL 3 /* DECIMAL */
|
|
153
|
+
#define SQL_INTEGER 4 /* INTEGER, or SQLINTEGER */
|
|
154
|
+
#define SQL_SMALLINT 5 /* SMALLINT, or SQLSMALLINT */
|
|
155
|
+
#define SQL_FLOAT 6 /* FLOAT, see SQL_DOUBLE */
|
|
156
|
+
#define SQL_REAL 7 /* REAL, or SQLREAL */
|
|
157
|
+
#define SQL_DOUBLE 8 /* DOUBLE PRECISION, SQLDOUBLE */
|
|
158
|
+
#define SQL_DATETIME 9 /* any datetime type */
|
|
159
|
+
#define SQL_VARCHAR 12 /* CHARACTER VARYING */
|
|
160
|
+
#define SQL_BOOLEAN 16 /* BOOLEAN */
|
|
161
|
+
#define SQL_BIGINT 25 /* BIGINT, or SQLBIGINT */
|
|
162
|
+
|
|
163
|
+
/* SQL_DESC_DATETIME_INTERVAL_CODEs of SQL_DATETIME. */
|
|
164
|
+
#define SQL_CODE_DATE 1 /* DATE */
|
|
165
|
+
#define SQL_CODE_TIME 2 /* TIME */
|
|
166
|
+
#define SQL_CODE_TIMESTAMP 3 /* TIMESTAMP */
|
|
167
|
+
#define SQL_CODE_TIME_ZONE 4 /* TIME WITH TIME ZONE */
|
|
168
|
+
#define SQL_CODE_TIMESTAMP_ZONE 5 /* TIMESTAMP WITH TIME ZONE */
|
|
169
|
+
|
|
170
|
+
/* Concise codes for datetime data types. */
|
|
171
|
+
#define SQL_TYPE_DATE 91 /* DATE */
|
|
172
|
+
#define SQL_TYPE_TIME 92 /* TIME */
|
|
173
|
+
#define SQL_TYPE_TIMESTAMP 93 /* TIMESTAMP */
|
|
174
|
+
#define SQL_TYPE_TIME_WITH_TIMEZONE 94 /* TIME WITH TIME ZONE */
|
|
175
|
+
#define SQL_TYPE_TIMESTAMP_WITH_TIMEZONE 95 /* TIMESTAMP WITH TIME ZONE */
|
|
176
|
+
|
|
177
|
+
/* Special TargetType values for SQLGetData. */
|
|
178
|
+
#define SQL_ARD_TYPE (-99) /* the type in the ARD */
|
|
179
|
+
#define SQL_DEFAULT 99 /* the type of the column */
|
|
180
|
+
|
|
181
|
+
/* Header fields for SQLGetDiagField. */
|
|
182
|
+
#define SQL_DIAG_RETURNCODE 1 /* the return code */
|
|
183
|
+
#define SQL_DIAG_NUMBER 2 /* the number of records */
|
|
184
|
+
#define SQL_DIAG_ROW_COUNT 3 /* see SQLRowCount */
|
|
185
|
+
#define SQL_DIAG_DYNAMIC_FUNCTION 7 /* the statement executed */
|
|
186
|
+
#define SQL_DIAG_DYNAMIC_FUNCTION_CODE 12 /* the code of the statement */
|
|
187
|
+
#define SQL_DIAG_MORE 13 /* always 0 */
|
|
188
|
+
#define SQL_DIAG_TRANSACTIONS_COMMITTED 34 /* transactions committed */
|
|
189
|
+
#define SQL_DIAG_TRANSACTIONS_ROLLED_BACK 35 /* transactions rolled back */
|
|
190
|
+
#define SQL_DIAG_TRANSACTION_ACTIVE 36 /* 1 if one is active */
|
|
191
|
+
|
|
192
|
+
/* Record fields for SQLGetDiagField. */
|
|
193
|
+
#define SQL_DIAG_SQLSTATE 4 /* the SQLSTATE */
|
|
194
|
+
#define SQL_DIAG_NATIVE_CODE 5 /* always 0 */
|
|
195
|
+
#define SQL_DIAG_MESSAGE_TEXT 6 /* the message */
|
|
196
|
+
#define SQL_DIAG_CLASS_ORIGIN 8 /* who defined the class */
|
|
197
|
+
#define SQL_DIAG_SUBCLASS_ORIGIN 9 /* and the subclass */
|
|
198
|
+
#define SQL_DIAG_CONNECTION_NAME 10 /* the ServerName */
|
|
199
|
+
#define SQL_DIAG_SERVER_NAME 11 /* the ServerName */
|
|
200
|
+
#define SQL_DIAG_CONDITION_NUMBER 14 /* the record number */
|
|
201
|
+
#define SQL_DIAG_CONSTRAINT_CATALOG 15 /* always "" */
|
|
202
|
+
#define SQL_DIAG_CONSTRAINT_SCHEMA 16 /* always "" */
|
|
203
|
+
#define SQL_DIAG_CONSTRAINT_NAME 17 /* always "" */
|
|
204
|
+
#define SQL_DIAG_CATALOG_NAME 18 /* always "" */
|
|
205
|
+
#define SQL_DIAG_SCHEMA_NAME 19 /* always "" */
|
|
206
|
+
#define SQL_DIAG_TABLE_NAME 20 /* always "" */
|
|
207
|
+
#define SQL_DIAG_COLUMN_NAME 21 /* always "" */
|
|
208
|
+
#define SQL_DIAG_CURSOR_NAME 22 /* always "" */
|
|
209
|
+
#define SQL_DIAG_MESSAGE_LENGTH 23 /* in characters */
|
|
210
|
+
#define SQL_DIAG_MESSAGE_OCTET_LENGTH 24 /* in octets */
|
|
211
|
+
#define SQL_DIAG_CONDITION_IDENTIFIER 25 /* always "" */
|
|
212
|
+
#define SQL_DIAG_PARAMETER_NAME 26 /* always "" */
|
|
213
|
+
#define SQL_DIAG_ROUTINE_CATALOG 27 /* always "" */
|
|
214
|
+
#define SQL_DIAG_ROUTINE_SCHEMA 28 /* always "" */
|
|
215
|
+
#define SQL_DIAG_ROUTINE_NAME 29 /* always "" */
|
|
216
|
+
#define SQL_DIAG_SPECIFIC_NAME 30 /* always "" */
|
|
217
|
+
#define SQL_DIAG_TRIGGER_CATALOG 31 /* always "" */
|
|
218
|
+
#define SQL_DIAG_TRIGGER_SCHEMA 32 /* always "" */
|
|
219
|
+
#define SQL_DIAG_TRIGGER_NAME 33 /* always "" */
|
|
220
|
+
#define SQL_DIAG_PARAMETER_MODE 37 /* always "" */
|
|
221
|
+
#define SQL_DIAG_PARAMETER_ORDINAL_POSITION 38 /* always 0 */
|
|
222
|
+
#define SQL_DIAG_ROW_NUMBER (-1248) /* the row, or 0 */
|
|
223
|
+
#define SQL_DIAG_COLUMN_NUMBER (-1247) /* the column, or 0 */
|
|
224
|
+
|
|
225
|
+
/* SQL_DIAG_DYNAMIC_FUNCTION_CODEs. The other statements have the codes from
|
|
226
|
+
* ISO/IEC 9075-2: ALTER SEQUENCE (134), COMMIT WORK (11), CREATE SEQUENCE
|
|
227
|
+
* (133), DROP SEQUENCE (135), ROLLBACK WORK (62) and START TRANSACTION (111).
|
|
228
|
+
* EXPLAIN is -1. */
|
|
229
|
+
#define SQL_DIAG_UNKNOWN_STATEMENT 0 /* no statement */
|
|
230
|
+
#define SQL_DIAG_ALTER_TABLE 4 /* ALTER TABLE */
|
|
231
|
+
#define SQL_DIAG_DELETE_WHERE 19 /* DELETE */
|
|
232
|
+
#define SQL_DIAG_DROP_SCHEMA 31 /* DROP SCHEMA */
|
|
233
|
+
#define SQL_DIAG_DROP_TABLE 32 /* DROP TABLE */
|
|
234
|
+
#define SQL_DIAG_INSERT 50 /* INSERT */
|
|
235
|
+
#define SQL_DIAG_CREATE_SCHEMA 64 /* CREATE SCHEMA */
|
|
236
|
+
#define SQL_DIAG_SET_CATALOG 66 /* SET CATALOG */
|
|
237
|
+
#define SQL_DIAG_SET_SCHEMA 74 /* SET SCHEMA */
|
|
238
|
+
#define SQL_DIAG_CREATE_TABLE 77 /* CREATE TABLE */
|
|
239
|
+
#define SQL_DIAG_UPDATE_WHERE 82 /* UPDATE */
|
|
240
|
+
#define SQL_DIAG_SELECT_CURSOR 85 /* a query */
|
|
241
|
+
|
|
242
|
+
/* Boolean values. */
|
|
243
|
+
#define SQL_FALSE 0 /* false */
|
|
244
|
+
#define SQL_TRUE 1 /* true */
|
|
245
|
+
|
|
246
|
+
/* Environment attributes. */
|
|
247
|
+
#define SQL_ATTR_OUTPUT_NTS 10001 /* null terminate strings */
|
|
248
|
+
|
|
249
|
+
/* Connection attributes. */
|
|
250
|
+
#define SQL_ATTR_AUTO_IPD 10001 /* always SQL_FALSE */
|
|
251
|
+
#define SQL_ATTR_SAVEPOINT_NAME 10027 /* a savepoint for SQLEndTran */
|
|
252
|
+
#define SQL_ATTR_AUTOCOMMIT 102 /* see SQLSetConnectAttr */
|
|
253
|
+
|
|
254
|
+
/* SQL_ATTR_AUTOCOMMIT values. */
|
|
255
|
+
#define SQL_AUTOCOMMIT_OFF 0 /* the default */
|
|
256
|
+
#define SQL_AUTOCOMMIT_ON 1 /* commit each statement */
|
|
257
|
+
|
|
258
|
+
/* SQLEndTran CompletionTypes. */
|
|
259
|
+
#define SQL_COMMIT 0 /* commit */
|
|
260
|
+
#define SQL_ROLLBACK 1 /* roll back */
|
|
261
|
+
#define SQL_SAVEPOINT_NAME_ROLLBACK 2 /* not supported */
|
|
262
|
+
#define SQL_SAVEPOINT_NAME_RELEASE 4 /* not supported */
|
|
263
|
+
#define SQL_COMMIT_AND_CHAIN 6 /* commit and start another */
|
|
264
|
+
#define SQL_ROLLBACK_AND_CHAIN 7 /* roll back and start another */
|
|
265
|
+
|
|
266
|
+
/* SQLStartTran AccessModes. */
|
|
267
|
+
#define SQL_TRANSACTION_READ_ONLY 0x00000001L /* not supported */
|
|
268
|
+
#define SQL_TRANSACTION_READ_WRITE 0x00000002L /* read and write */
|
|
269
|
+
|
|
270
|
+
/* SQLStartTran IsolationLevels. */
|
|
271
|
+
#define SQL_TRANSACTION_READ_UNCOMMITTED 0x00000001L /* READ COMMITTED */
|
|
272
|
+
#define SQL_TRANSACTION_READ_COMMITTED 0x00000002L /* READ COMMITTED */
|
|
273
|
+
#define SQL_TRANSACTION_REPEATABLE_READ 0x00000004L /* not supported */
|
|
274
|
+
#define SQL_TRANSACTION_SERIALIZABLE 0x00000008L /* not supported */
|
|
275
|
+
|
|
276
|
+
/* SQLGetSessionInfo InfoTypes. */
|
|
277
|
+
#define SQL_CURRENT_USER 47 /* CURRENT_USER */
|
|
278
|
+
#define SQL_CURRENT_DEFAULT_TRANSFORM_GROUP 20004 /* the default transform group */
|
|
279
|
+
#define SQL_CURRENT_PATH 20005 /* CURRENT_PATH */
|
|
280
|
+
#define SQL_CURRENT_ROLE 20006 /* CURRENT_ROLE */
|
|
281
|
+
#define SQL_SESSION_USER 20007 /* SESSION_USER */
|
|
282
|
+
#define SQL_SYSTEM_USER 20008 /* SYSTEM_USER */
|
|
283
|
+
|
|
284
|
+
/* Special values for the catalog routines. */
|
|
285
|
+
#define SQL_ALL_CATALOGS "%" /* every catalog (SQLTables) */
|
|
286
|
+
#define SQL_ALL_SCHEMAS "%" /* every schema (SQLTables) */
|
|
287
|
+
#define SQL_ALL_TABLE_TYPES "%" /* every table type (SQLTables) */
|
|
288
|
+
#define SQL_ALL_TYPES 0 /* every data type (SQLGetTypeInfo) */
|
|
289
|
+
|
|
290
|
+
/* UPDATE_RULE and DELETE_RULE of SQLForeignKeys. */
|
|
291
|
+
#define SQL_CASCADE 0 /* CASCADE */
|
|
292
|
+
#define SQL_RESTRICT 1 /* RESTRICT */
|
|
293
|
+
#define SQL_SET_NULL 2 /* SET NULL */
|
|
294
|
+
#define SQL_NO_ACTION 3 /* NO ACTION */
|
|
295
|
+
#define SQL_SET_DEFAULT 4 /* SET DEFAULT */
|
|
296
|
+
|
|
297
|
+
/* DEFERABILITY of SQLForeignKeys. */
|
|
298
|
+
#define SQL_INITIALLY_DEFERRED 5 /* not used */
|
|
299
|
+
#define SQL_INITIALLY_IMMEDIATE 6 /* not used */
|
|
300
|
+
#define SQL_NOT_DEFERRABLE 7 /* every constraint */
|
|
301
|
+
|
|
302
|
+
/* SQLSpecialColumns IdentifierType, Scope and PSEUDO_COLUMN. */
|
|
303
|
+
#define SQL_BEST_ROWID 1 /* the columns that identify a row */
|
|
304
|
+
#define SQL_SCOPE_CURROW 0 /* valid for the current row */
|
|
305
|
+
#define SQL_SCOPE_TRANSACTION 1 /* valid for the transaction */
|
|
306
|
+
#define SQL_SCOPE_SESSION 2 /* valid for the session */
|
|
307
|
+
#define SQL_PC_UNKNOWN 0 /* not used */
|
|
308
|
+
#define SQL_PC_NOT_PSEUDO 1 /* a real column */
|
|
309
|
+
#define SQL_PC_PSEUDO 2 /* not used */
|
|
310
|
+
|
|
311
|
+
/* SQLGetInfo InfoTypes. */
|
|
312
|
+
#define SQL_MAXIMUM_DRIVER_CONNECTIONS 0 /* SMALLINT, 0 (no limit) */
|
|
313
|
+
#define SQL_MAXIMUM_CONCURRENT_ACTIVITIES 1 /* SMALLINT, 0 (no limit) */
|
|
314
|
+
#define SQL_DATA_SOURCE_NAME 2 /* the ServerName */
|
|
315
|
+
#define SQL_FETCH_DIRECTION 8 /* INTEGER, SQL_FD_FETCH_* */
|
|
316
|
+
#define SQL_SERVER_NAME 13 /* the ServerName */
|
|
317
|
+
#define SQL_SEARCH_PATTERN_ESCAPE 14 /* "\\" */
|
|
318
|
+
#define SQL_DBMS_NAME 17 /* "vsql" */
|
|
319
|
+
#define SQL_DBMS_VERSION 18 /* "01.02.0003 v1.2.3 ..." */
|
|
320
|
+
#define SQL_CURSOR_COMMIT_BEHAVIOR 23 /* SMALLINT, SQL_CB_* */
|
|
321
|
+
#define SQL_DATA_SOURCE_READ_ONLY 25 /* "N" */
|
|
322
|
+
#define SQL_DEFAULT_TRANSACTION_ISOLATION 26 /* INTEGER, SQL_TRANSACTION_* */
|
|
323
|
+
#define SQL_IDENTIFIER_CASE 28 /* SMALLINT, SQL_IC_* */
|
|
324
|
+
#define SQL_MAXIMUM_COLUMN_NAME_LENGTH 30 /* SMALLINT, 128 */
|
|
325
|
+
#define SQL_MAXIMUM_CURSOR_NAME_LENGTH 31 /* SMALLINT, 128 */
|
|
326
|
+
#define SQL_MAXIMUM_SCHEMA_NAME_LENGTH 32 /* SMALLINT, 128 */
|
|
327
|
+
#define SQL_MAXIMUM_CATALOG_NAME_LENGTH 34 /* SMALLINT, 128 */
|
|
328
|
+
#define SQL_MAXIMUM_TABLE_NAME_LENGTH 35 /* SMALLINT, 128 */
|
|
329
|
+
#define SQL_SCROLL_CONCURRENCY 43 /* INTEGER, SQL_SCCO_* */
|
|
330
|
+
#define SQL_TRANSACTION_CAPABLE 46 /* SMALLINT, SQL_TC_* */
|
|
331
|
+
#define SQL_USER_NAME 47 /* "" (no users) */
|
|
332
|
+
#define SQL_TRANSACTION_ISOLATION_OPTION 72 /* INTEGER, SQL_TRANSACTION_* */
|
|
333
|
+
#define SQL_INTEGRITY 73 /* "Y" */
|
|
334
|
+
#define SQL_GETDATA_EXTENSIONS 81 /* INTEGER, SQL_GD_* */
|
|
335
|
+
#define SQL_NULL_COLLATION 85 /* SMALLINT, SQL_NC_* */
|
|
336
|
+
#define SQL_ALTER_TABLE 86 /* INTEGER, SQL_AT_* */
|
|
337
|
+
#define SQL_ORDER_BY_COLUMNS_IN_SELECT 90 /* "N" */
|
|
338
|
+
#define SQL_SPECIAL_CHARACTERS 94 /* "" */
|
|
339
|
+
#define SQL_MAXIMUM_COLUMNS_IN_GROUP_BY 97 /* SMALLINT, 0 (no limit) */
|
|
340
|
+
#define SQL_MAXIMUM_COLUMNS_IN_ORDER_BY 99 /* SMALLINT, 0 (no limit) */
|
|
341
|
+
#define SQL_MAXIMUM_COLUMNS_IN_SELECT 100 /* SMALLINT, 0 (no limit) */
|
|
342
|
+
#define SQL_MAXIMUM_COLUMNS_IN_TABLE 101 /* SMALLINT, 1600 */
|
|
343
|
+
#define SQL_MAXIMUM_TABLES_IN_SELECT 106 /* SMALLINT, 0 (no limit) */
|
|
344
|
+
#define SQL_MAXIMUM_USER_NAME_LENGTH 107 /* SMALLINT, 0 (no limit) */
|
|
345
|
+
#define SQL_OUTER_JOIN_CAPABILITIES 115 /* INTEGER, SQL_OUTER_JOIN_* */
|
|
346
|
+
#define SQL_CURSOR_SENSITIVITY 10001 /* INTEGER, SQL_INSENSITIVE */
|
|
347
|
+
#define SQL_DESCRIBE_PARAMETER 10002 /* "N" */
|
|
348
|
+
#define SQL_CATALOG_NAME 10003 /* "Y" */
|
|
349
|
+
#define SQL_COLLATING_SEQUENCE 10004 /* "" */
|
|
350
|
+
#define SQL_MAXIMUM_IDENTIFIER_LENGTH 10005 /* SMALLINT, 128 */
|
|
351
|
+
#define SQL_MAXIMUM_STMT_OCTETS 20000 /* SMALLINT, 0 (no limit) */
|
|
352
|
+
#define SQL_MAXIMUM_STMT_OCTETS_DATA 20001 /* SMALLINT, 0 (no limit) */
|
|
353
|
+
#define SQL_MAXIMUM_STMT_OCTETS_SCHEMA 20002 /* SMALLINT, 0 (no limit) */
|
|
354
|
+
|
|
355
|
+
/* SQLGetInfo values. */
|
|
356
|
+
#define SQL_AT_ADD_COLUMN 0x00000001L /* ADD COLUMN */
|
|
357
|
+
#define SQL_AT_DROP_COLUMN 0x00000002L /* DROP COLUMN */
|
|
358
|
+
#define SQL_AT_ALTER_COLUMN 0x00000004L /* ALTER COLUMN */
|
|
359
|
+
#define SQL_AT_ADD_CONSTRAINT 0x00000008L /* ADD CONSTRAINT */
|
|
360
|
+
#define SQL_AT_DROP_CONSTRAINT 0x00000010L /* DROP CONSTRAINT */
|
|
361
|
+
#define SQL_CB_DELETE 0 /* cursors are deleted */
|
|
362
|
+
#define SQL_CB_CLOSE 1 /* cursors are closed */
|
|
363
|
+
#define SQL_CB_PRESERVE 2 /* cursors stay open */
|
|
364
|
+
#define SQL_FD_FETCH_NEXT 0x00000001L /* SQL_FETCH_NEXT */
|
|
365
|
+
#define SQL_FD_FETCH_FIRST 0x00000002L /* SQL_FETCH_FIRST */
|
|
366
|
+
#define SQL_FD_FETCH_LAST 0x00000004L /* SQL_FETCH_LAST */
|
|
367
|
+
#define SQL_FD_FETCH_PRIOR 0x00000008L /* SQL_FETCH_PRIOR */
|
|
368
|
+
#define SQL_FD_FETCH_ABSOLUTE 0x00000010L /* SQL_FETCH_ABSOLUTE */
|
|
369
|
+
#define SQL_FD_FETCH_RELATIVE 0x00000020L /* SQL_FETCH_RELATIVE */
|
|
370
|
+
#define SQL_GD_ANY_COLUMN 0x00000001L /* any unbound column */
|
|
371
|
+
#define SQL_GD_ANY_ORDER 0x00000002L /* columns in any order */
|
|
372
|
+
#define SQL_IC_UPPER 1 /* upper case */
|
|
373
|
+
#define SQL_IC_LOWER 2 /* lower case */
|
|
374
|
+
#define SQL_IC_SENSITIVE 3 /* case sensitive */
|
|
375
|
+
#define SQL_IC_MIXED 4 /* mixed case */
|
|
376
|
+
#define SQL_NC_HIGH 1 /* NULLs sort high */
|
|
377
|
+
#define SQL_NC_LOW 2 /* NULLs sort low */
|
|
378
|
+
#define SQL_OUTER_JOIN_LEFT 0x00000001L /* LEFT JOIN */
|
|
379
|
+
#define SQL_OUTER_JOIN_RIGHT 0x00000002L /* RIGHT JOIN */
|
|
380
|
+
#define SQL_OUTER_JOIN_FULL 0x00000004L /* FULL JOIN */
|
|
381
|
+
#define SQL_OUTER_JOIN_NESTED 0x00000008L /* nested joins */
|
|
382
|
+
#define SQL_OUTER_JOIN_NOT_ORDERED 0x00000010L /* ON columns in any order */
|
|
383
|
+
#define SQL_OUTER_JOIN_INNER 0x00000020L /* inner table in an INNER JOIN */
|
|
384
|
+
#define SQL_OUTER_JOIN_ALL_COMPARISON_OPS 0x00000040L /* any comparison in ON */
|
|
385
|
+
#define SQL_SCCO_READ_ONLY 0x00000001L /* read only */
|
|
386
|
+
#define SQL_SCCO_LOCK 0x00000002L /* locking */
|
|
387
|
+
#define SQL_SCCO_OPT_ROWVER 0x00000004L /* row versions */
|
|
388
|
+
#define SQL_SCCO_OPT_VALUES 0x00000008L /* values */
|
|
389
|
+
#define SQL_TC_NONE 0 /* no transactions */
|
|
390
|
+
#define SQL_TC_DML 1 /* DML only */
|
|
391
|
+
#define SQL_TC_ALL 2 /* DML and DDL */
|
|
392
|
+
#define SQL_TC_DDL_COMMIT 3 /* DDL commits */
|
|
393
|
+
#define SQL_TC_DDL_IGNORE 4 /* DDL is ignored */
|
|
394
|
+
|
|
395
|
+
/* SQLGetFunctions FunctionIds. */
|
|
396
|
+
#define SQL_API_SQLALLOCCONNECT 1 /* supported */
|
|
397
|
+
#define SQL_API_SQLALLOCENV 2 /* supported */
|
|
398
|
+
#define SQL_API_SQLALLOCHANDLE 1001 /* supported */
|
|
399
|
+
#define SQL_API_SQLALLOCSTMT 3 /* supported */
|
|
400
|
+
#define SQL_API_SQLBINDCOL 4 /* supported */
|
|
401
|
+
#define SQL_API_SQLBINDPARAMETER 72 /* supported */
|
|
402
|
+
#define SQL_API_SQLCANCEL 5 /* supported */
|
|
403
|
+
#define SQL_API_SQLCLOSECURSOR 1003 /* supported */
|
|
404
|
+
#define SQL_API_SQLCOLATTRIBUTE 6 /* supported */
|
|
405
|
+
#define SQL_API_SQLCOLUMNPRIVILEGES 56 /* not supported */
|
|
406
|
+
#define SQL_API_SQLCOLUMNS 40 /* supported */
|
|
407
|
+
#define SQL_API_SQLCONNECT 7 /* supported */
|
|
408
|
+
#define SQL_API_SQLCOPYDESC 1004 /* supported */
|
|
409
|
+
#define SQL_API_SQLDATASOURCES 57 /* supported */
|
|
410
|
+
#define SQL_API_SQLDESCRIBECOL 8 /* supported */
|
|
411
|
+
#define SQL_API_SQLDISCONNECT 9 /* supported */
|
|
412
|
+
#define SQL_API_SQLENDTRAN 1005 /* supported */
|
|
413
|
+
#define SQL_API_SQLERROR 10 /* supported */
|
|
414
|
+
#define SQL_API_SQLEXECDIRECT 11 /* supported */
|
|
415
|
+
#define SQL_API_SQLEXECUTE 12 /* supported */
|
|
416
|
+
#define SQL_API_SQLFETCH 13 /* supported */
|
|
417
|
+
#define SQL_API_SQLFETCHSCROLL 1021 /* supported */
|
|
418
|
+
#define SQL_API_SQLFOREIGNKEYS 60 /* supported */
|
|
419
|
+
#define SQL_API_SQLFREECONNECT 14 /* supported */
|
|
420
|
+
#define SQL_API_SQLFREEENV 15 /* supported */
|
|
421
|
+
#define SQL_API_SQLFREEHANDLE 1006 /* supported */
|
|
422
|
+
#define SQL_API_SQLFREESTMT 16 /* supported */
|
|
423
|
+
#define SQL_API_SQLGETCONNECTATTR 1007 /* supported */
|
|
424
|
+
#define SQL_API_SQLGETCURSORNAME 17 /* supported */
|
|
425
|
+
#define SQL_API_SQLGETDATA 43 /* supported */
|
|
426
|
+
#define SQL_API_SQLGETDESCFIELD 1008 /* supported */
|
|
427
|
+
#define SQL_API_SQLGETDESCREC 1009 /* supported */
|
|
428
|
+
#define SQL_API_SQLGETDIAGFIELD 1010 /* supported */
|
|
429
|
+
#define SQL_API_SQLGETDIAGREC 1011 /* supported */
|
|
430
|
+
#define SQL_API_SQLGETENVATTR 1012 /* supported */
|
|
431
|
+
#define SQL_API_SQLGETFEATUREINFO 1027 /* supported */
|
|
432
|
+
#define SQL_API_SQLGETFUNCTIONS 44 /* supported */
|
|
433
|
+
#define SQL_API_SQLGETINFO 45 /* supported */
|
|
434
|
+
#define SQL_API_SQLGETLENGTH 1022 /* not supported */
|
|
435
|
+
#define SQL_API_SQLGETPARAMDATA 1025 /* not supported */
|
|
436
|
+
#define SQL_API_SQLGETPOSITION 1023 /* not supported */
|
|
437
|
+
#define SQL_API_SQLGETSESSIONINFO 1028 /* not supported */
|
|
438
|
+
#define SQL_API_SQLGETSTMTATTR 1014 /* supported */
|
|
439
|
+
#define SQL_API_SQLGETSUBSTRING 1024 /* not supported */
|
|
440
|
+
#define SQL_API_SQLGETTYPEINFO 47 /* supported */
|
|
441
|
+
#define SQL_API_SQLMORERESULTS 61 /* supported */
|
|
442
|
+
#define SQL_API_SQLNEXTRESULT 73 /* supported */
|
|
443
|
+
#define SQL_API_SQLNUMRESULTCOLS 18 /* supported */
|
|
444
|
+
#define SQL_API_SQLPARAMDATA 48 /* supported */
|
|
445
|
+
#define SQL_API_SQLPREPARE 19 /* supported */
|
|
446
|
+
#define SQL_API_SQLPRIMARYKEYS 65 /* supported */
|
|
447
|
+
#define SQL_API_SQLPUTDATA 49 /* supported */
|
|
448
|
+
#define SQL_API_SQLROWCOUNT 20 /* supported */
|
|
449
|
+
#define SQL_API_SQLSETCONNECTATTR 1016 /* supported */
|
|
450
|
+
#define SQL_API_SQLSETCURSORNAME 21 /* supported */
|
|
451
|
+
#define SQL_API_SQLSETDESCFIELD 1017 /* supported */
|
|
452
|
+
#define SQL_API_SQLSETDESCREC 1018 /* supported */
|
|
453
|
+
#define SQL_API_SQLSETENVATTR 1019 /* supported */
|
|
454
|
+
#define SQL_API_SQLSETSTMTATTR 1020 /* supported */
|
|
455
|
+
#define SQL_API_SQLSPECIALCOLUMNS 52 /* supported */
|
|
456
|
+
#define SQL_API_SQLSTARTTRAN 74 /* supported */
|
|
457
|
+
#define SQL_API_SQLTABLEPRIVILEGES 70 /* not supported */
|
|
458
|
+
#define SQL_API_SQLTABLES 54 /* supported */
|
|
459
|
+
|
|
460
|
+
/* SQLBindParameter InputOutputModes. */
|
|
461
|
+
#define SQL_PARAM_MODE_IN 1 /* an input parameter */
|
|
462
|
+
#define SQL_PARAM_MODE_INOUT 2 /* the same as an input parameter */
|
|
463
|
+
#define SQL_PARAM_MODE_OUT 4 /* not supported */
|
|
464
|
+
|
|
465
|
+
/* SQLFetchScroll FetchOrientations. */
|
|
466
|
+
#define SQL_FETCH_NEXT 1 /* the next rowset */
|
|
467
|
+
#define SQL_FETCH_FIRST 2 /* the first rowset */
|
|
468
|
+
#define SQL_FETCH_LAST 3 /* the last rowset */
|
|
469
|
+
#define SQL_FETCH_PRIOR 4 /* the rowset before */
|
|
470
|
+
#define SQL_FETCH_ABSOLUTE 5 /* from the first (or last) row */
|
|
471
|
+
#define SQL_FETCH_RELATIVE 6 /* from the first row of the rowset */
|
|
472
|
+
|
|
473
|
+
/* The status of each row of a rowset (SQL_DESC_ARRAY_STATUS_POINTER). */
|
|
474
|
+
#define SQL_ROW_SUCCESS 0 /* fetched */
|
|
475
|
+
#define SQL_ROW_NO_ROW 3 /* there isn't a row */
|
|
476
|
+
#define SQL_ROW_ERROR 5 /* couldn't be fetched */
|
|
477
|
+
#define SQL_ROW_SUCCESS_WITH_INFO 6 /* fetched with a warning */
|
|
478
|
+
|
|
479
|
+
/* Statement attributes. */
|
|
480
|
+
#define SQL_ATTR_CURSOR_HOLDABLE (-3) /* SQL_HOLDABLE (the default) */
|
|
481
|
+
#define SQL_ATTR_CURSOR_SENSITIVITY (-2) /* SQL_ASENSITIVE (the default) */
|
|
482
|
+
#define SQL_ATTR_CURSOR_SCROLLABLE (-1) /* SQL_NONSCROLLABLE (the default) */
|
|
483
|
+
#define SQL_ATTR_APP_ROW_DESC 10010 /* the current ARD */
|
|
484
|
+
#define SQL_ATTR_APP_PARAM_DESC 10011 /* the current APD */
|
|
485
|
+
#define SQL_ATTR_IMP_ROW_DESC 10012 /* the IRD (read only) */
|
|
486
|
+
#define SQL_ATTR_IMP_PARAM_DESC 10013 /* the IPD (read only) */
|
|
487
|
+
#define SQL_ATTR_METADATA_ID 10014 /* SQL_FALSE (the default) */
|
|
488
|
+
#define SQL_ATTR_CURRENT_OF_POSITION 10027 /* the row of the rowset */
|
|
489
|
+
#define SQL_ATTR_NEST_DESCRIPTOR 10029 /* SQL_FALSE (the default) */
|
|
490
|
+
|
|
491
|
+
/* Values of the cursor statement attributes. */
|
|
492
|
+
#define SQL_NONSCROLLABLE 0 /* only SQL_FETCH_NEXT */
|
|
493
|
+
#define SQL_SCROLLABLE 1 /* any fetch orientation */
|
|
494
|
+
#define SQL_ASENSITIVE 0 /* may see changes (but doesn't) */
|
|
495
|
+
#define SQL_INSENSITIVE 1 /* doesn't see changes */
|
|
496
|
+
#define SQL_SENSITIVE 2 /* not supported */
|
|
497
|
+
#define SQL_NONHOLDABLE 0 /* closed by a commit */
|
|
498
|
+
#define SQL_HOLDABLE 1 /* stays open after a commit */
|
|
499
|
+
|
|
500
|
+
/* Descriptor header fields. */
|
|
501
|
+
#define SQL_DESC_ARRAY_SIZE 20 /* the number of rows */
|
|
502
|
+
#define SQL_DESC_ARRAY_STATUS_POINTER 21 /* SQLINTEGER[] row statuses */
|
|
503
|
+
#define SQL_DESC_ROWS_PROCESSED_POINTER 34 /* SQLINTEGER * rows fetched */
|
|
504
|
+
#define SQL_DESC_COUNT 1001 /* the number of records */
|
|
505
|
+
#define SQL_DESC_KEY_TYPE 1029 /* always 0 */
|
|
506
|
+
#define SQL_DESC_DYNAMIC_FUNCTION 1031 /* the statement */
|
|
507
|
+
#define SQL_DESC_DYNAMIC_FUNCTION_CODE 1032 /* the code of the statement */
|
|
508
|
+
#define SQL_DESC_TOP_LEVEL_COUNT 1044 /* the number of columns */
|
|
509
|
+
#define SQL_DESC_ALLOC_TYPE 1099 /* SQL_DESC_ALLOC_AUTO or USER */
|
|
510
|
+
|
|
511
|
+
/* Descriptor record fields. */
|
|
512
|
+
#define SQL_DESC_DATETIME_INTERVAL_PRECISION 26 /* not used */
|
|
513
|
+
#define SQL_DESC_TYPE 1002 /* the data type */
|
|
514
|
+
#define SQL_DESC_LENGTH 1003 /* in characters */
|
|
515
|
+
#define SQL_DESC_OCTET_LENGTH_POINTER 1004 /* SQLINTEGER *length */
|
|
516
|
+
#define SQL_DESC_PRECISION 1005 /* the precision */
|
|
517
|
+
#define SQL_DESC_SCALE 1006 /* the scale */
|
|
518
|
+
#define SQL_DESC_DATETIME_INTERVAL_CODE 1007 /* such as SQL_CODE_DATE */
|
|
519
|
+
#define SQL_DESC_NULLABLE 1008 /* SQL_NULLABLE */
|
|
520
|
+
#define SQL_DESC_INDICATOR_POINTER 1009 /* SQLINTEGER * indicator */
|
|
521
|
+
#define SQL_DESC_DATA_POINTER 1010 /* the value */
|
|
522
|
+
#define SQL_DESC_NAME 1011 /* the name of the column */
|
|
523
|
+
#define SQL_DESC_UNNAMED 1012 /* SQL_UNNAMED or SQL_NAMED */
|
|
524
|
+
#define SQL_DESC_OCTET_LENGTH 1013 /* the length in octets */
|
|
525
|
+
#define SQL_DESC_COLLATION_CATALOG 1015 /* always "" */
|
|
526
|
+
#define SQL_DESC_COLLATION_SCHEMA 1016 /* always "" */
|
|
527
|
+
#define SQL_DESC_COLLATION_NAME 1017 /* always "" */
|
|
528
|
+
#define SQL_DESC_CHARACTER_SET_CATALOG 1018 /* the current catalog */
|
|
529
|
+
#define SQL_DESC_CHARACTER_SET_SCHEMA 1019 /* "INFORMATION_SCHEMA" */
|
|
530
|
+
#define SQL_DESC_CHARACTER_SET_NAME 1020 /* "UTF8" */
|
|
531
|
+
#define SQL_DESC_PARAMETER_MODE 1021 /* SQL_PARAM_MODE_IN */
|
|
532
|
+
#define SQL_DESC_PARAMETER_ORDINAL_POSITION 1022 /* not used */
|
|
533
|
+
#define SQL_DESC_PARAMETER_SPECIFIC_CATALOG 1023 /* not used */
|
|
534
|
+
#define SQL_DESC_PARAMETER_SPECIFIC_SCHEMA 1024 /* not used */
|
|
535
|
+
#define SQL_DESC_PARAMETER_SPECIFIC_NAME 1025 /* not used */
|
|
536
|
+
#define SQL_DESC_UDT_CATALOG 1026 /* not used */
|
|
537
|
+
#define SQL_DESC_UDT_SCHEMA 1027 /* not used */
|
|
538
|
+
#define SQL_DESC_UDT_NAME 1028 /* not used */
|
|
539
|
+
#define SQL_DESC_KEY_MEMBER 1030 /* always 0 */
|
|
540
|
+
#define SQL_DESC_SCOPE_CATALOG 1033 /* not used */
|
|
541
|
+
#define SQL_DESC_SCOPE_SCHEMA 1034 /* not used */
|
|
542
|
+
#define SQL_DESC_SCOPE_NAME 1035 /* not used */
|
|
543
|
+
#define SQL_DESC_SPECIFIC_TYPE_CATALOG 1036 /* not used */
|
|
544
|
+
#define SQL_DESC_SPECIFIC_TYPE_SCHEMA 1037 /* not used */
|
|
545
|
+
#define SQL_DESC_SPECIFIC_TYPE_NAME 1038 /* not used */
|
|
546
|
+
#define SQL_DESC_CURRENT_TRANSFORM_GROUP 1039 /* not used */
|
|
547
|
+
#define SQL_DESC_CARDINALITY 1040 /* not used */
|
|
548
|
+
#define SQL_DESC_DEGREE 1041 /* not used */
|
|
549
|
+
#define SQL_DESC_LEVEL 1042 /* always 0 */
|
|
550
|
+
#define SQL_DESC_RETURNED_CARDINALITY_POINTER 1043 /* not used */
|
|
551
|
+
#define SQL_DESC_USER_DEFINED_TYPE_CODE 1045 /* not used */
|
|
552
|
+
|
|
553
|
+
/* Other descriptor values. */
|
|
554
|
+
#define SQL_DESC_ALLOC_AUTO 1 /* allocated with a statement */
|
|
555
|
+
#define SQL_DESC_ALLOC_USER 2 /* allocated with SQLAllocHandle */
|
|
556
|
+
#define SQL_NAMED 0 /* the column has a name */
|
|
557
|
+
#define SQL_UNNAMED 1 /* the column doesn't have a name */
|
|
558
|
+
|
|
559
|
+
/* SQLFreeStmt options (and their ODBC names). */
|
|
560
|
+
#define SQL_CLOSE_CURSOR 0 /* close the cursor */
|
|
561
|
+
#define SQL_FREE_HANDLE 1 /* free the statement */
|
|
562
|
+
#define SQL_UNBIND_COLUMNS 2 /* unbind every column */
|
|
563
|
+
#define SQL_UNBIND_PARAMETERS 3 /* unbind every parameter */
|
|
564
|
+
#define SQL_REALLOCATE 4 /* forget the statement */
|
|
565
|
+
#define SQL_CLOSE 0 /* SQL_CLOSE_CURSOR */
|
|
566
|
+
#define SQL_DROP 1 /* SQL_FREE_HANDLE */
|
|
567
|
+
#define SQL_UNBIND 2 /* SQL_UNBIND_COLUMNS */
|
|
568
|
+
#define SQL_RESET_PARAMS 3 /* SQL_UNBIND_PARAMETERS */
|
|
569
|
+
|
|
570
|
+
/* Nullability. */
|
|
571
|
+
#define SQL_NO_NULLS 0 /* the column is never NULL */
|
|
572
|
+
#define SQL_NULLABLE 1 /* the column may be NULL */
|
|
573
|
+
|
|
574
|
+
/*
|
|
575
|
+
* SQLAllocConnect is the same as SQLAllocHandle(SQL_HANDLE_DBC,
|
|
576
|
+
* EnvironmentHandle, ConnectionHandle).
|
|
577
|
+
*/
|
|
578
|
+
SQLRETURN SQLAllocConnect(
|
|
579
|
+
SQLHENV EnvironmentHandle,
|
|
580
|
+
SQLHDBC *ConnectionHandle
|
|
581
|
+
);
|
|
582
|
+
|
|
583
|
+
/*
|
|
584
|
+
* SQLAllocEnv is the same as SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE,
|
|
585
|
+
* EnvironmentHandle).
|
|
586
|
+
*/
|
|
587
|
+
SQLRETURN SQLAllocEnv(
|
|
588
|
+
SQLHENV *EnvironmentHandle
|
|
589
|
+
);
|
|
590
|
+
|
|
591
|
+
/*
|
|
592
|
+
* SQLAllocHandle allocates an environment (SQL_HANDLE_ENV), a connection
|
|
593
|
+
* (SQL_HANDLE_DBC) for an environment, or a statement (SQL_HANDLE_STMT) or
|
|
594
|
+
* descriptor (SQL_HANDLE_DESC, see SQLGetDescField) for an established
|
|
595
|
+
* connection. InputHandle is SQL_NULL_HANDLE for an environment, otherwise
|
|
596
|
+
* it's the environment or connection to allocate it for. Each handle must be
|
|
597
|
+
* freed with SQLFreeHandle.
|
|
598
|
+
*
|
|
599
|
+
* SQLHENV env;
|
|
600
|
+
* SQLHDBC dbc;
|
|
601
|
+
* SQLHSTMT stmt;
|
|
602
|
+
*
|
|
603
|
+
* SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
|
|
604
|
+
* SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
|
|
605
|
+
* SQLConnect(dbc, (SQLCHAR *)"test.vsql", SQL_NTS, NULL, 0, NULL, 0);
|
|
606
|
+
* SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
|
|
607
|
+
*/
|
|
608
|
+
SQLRETURN SQLAllocHandle(
|
|
609
|
+
SQLSMALLINT HandleType,
|
|
610
|
+
SQLINTEGER InputHandle,
|
|
611
|
+
SQLINTEGER *OutputHandle
|
|
612
|
+
);
|
|
613
|
+
|
|
614
|
+
/*
|
|
615
|
+
* SQLAllocStmt is the same as SQLAllocHandle(SQL_HANDLE_STMT,
|
|
616
|
+
* ConnectionHandle, StatementHandle).
|
|
617
|
+
*/
|
|
618
|
+
SQLRETURN SQLAllocStmt(
|
|
619
|
+
SQLHDBC ConnectionHandle,
|
|
620
|
+
SQLHSTMT *StatementHandle
|
|
621
|
+
);
|
|
622
|
+
|
|
623
|
+
/*
|
|
624
|
+
* SQLBindCol binds a column (starting at 1) so that SQLFetch and
|
|
625
|
+
* SQLFetchScroll set TargetValue (of TargetType, see SQLGetData) and
|
|
626
|
+
* StrLen_or_Ind. With a SQL_DESC_ARRAY_SIZE (in the ARD) greater than 1, they
|
|
627
|
+
* are arrays with an element for each row of the rowset. A null TargetValue
|
|
628
|
+
* unbinds the column. BufferLength must be greater than 0.
|
|
629
|
+
*/
|
|
630
|
+
SQLRETURN SQLBindCol(
|
|
631
|
+
SQLHSTMT StatementHandle,
|
|
632
|
+
SQLSMALLINT ColumnNumber,
|
|
633
|
+
SQLSMALLINT TargetType,
|
|
634
|
+
SQLPOINTER TargetValue,
|
|
635
|
+
SQLINTEGER BufferLength,
|
|
636
|
+
SQLINTEGER *StrLen_or_Ind
|
|
637
|
+
);
|
|
638
|
+
|
|
639
|
+
/*
|
|
640
|
+
* SQLBindParameter binds a dynamic parameter ("?", starting at 1) of a
|
|
641
|
+
* statement. ParameterType (such as SQL_VARCHAR or SQL_TYPE_DATE) is its SQL
|
|
642
|
+
* data type, with ColumnSize as the length of a string, or the precision of a
|
|
643
|
+
* number (and DecimalDigits as its scale), or the fractional seconds of a
|
|
644
|
+
* datetime. When the statement is executed, ParameterValue (of ValueType, see
|
|
645
|
+
* SQLGetData) is cast to that type.
|
|
646
|
+
*
|
|
647
|
+
* StrLen_or_Ind is the length in octets of a string (or SQL_NTS), and it may
|
|
648
|
+
* be SQL_NULL_DATA for a NULL, or SQL_DATA_AT_EXEC to give the value with
|
|
649
|
+
* SQLParamData and SQLPutData. BufferLength is the size of ParameterValue.
|
|
650
|
+
* InputOutputMode must be SQL_PARAM_MODE_IN (or SQL_PARAM_MODE_INOUT, which is
|
|
651
|
+
* the same).
|
|
652
|
+
*
|
|
653
|
+
* SQLINTEGER x = 123;
|
|
654
|
+
*
|
|
655
|
+
* SQLPrepare(stmt, (SQLCHAR *)"INSERT INTO foo (x) VALUES (?)", SQL_NTS);
|
|
656
|
+
* SQLBindParameter(stmt, 1, SQL_PARAM_MODE_IN, SQL_INTEGER, SQL_INTEGER, 0,
|
|
657
|
+
* 0, &x, sizeof(x), NULL);
|
|
658
|
+
* SQLExecute(stmt);
|
|
659
|
+
*/
|
|
660
|
+
SQLRETURN SQLBindParameter(
|
|
661
|
+
SQLHSTMT StatementHandle,
|
|
662
|
+
SQLSMALLINT ParameterNumber,
|
|
663
|
+
SQLSMALLINT InputOutputMode,
|
|
664
|
+
SQLSMALLINT ValueType,
|
|
665
|
+
SQLSMALLINT ParameterType,
|
|
666
|
+
SQLINTEGER ColumnSize,
|
|
667
|
+
SQLSMALLINT DecimalDigits,
|
|
668
|
+
SQLPOINTER ParameterValue,
|
|
669
|
+
SQLINTEGER BufferLength,
|
|
670
|
+
SQLINTEGER *StrLen_or_Ind
|
|
671
|
+
);
|
|
672
|
+
|
|
673
|
+
/*
|
|
674
|
+
* SQLCancel cancels a routine that's running on the statement. libvsql isn't
|
|
675
|
+
* thread safe, so there's never one running and SQLCancel only clears the
|
|
676
|
+
* diagnostics of the statement.
|
|
677
|
+
*/
|
|
678
|
+
SQLRETURN SQLCancel(
|
|
679
|
+
SQLHSTMT StatementHandle
|
|
680
|
+
);
|
|
681
|
+
|
|
682
|
+
/*
|
|
683
|
+
* SQLCloseCursor closes the cursor opened by SQLExecDirect so that the
|
|
684
|
+
* statement can be used to execute another statement.
|
|
685
|
+
*
|
|
686
|
+
* SQLExecDirect(stmt, (SQLCHAR *)"SELECT * FROM foo", SQL_NTS);
|
|
687
|
+
* SQLFetch(stmt);
|
|
688
|
+
* SQLCloseCursor(stmt);
|
|
689
|
+
* SQLExecDirect(stmt, (SQLCHAR *)"DROP TABLE foo", SQL_NTS);
|
|
690
|
+
*/
|
|
691
|
+
SQLRETURN SQLCloseCursor(
|
|
692
|
+
SQLHSTMT StatementHandle
|
|
693
|
+
);
|
|
694
|
+
|
|
695
|
+
/*
|
|
696
|
+
* SQLColAttribute reads a field of the IRD (see SQLGetDescField) for a column
|
|
697
|
+
* (starting at 1) of the executed statement. A string field (such as
|
|
698
|
+
* SQL_DESC_NAME) is returned in CharacterAttribute (see SQLGetData for
|
|
699
|
+
* SQL_CHAR), and any other field in NumericAttribute. SQL_DESC_TYPE is the
|
|
700
|
+
* same as the DataType of SQLDescribeCol (such as SQL_TYPE_DATE). It returns
|
|
701
|
+
* SQL_NO_DATA for a column after the last one.
|
|
702
|
+
*
|
|
703
|
+
* SQLINTEGER nullable;
|
|
704
|
+
*
|
|
705
|
+
* SQLExecDirect(stmt, (SQLCHAR *)"SELECT * FROM foo", SQL_NTS);
|
|
706
|
+
* SQLColAttribute(stmt, 1, SQL_DESC_NULLABLE, NULL, 0, NULL, &nullable);
|
|
707
|
+
*/
|
|
708
|
+
SQLRETURN SQLColAttribute(
|
|
709
|
+
SQLHSTMT StatementHandle,
|
|
710
|
+
SQLSMALLINT ColumnNumber,
|
|
711
|
+
SQLSMALLINT FieldIdentifier,
|
|
712
|
+
SQLCHAR *CharacterAttribute,
|
|
713
|
+
SQLSMALLINT BufferLength,
|
|
714
|
+
SQLSMALLINT *StringLength,
|
|
715
|
+
SQLINTEGER *NumericAttribute
|
|
716
|
+
);
|
|
717
|
+
|
|
718
|
+
/*
|
|
719
|
+
* SQLColumnPrivileges would return a result set that describes the privileges
|
|
720
|
+
* of columns.
|
|
721
|
+
* vsql doesn't have privileges, so it always returns SQL_ERROR with SQLSTATE
|
|
722
|
+
* HYC00 (optional feature not implemented).
|
|
723
|
+
*/
|
|
724
|
+
SQLRETURN SQLColumnPrivileges(
|
|
725
|
+
SQLHSTMT StatementHandle,
|
|
726
|
+
SQLCHAR *CatalogName,
|
|
727
|
+
SQLSMALLINT NameLength1,
|
|
728
|
+
SQLCHAR *SchemaName,
|
|
729
|
+
SQLSMALLINT NameLength2,
|
|
730
|
+
SQLCHAR *TableName,
|
|
731
|
+
SQLSMALLINT NameLength3,
|
|
732
|
+
SQLCHAR *ColumnName,
|
|
733
|
+
SQLSMALLINT NameLength4
|
|
734
|
+
);
|
|
735
|
+
|
|
736
|
+
/*
|
|
737
|
+
* SQLColumns returns a result set (like a query) that describes the columns of
|
|
738
|
+
* tables, from the INFORMATION_SCHEMA. Its columns are TABLE_CAT, TABLE_SCHEM,
|
|
739
|
+
* TABLE_NAME, COLUMN_NAME, DATA_TYPE (such as SQL_INTEGER), TYPE_NAME,
|
|
740
|
+
* COLUMN_SIZE, BUFFER_LENGTH, DECIMAL_DIGITS, NUM_PREC_RADIX, NULLABLE,
|
|
741
|
+
* REMARKS, COLUMN_DEF, SQL_DATA_TYPE, SQL_DATETIME_SUB, CHAR_OCTET_LENGTH,
|
|
742
|
+
* ORDINAL_POSITION and IS_NULLABLE (and others, see the standard).
|
|
743
|
+
*
|
|
744
|
+
* Each name argument is a LIKE pattern (where "\" escapes "%" and "_"), and a
|
|
745
|
+
* null pointer (or a zero-length string) matches anything. If the statement's
|
|
746
|
+
* SQL_ATTR_METADATA_ID is SQL_TRUE, they are identifiers instead: they can't
|
|
747
|
+
* be null pointers, and they're case insensitive unless they're quoted.
|
|
748
|
+
*
|
|
749
|
+
* SQLColumns(stmt, NULL, 0, NULL, 0, (SQLCHAR *)"FOO", SQL_NTS, NULL, 0);
|
|
750
|
+
* while (SQLFetch(stmt) == SQL_SUCCESS) {
|
|
751
|
+
* SQLGetData(stmt, 4, SQL_CHAR, name, sizeof(name), NULL);
|
|
752
|
+
* }
|
|
753
|
+
*/
|
|
754
|
+
SQLRETURN SQLColumns(
|
|
755
|
+
SQLHSTMT StatementHandle,
|
|
756
|
+
SQLCHAR *CatalogName,
|
|
757
|
+
SQLSMALLINT NameLength1,
|
|
758
|
+
SQLCHAR *SchemaName,
|
|
759
|
+
SQLSMALLINT NameLength2,
|
|
760
|
+
SQLCHAR *TableName,
|
|
761
|
+
SQLSMALLINT NameLength3,
|
|
762
|
+
SQLCHAR *ColumnName,
|
|
763
|
+
SQLSMALLINT NameLength4
|
|
764
|
+
);
|
|
765
|
+
|
|
766
|
+
/*
|
|
767
|
+
* SQLConnect opens a database. ServerName is the path to the database file, or
|
|
768
|
+
* ":memory:" for an in-memory database. An empty ServerName (or a null pointer,
|
|
769
|
+
* or "DEFAULT") connects to a new in-memory database. UserName and
|
|
770
|
+
* Authentication are not used. Each length is in octets, or SQL_NTS for a null
|
|
771
|
+
* terminated string.
|
|
772
|
+
*
|
|
773
|
+
* The new connection becomes the current connection. Using a statement,
|
|
774
|
+
* descriptor or connection of another connection makes that one current
|
|
775
|
+
* instead. Each connection is a different database, and a transaction can't
|
|
776
|
+
* span more than one, so while the current connection has an active
|
|
777
|
+
* transaction, connecting or switching to another connection is 0A001. End
|
|
778
|
+
* the transaction with SQLEndTran first.
|
|
779
|
+
*
|
|
780
|
+
* SQLConnect(dbc, (SQLCHAR *)"test.vsql", SQL_NTS, NULL, 0, NULL, 0);
|
|
781
|
+
*/
|
|
782
|
+
SQLRETURN SQLConnect(
|
|
783
|
+
SQLHDBC ConnectionHandle,
|
|
784
|
+
SQLCHAR *ServerName,
|
|
785
|
+
SQLSMALLINT NameLength1,
|
|
786
|
+
SQLCHAR *UserName,
|
|
787
|
+
SQLSMALLINT NameLength2,
|
|
788
|
+
SQLCHAR *Authentication,
|
|
789
|
+
SQLSMALLINT NameLength3
|
|
790
|
+
);
|
|
791
|
+
|
|
792
|
+
/*
|
|
793
|
+
* SQLCopyDesc replaces the fields and records of TargetDescHandle with those of
|
|
794
|
+
* SourceDescHandle (except for SQL_DESC_ALLOC_TYPE). The target can't be an
|
|
795
|
+
* IRD (HY016, see SQLSetDescRec).
|
|
796
|
+
*/
|
|
797
|
+
SQLRETURN SQLCopyDesc(
|
|
798
|
+
SQLHDESC SourceDescHandle,
|
|
799
|
+
SQLHDESC TargetDescHandle
|
|
800
|
+
);
|
|
801
|
+
|
|
802
|
+
/*
|
|
803
|
+
* SQLDataSources returns the ServerNames that SQLConnect accepts without a
|
|
804
|
+
* file path: "DEFAULT" and ":memory:" (both are new in-memory databases).
|
|
805
|
+
* Direction is SQL_FETCH_FIRST or SQL_FETCH_NEXT, and SQL_NO_DATA is returned
|
|
806
|
+
* after the last one.
|
|
807
|
+
*
|
|
808
|
+
* SQLCHAR name[129], description[256];
|
|
809
|
+
*
|
|
810
|
+
* SQLDataSources(env, SQL_FETCH_FIRST, name, sizeof(name), NULL,
|
|
811
|
+
* description, sizeof(description), NULL);
|
|
812
|
+
*/
|
|
813
|
+
SQLRETURN SQLDataSources(
|
|
814
|
+
SQLHENV EnvironmentHandle,
|
|
815
|
+
SQLSMALLINT Direction,
|
|
816
|
+
SQLCHAR *ServerName,
|
|
817
|
+
SQLSMALLINT BufferLength1,
|
|
818
|
+
SQLSMALLINT *NameLength1,
|
|
819
|
+
SQLCHAR *Description,
|
|
820
|
+
SQLSMALLINT BufferLength2,
|
|
821
|
+
SQLSMALLINT *NameLength2
|
|
822
|
+
);
|
|
823
|
+
|
|
824
|
+
/*
|
|
825
|
+
* SQLDescribeCol describes a column (starting at 1) of the cursor. The name is
|
|
826
|
+
* null terminated and truncated (SQL_SUCCESS_WITH_INFO) if it's longer than
|
|
827
|
+
* BufferLength - 1. NameLength may be a null pointer, otherwise it's set to the
|
|
828
|
+
* length of the whole name. DataType is one of the data type codes (such as
|
|
829
|
+
* SQL_DOUBLE, or SQL_TYPE_DATE for a DATE). ColumnSize is the maximum length in
|
|
830
|
+
* octets of a string (4 for each character), the number of decimal digits of a
|
|
831
|
+
* number, or the length of a datetime. DecimalDigits is the scale of a DECIMAL
|
|
832
|
+
* or NUMERIC, or the fractional seconds of a datetime. Nullable is SQL_NO_NULLS
|
|
833
|
+
* or SQL_NULLABLE. These are from the IRD, see SQLGetDescField.
|
|
834
|
+
*
|
|
835
|
+
* SQLCHAR name[128];
|
|
836
|
+
* SQLSMALLINT type, digits, nullable;
|
|
837
|
+
* SQLINTEGER size;
|
|
838
|
+
*
|
|
839
|
+
* SQLExecDirect(stmt, (SQLCHAR *)"SELECT * FROM foo", SQL_NTS);
|
|
840
|
+
* SQLDescribeCol(stmt, 1, name, sizeof(name), NULL, &type, &size, &digits,
|
|
841
|
+
* &nullable);
|
|
842
|
+
*/
|
|
843
|
+
SQLRETURN SQLDescribeCol(
|
|
844
|
+
SQLHSTMT StatementHandle,
|
|
845
|
+
SQLSMALLINT ColumnNumber,
|
|
846
|
+
SQLCHAR *ColumnName,
|
|
847
|
+
SQLSMALLINT BufferLength,
|
|
848
|
+
SQLSMALLINT *NameLength,
|
|
849
|
+
SQLSMALLINT *DataType,
|
|
850
|
+
SQLINTEGER *ColumnSize,
|
|
851
|
+
SQLSMALLINT *DecimalDigits,
|
|
852
|
+
SQLSMALLINT *Nullable
|
|
853
|
+
);
|
|
854
|
+
|
|
855
|
+
/*
|
|
856
|
+
* SQLDisconnect closes the database and frees the statements of the
|
|
857
|
+
* connection. A transaction must be committed or rolled back with SQLEndTran
|
|
858
|
+
* first. The connection can then be freed, or connected again.
|
|
859
|
+
*
|
|
860
|
+
* SQLDisconnect(dbc);
|
|
861
|
+
* SQLFreeHandle(SQL_HANDLE_DBC, dbc);
|
|
862
|
+
*/
|
|
863
|
+
SQLRETURN SQLDisconnect(
|
|
864
|
+
SQLHDBC ConnectionHandle
|
|
865
|
+
);
|
|
866
|
+
|
|
867
|
+
/*
|
|
868
|
+
* SQLEndTran commits (SQL_COMMIT) or rolls back (SQL_ROLLBACK) the
|
|
869
|
+
* transaction of a connection (SQL_HANDLE_DBC), or of every connection of an
|
|
870
|
+
* environment (SQL_HANDLE_ENV). SQL_COMMIT_AND_CHAIN and
|
|
871
|
+
* SQL_ROLLBACK_AND_CHAIN also start a new transaction. A rollback closes every
|
|
872
|
+
* cursor of the connection, but a commit doesn't. There are no savepoints, so
|
|
873
|
+
* SQL_SAVEPOINT_NAME_ROLLBACK and SQL_SAVEPOINT_NAME_RELEASE are 3B001.
|
|
874
|
+
*
|
|
875
|
+
* SQLExecDirect(stmt, (SQLCHAR *)"INSERT INTO foo (x) VALUES (1.23)",
|
|
876
|
+
* SQL_NTS);
|
|
877
|
+
* SQLEndTran(SQL_HANDLE_DBC, dbc, SQL_COMMIT);
|
|
878
|
+
*/
|
|
879
|
+
SQLRETURN SQLEndTran(
|
|
880
|
+
SQLSMALLINT HandleType,
|
|
881
|
+
SQLINTEGER Handle,
|
|
882
|
+
SQLSMALLINT CompletionType
|
|
883
|
+
);
|
|
884
|
+
|
|
885
|
+
/*
|
|
886
|
+
* SQLError reads the next diagnostic record that it hasn't already read for the
|
|
887
|
+
* last routine called with a handle. It uses StatementHandle if it's a
|
|
888
|
+
* statement, otherwise ConnectionHandle if StatementHandle is SQL_NULL_HANDLE,
|
|
889
|
+
* otherwise EnvironmentHandle if ConnectionHandle is SQL_NULL_HANDLE. It
|
|
890
|
+
* returns SQL_NO_DATA (and Sqlstate is "00000") after the last record. The
|
|
891
|
+
* other arguments are the same as SQLGetDiagRec.
|
|
892
|
+
*
|
|
893
|
+
* SQLCHAR sqlstate[6], msg[256];
|
|
894
|
+
*
|
|
895
|
+
* while (SQLError(SQL_NULL_HANDLE, SQL_NULL_HANDLE, stmt, sqlstate, NULL,
|
|
896
|
+
* msg, sizeof(msg), NULL) == SQL_SUCCESS) {
|
|
897
|
+
* printf("%s %s\n", sqlstate, msg);
|
|
898
|
+
* }
|
|
899
|
+
*/
|
|
900
|
+
SQLRETURN SQLError(
|
|
901
|
+
SQLHENV EnvironmentHandle,
|
|
902
|
+
SQLHDBC ConnectionHandle,
|
|
903
|
+
SQLHSTMT StatementHandle,
|
|
904
|
+
SQLCHAR *Sqlstate,
|
|
905
|
+
SQLINTEGER *NativeError,
|
|
906
|
+
SQLCHAR *MessageText,
|
|
907
|
+
SQLSMALLINT BufferLength,
|
|
908
|
+
SQLSMALLINT *TextLength
|
|
909
|
+
);
|
|
910
|
+
|
|
911
|
+
/*
|
|
912
|
+
* SQLExecDirect executes an SQL statement. TextLength is the length in octets,
|
|
913
|
+
* or SQL_NTS for a null terminated string. A query opens a cursor that's read
|
|
914
|
+
* with SQLFetch and must be closed with SQLCloseCursor before executing
|
|
915
|
+
* another statement.
|
|
916
|
+
*
|
|
917
|
+
* A transaction is started if there isn't one, and it must be ended with
|
|
918
|
+
* SQLEndTran, so START TRANSACTION, COMMIT and ROLLBACK can't be executed
|
|
919
|
+
* (42000). A "--" comment isn't allowed either (42000).
|
|
920
|
+
*
|
|
921
|
+
* SQLExecDirect(stmt, (SQLCHAR *)"CREATE TABLE foo (x DOUBLE PRECISION)",
|
|
922
|
+
* SQL_NTS);
|
|
923
|
+
* SQLExecDirect(stmt, (SQLCHAR *)"INSERT INTO foo (x) VALUES (1.23)",
|
|
924
|
+
* SQL_NTS);
|
|
925
|
+
*/
|
|
926
|
+
SQLRETURN SQLExecDirect(
|
|
927
|
+
SQLHSTMT StatementHandle,
|
|
928
|
+
SQLCHAR *StatementText,
|
|
929
|
+
SQLINTEGER TextLength
|
|
930
|
+
);
|
|
931
|
+
|
|
932
|
+
/*
|
|
933
|
+
* SQLExecute executes the statement prepared by SQLPrepare (which can be
|
|
934
|
+
* executed again), the same as SQLExecDirect. It returns SQL_NEED_DATA if a
|
|
935
|
+
* parameter is SQL_DATA_AT_EXEC, see SQLParamData.
|
|
936
|
+
*/
|
|
937
|
+
SQLRETURN SQLExecute(
|
|
938
|
+
SQLHSTMT StatementHandle
|
|
939
|
+
);
|
|
940
|
+
|
|
941
|
+
/*
|
|
942
|
+
* SQLFetch moves the cursor to the next row, which is read with SQLGetData (or
|
|
943
|
+
* set in the columns bound with SQLBindCol). It returns SQL_NO_DATA after the
|
|
944
|
+
* last row.
|
|
945
|
+
*
|
|
946
|
+
* With an SQL_DESC_ARRAY_SIZE greater than 1 in the ARD, it fetches a rowset of
|
|
947
|
+
* that many rows into the bound arrays. The SQL_DESC_ROWS_PROCESSED_POINTER of
|
|
948
|
+
* the IRD is set to the number of rows fetched, and its
|
|
949
|
+
* SQL_DESC_ARRAY_STATUS_POINTER (an SQLINTEGER array) to the status of each
|
|
950
|
+
* row, such as SQL_ROW_SUCCESS or SQL_ROW_NO_ROW. A row that can't be fetched
|
|
951
|
+
* (such as a number that's out of range) is SQL_ROW_ERROR and returns
|
|
952
|
+
* SQL_SUCCESS_WITH_INFO (or SQL_ERROR if no rows could be fetched), and its
|
|
953
|
+
* diagnostics have the SQL_DIAG_ROW_NUMBER and SQL_DIAG_COLUMN_NUMBER.
|
|
954
|
+
*
|
|
955
|
+
* SQLRETURN rc;
|
|
956
|
+
* SQLDOUBLE x;
|
|
957
|
+
*
|
|
958
|
+
* SQLExecDirect(stmt, (SQLCHAR *)"SELECT * FROM foo", SQL_NTS);
|
|
959
|
+
* while ((rc = SQLFetch(stmt)) == SQL_SUCCESS) {
|
|
960
|
+
* SQLGetData(stmt, 1, SQL_DOUBLE, &x, 0, NULL);
|
|
961
|
+
* }
|
|
962
|
+
*/
|
|
963
|
+
SQLRETURN SQLFetch(
|
|
964
|
+
SQLHSTMT StatementHandle
|
|
965
|
+
);
|
|
966
|
+
|
|
967
|
+
/*
|
|
968
|
+
* SQLFetchScroll moves the cursor to a rowset (see SQL_FETCH_NEXT and the
|
|
969
|
+
* others). Anything other than SQL_FETCH_NEXT needs SQL_ATTR_CURSOR_SCROLLABLE
|
|
970
|
+
* to be SQL_SCROLLABLE. It returns SQL_NO_DATA when there's no rowset there.
|
|
971
|
+
*/
|
|
972
|
+
SQLRETURN SQLFetchScroll(
|
|
973
|
+
SQLHSTMT StatementHandle,
|
|
974
|
+
SQLSMALLINT FetchOrientation,
|
|
975
|
+
SQLINTEGER FetchOffset
|
|
976
|
+
);
|
|
977
|
+
|
|
978
|
+
/*
|
|
979
|
+
* SQLForeignKeys returns a result set that describes the columns of foreign
|
|
980
|
+
* keys, from the INFORMATION_SCHEMA. With a PKTableName, it's the foreign keys
|
|
981
|
+
* that reference the PRIMARY KEY of that table. With an FKTableName, it's the
|
|
982
|
+
* foreign keys of that table (and the PRIMARY KEY or UNIQUE that each one
|
|
983
|
+
* references). The names are not patterns.
|
|
984
|
+
*
|
|
985
|
+
* Its columns are UK_TABLE_CAT, UK_TABLE_SCHEM, UK_TABLE_NAME, UK_COLUMN_NAME,
|
|
986
|
+
* FK_TABLE_CAT, FK_TABLE_SCHEM, FK_TABLE_NAME, FK_COLUMN_NAME,
|
|
987
|
+
* ORDINAL_POSITION, UPDATE_RULE and DELETE_RULE (such as SQL_CASCADE),
|
|
988
|
+
* FK_NAME, UK_NAME, DEFERABILITY (always SQL_NOT_DEFERRABLE) and
|
|
989
|
+
* UNIQUE_OR_PRIMARY ("UNIQUE " or "PRIMARY").
|
|
990
|
+
*/
|
|
991
|
+
SQLRETURN SQLForeignKeys(
|
|
992
|
+
SQLHSTMT StatementHandle,
|
|
993
|
+
SQLCHAR *PKCatalogName,
|
|
994
|
+
SQLSMALLINT NameLength1,
|
|
995
|
+
SQLCHAR *PKSchemaName,
|
|
996
|
+
SQLSMALLINT NameLength2,
|
|
997
|
+
SQLCHAR *PKTableName,
|
|
998
|
+
SQLSMALLINT NameLength3,
|
|
999
|
+
SQLCHAR *FKCatalogName,
|
|
1000
|
+
SQLSMALLINT NameLength4,
|
|
1001
|
+
SQLCHAR *FKSchemaName,
|
|
1002
|
+
SQLSMALLINT NameLength5,
|
|
1003
|
+
SQLCHAR *FKTableName,
|
|
1004
|
+
SQLSMALLINT NameLength6
|
|
1005
|
+
);
|
|
1006
|
+
|
|
1007
|
+
/*
|
|
1008
|
+
* SQLFreeConnect is the same as SQLFreeHandle(SQL_HANDLE_DBC,
|
|
1009
|
+
* ConnectionHandle).
|
|
1010
|
+
*/
|
|
1011
|
+
SQLRETURN SQLFreeConnect(
|
|
1012
|
+
SQLHDBC ConnectionHandle
|
|
1013
|
+
);
|
|
1014
|
+
|
|
1015
|
+
/*
|
|
1016
|
+
* SQLFreeEnv is the same as SQLFreeHandle(SQL_HANDLE_ENV, EnvironmentHandle).
|
|
1017
|
+
*/
|
|
1018
|
+
SQLRETURN SQLFreeEnv(
|
|
1019
|
+
SQLHENV EnvironmentHandle
|
|
1020
|
+
);
|
|
1021
|
+
|
|
1022
|
+
/*
|
|
1023
|
+
* SQLFreeHandle frees a handle from SQLAllocHandle. A connection must be
|
|
1024
|
+
* disconnected first, and an environment can only be freed after its
|
|
1025
|
+
* connections. Freeing a statement closes its cursor.
|
|
1026
|
+
*
|
|
1027
|
+
* SQLFreeHandle(SQL_HANDLE_STMT, stmt);
|
|
1028
|
+
* SQLDisconnect(dbc);
|
|
1029
|
+
* SQLFreeHandle(SQL_HANDLE_DBC, dbc);
|
|
1030
|
+
* SQLFreeHandle(SQL_HANDLE_ENV, env);
|
|
1031
|
+
*/
|
|
1032
|
+
SQLRETURN SQLFreeHandle(
|
|
1033
|
+
SQLSMALLINT HandleType,
|
|
1034
|
+
SQLINTEGER Handle
|
|
1035
|
+
);
|
|
1036
|
+
|
|
1037
|
+
/*
|
|
1038
|
+
* SQLFreeStmt does one of the following, depending on Option:
|
|
1039
|
+
*
|
|
1040
|
+
* SQL_CLOSE_CURSOR closes the cursor, if there is one
|
|
1041
|
+
* SQL_FREE_HANDLE the same as SQLFreeHandle(SQL_HANDLE_STMT, ...)
|
|
1042
|
+
* SQL_UNBIND_COLUMNS unbinds every column
|
|
1043
|
+
* SQL_UNBIND_PARAMETERS unbinds every parameter
|
|
1044
|
+
* SQL_REALLOCATE closes the cursor and forgets the statement
|
|
1045
|
+
*
|
|
1046
|
+
* SQLFreeStmt(stmt, SQL_CLOSE_CURSOR);
|
|
1047
|
+
*/
|
|
1048
|
+
SQLRETURN SQLFreeStmt(
|
|
1049
|
+
SQLHSTMT StatementHandle,
|
|
1050
|
+
SQLSMALLINT Option
|
|
1051
|
+
);
|
|
1052
|
+
|
|
1053
|
+
/*
|
|
1054
|
+
* SQLGetConnectAttr reads an attribute of a connection:
|
|
1055
|
+
*
|
|
1056
|
+
* SQL_ATTR_AUTO_IPD SQLINTEGER, always SQL_FALSE
|
|
1057
|
+
* SQL_ATTR_SAVEPOINT_NAME string, see SQLGetData for SQL_CHAR
|
|
1058
|
+
* SQL_ATTR_AUTOCOMMIT SQLINTEGER, SQL_AUTOCOMMIT_OFF or _ON
|
|
1059
|
+
*
|
|
1060
|
+
* BufferLength and StringLength are only used for a string.
|
|
1061
|
+
*/
|
|
1062
|
+
SQLRETURN SQLGetConnectAttr(
|
|
1063
|
+
SQLHDBC ConnectionHandle,
|
|
1064
|
+
SQLINTEGER Attribute,
|
|
1065
|
+
SQLPOINTER Value,
|
|
1066
|
+
SQLINTEGER BufferLength,
|
|
1067
|
+
SQLINTEGER *StringLength
|
|
1068
|
+
);
|
|
1069
|
+
|
|
1070
|
+
/*
|
|
1071
|
+
* SQLGetCursorName reads the name of the statement's cursor (see
|
|
1072
|
+
* SQLGetData for SQL_CHAR). A statement that doesn't have one is given a
|
|
1073
|
+
* unique name that starts with "SQL_CUR".
|
|
1074
|
+
*/
|
|
1075
|
+
SQLRETURN SQLGetCursorName(
|
|
1076
|
+
SQLHSTMT StatementHandle,
|
|
1077
|
+
SQLCHAR *CursorName,
|
|
1078
|
+
SQLSMALLINT BufferLength,
|
|
1079
|
+
SQLSMALLINT *NameLength
|
|
1080
|
+
);
|
|
1081
|
+
|
|
1082
|
+
/*
|
|
1083
|
+
* SQLGetData reads a column (starting at 1) of the fetched row, converted to
|
|
1084
|
+
* TargetType:
|
|
1085
|
+
*
|
|
1086
|
+
* SQL_CHAR char[BufferLength], null terminated
|
|
1087
|
+
* SQL_SMALLINT SQLSMALLINT
|
|
1088
|
+
* SQL_INTEGER SQLINTEGER
|
|
1089
|
+
* SQL_BIGINT SQLBIGINT
|
|
1090
|
+
* SQL_REAL SQLREAL
|
|
1091
|
+
* SQL_DOUBLE SQLDOUBLE
|
|
1092
|
+
* SQL_DEFAULT the type of the column
|
|
1093
|
+
* SQL_ARD_TYPE the SQL_DESC_TYPE of the column in the ARD
|
|
1094
|
+
*
|
|
1095
|
+
* The SQL_DESC_TYPE of the column in the ARD (if it has a record for the
|
|
1096
|
+
* column) is set to TargetType. A column that's bound in the ARD can't be read
|
|
1097
|
+
* with SQLGetData (07009).
|
|
1098
|
+
*
|
|
1099
|
+
* BufferLength is only used for SQL_CHAR. StrLen_or_Ind is set to SQL_NULL_DATA
|
|
1100
|
+
* for a NULL value (so it can only be a null pointer when the value isn't
|
|
1101
|
+
* NULL), otherwise it's set to the length of the string still to be read (or
|
|
1102
|
+
* 0 for a number). A string that doesn't fit returns SQL_SUCCESS_WITH_INFO,
|
|
1103
|
+
* and calling SQLGetData again for the same column reads the next piece.
|
|
1104
|
+
*
|
|
1105
|
+
* char buf[6];
|
|
1106
|
+
* SQLINTEGER ind;
|
|
1107
|
+
*
|
|
1108
|
+
* SQLExecDirect(stmt, (SQLCHAR *)"VALUES 'hello world'", SQL_NTS);
|
|
1109
|
+
* SQLFetch(stmt);
|
|
1110
|
+
* SQLGetData(stmt, 1, SQL_CHAR, buf, sizeof(buf), &ind);
|
|
1111
|
+
* SQLGetData(stmt, 1, SQL_CHAR, buf, sizeof(buf), &ind);
|
|
1112
|
+
* SQLGetData(stmt, 1, SQL_CHAR, buf, sizeof(buf), &ind);
|
|
1113
|
+
*
|
|
1114
|
+
* The first call returns SQL_SUCCESS_WITH_INFO with "hello" (ind is 11), the
|
|
1115
|
+
* second returns SQL_SUCCESS_WITH_INFO with " worl" (ind is 6), and the third
|
|
1116
|
+
* returns SQL_SUCCESS with "d" (ind is 1).
|
|
1117
|
+
*/
|
|
1118
|
+
SQLRETURN SQLGetData(
|
|
1119
|
+
SQLHSTMT StatementHandle,
|
|
1120
|
+
SQLSMALLINT ColumnNumber,
|
|
1121
|
+
SQLSMALLINT TargetType,
|
|
1122
|
+
SQLPOINTER TargetValue,
|
|
1123
|
+
SQLINTEGER BufferLength,
|
|
1124
|
+
SQLINTEGER *StrLen_or_Ind
|
|
1125
|
+
);
|
|
1126
|
+
|
|
1127
|
+
/*
|
|
1128
|
+
* SQLGetDescField reads a field of a descriptor. A header field (such as
|
|
1129
|
+
* SQL_DESC_COUNT) ignores RecordNumber, and a record field (such as
|
|
1130
|
+
* SQL_DESC_TYPE) reads the record numbered from 1. It returns SQL_NO_DATA if
|
|
1131
|
+
* there isn't a record with that number.
|
|
1132
|
+
*
|
|
1133
|
+
* Value is an SQLSMALLINT, an SQLINTEGER, a pointer or a string (see
|
|
1134
|
+
* SQLGetData for SQL_CHAR), depending on the field. A field that was never set
|
|
1135
|
+
* is HY091, and so is a field that can't be read from that type of descriptor.
|
|
1136
|
+
* An IRD can only be read after a statement is executed.
|
|
1137
|
+
*
|
|
1138
|
+
* Each statement has four descriptors, which are its attributes:
|
|
1139
|
+
*
|
|
1140
|
+
* SQL_ATTR_APP_ROW_DESC the ARD, which binds the columns
|
|
1141
|
+
* SQL_ATTR_APP_PARAM_DESC the APD, which binds the parameters
|
|
1142
|
+
* SQL_ATTR_IMP_ROW_DESC the IRD, which describes the columns
|
|
1143
|
+
* SQL_ATTR_IMP_PARAM_DESC the IPD, which describes the parameters
|
|
1144
|
+
*
|
|
1145
|
+
* SQLHDESC ird;
|
|
1146
|
+
* SQLSMALLINT type;
|
|
1147
|
+
*
|
|
1148
|
+
* SQLExecDirect(stmt, (SQLCHAR *)"SELECT * FROM foo", SQL_NTS);
|
|
1149
|
+
* SQLGetStmtAttr(stmt, SQL_ATTR_IMP_ROW_DESC, &ird, 0, NULL);
|
|
1150
|
+
* SQLGetDescField(ird, 1, SQL_DESC_TYPE, &type, 0, NULL);
|
|
1151
|
+
*/
|
|
1152
|
+
SQLRETURN SQLGetDescField(
|
|
1153
|
+
SQLHDESC DescriptorHandle,
|
|
1154
|
+
SQLSMALLINT RecordNumber,
|
|
1155
|
+
SQLSMALLINT FieldIdentifier,
|
|
1156
|
+
SQLPOINTER Value,
|
|
1157
|
+
SQLINTEGER BufferLength,
|
|
1158
|
+
SQLINTEGER *StringLength
|
|
1159
|
+
);
|
|
1160
|
+
|
|
1161
|
+
/*
|
|
1162
|
+
* SQLGetDescRec reads the SQL_DESC_NAME, SQL_DESC_TYPE,
|
|
1163
|
+
* SQL_DESC_DATETIME_INTERVAL_CODE (SubType), SQL_DESC_OCTET_LENGTH (Length),
|
|
1164
|
+
* SQL_DESC_PRECISION, SQL_DESC_SCALE and SQL_DESC_NULLABLE fields of a record
|
|
1165
|
+
* (starting at 1) of a descriptor. Any of them may be a null pointer. It
|
|
1166
|
+
* returns SQL_NO_DATA if there isn't a record with that number.
|
|
1167
|
+
*/
|
|
1168
|
+
SQLRETURN SQLGetDescRec(
|
|
1169
|
+
SQLHDESC DescriptorHandle,
|
|
1170
|
+
SQLSMALLINT RecordNumber,
|
|
1171
|
+
SQLCHAR *Name,
|
|
1172
|
+
SQLSMALLINT BufferLength,
|
|
1173
|
+
SQLSMALLINT *NameLength,
|
|
1174
|
+
SQLSMALLINT *Type,
|
|
1175
|
+
SQLSMALLINT *SubType,
|
|
1176
|
+
SQLINTEGER *Length,
|
|
1177
|
+
SQLSMALLINT *Precision,
|
|
1178
|
+
SQLSMALLINT *Scale,
|
|
1179
|
+
SQLSMALLINT *Nullable
|
|
1180
|
+
);
|
|
1181
|
+
|
|
1182
|
+
/*
|
|
1183
|
+
* SQLGetDiagField reads one field of the diagnostics for the last routine that
|
|
1184
|
+
* was called with a handle (other than SQLError, SQLGetDiagField and
|
|
1185
|
+
* SQLGetDiagRec). A header field (such as SQL_DIAG_NUMBER, the number of
|
|
1186
|
+
* records) ignores RecordNumber, and a record field (such as
|
|
1187
|
+
* SQL_DIAG_SQLSTATE) reads the record numbered from 1. It returns SQL_NO_DATA
|
|
1188
|
+
* if there isn't a record with that number.
|
|
1189
|
+
*
|
|
1190
|
+
* DiagInfo is an SQLSMALLINT for SQL_DIAG_RETURNCODE, an SQLINTEGER for the
|
|
1191
|
+
* other numbers, or a null terminated string that's truncated to fit in
|
|
1192
|
+
* BufferLength. StringLength may be a null pointer, otherwise it's set to the
|
|
1193
|
+
* length of the whole string. The fields are:
|
|
1194
|
+
*
|
|
1195
|
+
* SQL_DIAG_NUMBER the number of records
|
|
1196
|
+
* SQL_DIAG_RETURNCODE what the routine returned
|
|
1197
|
+
* SQL_DIAG_ROW_COUNT see SQLRowCount (only for statements)
|
|
1198
|
+
* SQL_DIAG_DYNAMIC_FUNCTION such as "INSERT", or "" if the routine
|
|
1199
|
+
* didn't execute a statement
|
|
1200
|
+
* SQL_DIAG_DYNAMIC_FUNCTION_CODE such as SQL_DIAG_INSERT, or 0
|
|
1201
|
+
* SQL_DIAG_TRANSACTIONS_COMMITTED transactions committed by the routine
|
|
1202
|
+
* SQL_DIAG_TRANSACTIONS_ROLLED_BACK transactions rolled back by the routine
|
|
1203
|
+
* SQL_DIAG_TRANSACTION_ACTIVE 1 if a transaction is active, or 0
|
|
1204
|
+
* SQL_DIAG_MORE always 0
|
|
1205
|
+
*
|
|
1206
|
+
* SQL_DIAG_SQLSTATE the SQLSTATE
|
|
1207
|
+
* SQL_DIAG_MESSAGE_TEXT the message
|
|
1208
|
+
* SQL_DIAG_MESSAGE_LENGTH the length of the message in characters
|
|
1209
|
+
* SQL_DIAG_MESSAGE_OCTET_LENGTH the length of the message in octets
|
|
1210
|
+
* SQL_DIAG_CLASS_ORIGIN "ISO 9075" if the class of the SQLSTATE
|
|
1211
|
+
* is from the standard, otherwise "vsql"
|
|
1212
|
+
* SQL_DIAG_SUBCLASS_ORIGIN the same, for the subclass
|
|
1213
|
+
* SQL_DIAG_SERVER_NAME the ServerName of the connection
|
|
1214
|
+
* SQL_DIAG_CONNECTION_NAME the same as SQL_DIAG_SERVER_NAME
|
|
1215
|
+
* SQL_DIAG_CONDITION_NUMBER the record number
|
|
1216
|
+
* SQL_DIAG_COLUMN_NUMBER the column, or 0
|
|
1217
|
+
* SQL_DIAG_ROW_NUMBER the row, or 0
|
|
1218
|
+
* SQL_DIAG_NATIVE_CODE always 0
|
|
1219
|
+
*
|
|
1220
|
+
* Every other record field is "" (or 0 for
|
|
1221
|
+
* SQL_DIAG_PARAMETER_ORDINAL_POSITION).
|
|
1222
|
+
*
|
|
1223
|
+
* SQLINTEGER rows;
|
|
1224
|
+
*
|
|
1225
|
+
* SQLExecDirect(stmt, (SQLCHAR *)"DELETE FROM foo", SQL_NTS);
|
|
1226
|
+
* SQLGetDiagField(SQL_HANDLE_STMT, stmt, 0, SQL_DIAG_ROW_COUNT, &rows, 0,
|
|
1227
|
+
* NULL);
|
|
1228
|
+
*/
|
|
1229
|
+
SQLRETURN SQLGetDiagField(
|
|
1230
|
+
SQLSMALLINT HandleType,
|
|
1231
|
+
SQLINTEGER Handle,
|
|
1232
|
+
SQLSMALLINT RecordNumber,
|
|
1233
|
+
SQLSMALLINT DiagIdentifier,
|
|
1234
|
+
SQLPOINTER DiagInfo,
|
|
1235
|
+
SQLSMALLINT BufferLength,
|
|
1236
|
+
SQLSMALLINT *StringLength
|
|
1237
|
+
);
|
|
1238
|
+
|
|
1239
|
+
/*
|
|
1240
|
+
* SQLGetDiagRec reads a diagnostic record (starting at 1) for the last routine
|
|
1241
|
+
* that was called with the handle. It returns SQL_NO_DATA when there are no
|
|
1242
|
+
* more records. Sqlstate needs room for 6 octets. The message is null
|
|
1243
|
+
* terminated and truncated to fit in BufferLength. Sqlstate, NativeError,
|
|
1244
|
+
* MessageText and TextLength may each be a null pointer.
|
|
1245
|
+
*
|
|
1246
|
+
* SQLCHAR sqlstate[6], msg[256];
|
|
1247
|
+
*
|
|
1248
|
+
* if (SQLExecDirect(stmt, (SQLCHAR *)"SELECT * FROM bar", SQL_NTS) ==
|
|
1249
|
+
* SQL_ERROR) {
|
|
1250
|
+
* SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, sqlstate, NULL, msg,
|
|
1251
|
+
* sizeof(msg), NULL);
|
|
1252
|
+
* }
|
|
1253
|
+
*
|
|
1254
|
+
* sqlstate is "42P01" and msg is "no such table: ...".
|
|
1255
|
+
*/
|
|
1256
|
+
SQLRETURN SQLGetDiagRec(
|
|
1257
|
+
SQLSMALLINT HandleType,
|
|
1258
|
+
SQLINTEGER Handle,
|
|
1259
|
+
SQLSMALLINT RecordNumber,
|
|
1260
|
+
SQLCHAR *Sqlstate,
|
|
1261
|
+
SQLINTEGER *NativeError,
|
|
1262
|
+
SQLCHAR *MessageText,
|
|
1263
|
+
SQLSMALLINT BufferLength,
|
|
1264
|
+
SQLSMALLINT *TextLength
|
|
1265
|
+
);
|
|
1266
|
+
|
|
1267
|
+
/*
|
|
1268
|
+
* SQLGetEnvAttr reads an attribute of an environment. The only one is
|
|
1269
|
+
* SQL_ATTR_OUTPUT_NTS (an SQLINTEGER), see SQLSetEnvAttr. BufferLength and
|
|
1270
|
+
* StringLength are not used.
|
|
1271
|
+
*
|
|
1272
|
+
* SQLINTEGER nts;
|
|
1273
|
+
*
|
|
1274
|
+
* SQLGetEnvAttr(env, SQL_ATTR_OUTPUT_NTS, &nts, 0, NULL);
|
|
1275
|
+
*/
|
|
1276
|
+
SQLRETURN SQLGetEnvAttr(
|
|
1277
|
+
SQLHENV EnvironmentHandle,
|
|
1278
|
+
SQLINTEGER Attribute,
|
|
1279
|
+
SQLPOINTER Value,
|
|
1280
|
+
SQLINTEGER BufferLength,
|
|
1281
|
+
SQLINTEGER *StringLength
|
|
1282
|
+
);
|
|
1283
|
+
|
|
1284
|
+
/*
|
|
1285
|
+
* SQLGetFeatureInfo sets Supported to 1 if vsql supports a feature ("FEATURE"
|
|
1286
|
+
* with an id such as "E011") or a subfeature ("SUBFEATURE" with "E011" and
|
|
1287
|
+
* "01"), otherwise 0. An unknown feature, or a "PACKAGE", is HY024. See
|
|
1288
|
+
* https://vsql.readthedocs.io/en/latest/sql-compliance.html
|
|
1289
|
+
*
|
|
1290
|
+
* SQLSMALLINT supported;
|
|
1291
|
+
*
|
|
1292
|
+
* SQLGetFeatureInfo(dbc, (SQLCHAR *)"FEATURE", SQL_NTS, (SQLCHAR *)"E011",
|
|
1293
|
+
* SQL_NTS, NULL, 0, &supported);
|
|
1294
|
+
*/
|
|
1295
|
+
SQLRETURN SQLGetFeatureInfo(
|
|
1296
|
+
SQLHDBC ConnectionHandle,
|
|
1297
|
+
SQLCHAR *FeatureType,
|
|
1298
|
+
SQLSMALLINT FeatureTypeLength,
|
|
1299
|
+
SQLCHAR *FeatureId,
|
|
1300
|
+
SQLSMALLINT FeatureIdLength,
|
|
1301
|
+
SQLCHAR *SubFeatureId,
|
|
1302
|
+
SQLSMALLINT SubFeatureIdLength,
|
|
1303
|
+
SQLSMALLINT *Supported
|
|
1304
|
+
);
|
|
1305
|
+
|
|
1306
|
+
/*
|
|
1307
|
+
* SQLGetFunctions sets Supported to 1 if a routine (one of the SQL_API_*
|
|
1308
|
+
* FunctionIds) is supported, otherwise 0.
|
|
1309
|
+
*
|
|
1310
|
+
* SQLSMALLINT supported;
|
|
1311
|
+
*
|
|
1312
|
+
* SQLGetFunctions(dbc, SQL_API_SQLFETCHSCROLL, &supported);
|
|
1313
|
+
*/
|
|
1314
|
+
SQLRETURN SQLGetFunctions(
|
|
1315
|
+
SQLHDBC ConnectionHandle,
|
|
1316
|
+
SQLSMALLINT FunctionId,
|
|
1317
|
+
SQLSMALLINT *Supported
|
|
1318
|
+
);
|
|
1319
|
+
|
|
1320
|
+
/*
|
|
1321
|
+
* SQLGetInfo reads information about the connection and vsql. InfoType is one
|
|
1322
|
+
* of the SQLGetInfo InfoTypes, and each one is a string (written like
|
|
1323
|
+
* SQLGetData, with BufferLength and StringLength), an SQLSMALLINT or an
|
|
1324
|
+
* SQLINTEGER (see the constants).
|
|
1325
|
+
*
|
|
1326
|
+
* SQLCHAR version[64];
|
|
1327
|
+
* SQLSMALLINT max_name;
|
|
1328
|
+
*
|
|
1329
|
+
* SQLGetInfo(dbc, SQL_DBMS_VERSION, version, sizeof(version), NULL);
|
|
1330
|
+
* SQLGetInfo(dbc, SQL_MAXIMUM_TABLE_NAME_LENGTH, &max_name, 0, NULL);
|
|
1331
|
+
*/
|
|
1332
|
+
SQLRETURN SQLGetInfo(
|
|
1333
|
+
SQLHDBC ConnectionHandle,
|
|
1334
|
+
SQLSMALLINT InfoType,
|
|
1335
|
+
SQLPOINTER InfoValue,
|
|
1336
|
+
SQLSMALLINT BufferLength,
|
|
1337
|
+
SQLSMALLINT *StringLength
|
|
1338
|
+
);
|
|
1339
|
+
|
|
1340
|
+
/*
|
|
1341
|
+
* SQLGetLength would read the length of the value of a large object locator.
|
|
1342
|
+
* vsql doesn't have large objects, so it always returns SQL_ERROR with SQLSTATE
|
|
1343
|
+
* HYC00 (optional feature not implemented).
|
|
1344
|
+
*/
|
|
1345
|
+
SQLRETURN SQLGetLength(
|
|
1346
|
+
SQLHSTMT StatementHandle,
|
|
1347
|
+
SQLSMALLINT LocatorType,
|
|
1348
|
+
SQLINTEGER Locator,
|
|
1349
|
+
SQLINTEGER *StringLength,
|
|
1350
|
+
SQLINTEGER *IndicatorValue
|
|
1351
|
+
);
|
|
1352
|
+
|
|
1353
|
+
/*
|
|
1354
|
+
* SQLGetParamData would read the value of a dynamic output parameter. vsql
|
|
1355
|
+
* doesn't have procedures (or SQL_PARAM_MODE_OUT), so it always returns
|
|
1356
|
+
* SQL_ERROR with SQLSTATE HYC00 (optional feature not implemented).
|
|
1357
|
+
*/
|
|
1358
|
+
SQLRETURN SQLGetParamData(
|
|
1359
|
+
SQLHSTMT StatementHandle,
|
|
1360
|
+
SQLSMALLINT ParameterNumber,
|
|
1361
|
+
SQLSMALLINT TargetType,
|
|
1362
|
+
SQLPOINTER TargetValue,
|
|
1363
|
+
SQLINTEGER BufferLength,
|
|
1364
|
+
SQLINTEGER *StrLen_or_Ind
|
|
1365
|
+
);
|
|
1366
|
+
|
|
1367
|
+
/*
|
|
1368
|
+
* SQLGetPosition would find a string within the value of a large object
|
|
1369
|
+
* locator.
|
|
1370
|
+
* vsql doesn't have large objects, so it always returns SQL_ERROR with SQLSTATE
|
|
1371
|
+
* HYC00 (optional feature not implemented).
|
|
1372
|
+
*/
|
|
1373
|
+
SQLRETURN SQLGetPosition(
|
|
1374
|
+
SQLHSTMT StatementHandle,
|
|
1375
|
+
SQLSMALLINT LocatorType,
|
|
1376
|
+
SQLINTEGER SourceLocator,
|
|
1377
|
+
SQLINTEGER SearchLocator,
|
|
1378
|
+
SQLCHAR *SearchLiteral,
|
|
1379
|
+
SQLINTEGER SearchLiteralLength,
|
|
1380
|
+
SQLINTEGER FromPosition,
|
|
1381
|
+
SQLINTEGER *LocatedAt,
|
|
1382
|
+
SQLINTEGER *IndicatorValue
|
|
1383
|
+
);
|
|
1384
|
+
|
|
1385
|
+
/*
|
|
1386
|
+
* SQLGetSessionInfo reads the value of CURRENT_USER (SQL_CURRENT_USER),
|
|
1387
|
+
* SESSION_USER (SQL_SESSION_USER), etc. as a string (see SQLGetData for
|
|
1388
|
+
* SQL_CHAR) by selecting it with SQLExecDirect. vsql doesn't support any of
|
|
1389
|
+
* them yet, so it returns SQL_ERROR with the syntax error.
|
|
1390
|
+
*/
|
|
1391
|
+
SQLRETURN SQLGetSessionInfo(
|
|
1392
|
+
SQLHDBC ConnectionHandle,
|
|
1393
|
+
SQLSMALLINT InfoType,
|
|
1394
|
+
SQLPOINTER InfoValue,
|
|
1395
|
+
SQLSMALLINT BufferLength,
|
|
1396
|
+
SQLSMALLINT *StringLength
|
|
1397
|
+
);
|
|
1398
|
+
|
|
1399
|
+
/*
|
|
1400
|
+
* SQLGetStmtAttr reads an attribute of a statement (an SQLINTEGER), such as
|
|
1401
|
+
* SQL_ATTR_IMP_ROW_DESC (see SQLGetDescField) or SQL_ATTR_CURSOR_SCROLLABLE.
|
|
1402
|
+
* BufferLength and StringLength are not used.
|
|
1403
|
+
*/
|
|
1404
|
+
SQLRETURN SQLGetStmtAttr(
|
|
1405
|
+
SQLHSTMT StatementHandle,
|
|
1406
|
+
SQLINTEGER Attribute,
|
|
1407
|
+
SQLPOINTER Value,
|
|
1408
|
+
SQLINTEGER BufferLength,
|
|
1409
|
+
SQLINTEGER *StringLength
|
|
1410
|
+
);
|
|
1411
|
+
|
|
1412
|
+
/*
|
|
1413
|
+
* SQLGetSubString would read part of the value of a large object locator.
|
|
1414
|
+
* vsql doesn't have large objects, so it always returns SQL_ERROR with SQLSTATE
|
|
1415
|
+
* HYC00 (optional feature not implemented).
|
|
1416
|
+
*/
|
|
1417
|
+
SQLRETURN SQLGetSubString(
|
|
1418
|
+
SQLHSTMT StatementHandle,
|
|
1419
|
+
SQLSMALLINT LocatorType,
|
|
1420
|
+
SQLINTEGER SourceLocator,
|
|
1421
|
+
SQLINTEGER FromPosition,
|
|
1422
|
+
SQLINTEGER ForLength,
|
|
1423
|
+
SQLSMALLINT TargetType,
|
|
1424
|
+
SQLPOINTER TargetValue,
|
|
1425
|
+
SQLINTEGER BufferLength,
|
|
1426
|
+
SQLINTEGER *StringLength,
|
|
1427
|
+
SQLINTEGER *IndicatorValue
|
|
1428
|
+
);
|
|
1429
|
+
|
|
1430
|
+
/*
|
|
1431
|
+
* SQLGetTypeInfo returns a result set that describes a data type (such as
|
|
1432
|
+
* SQL_VARCHAR), or each data type (SQL_ALL_TYPES). Its columns are TYPE_NAME,
|
|
1433
|
+
* DATA_TYPE, COLUMN_SIZE, LITERAL_PREFIX, LITERAL_SUFFIX, CREATE_PARAMS,
|
|
1434
|
+
* NULLABLE, CASE_SENSITIVE, SEARCHABLE, UNSIGNED_ATTRIBUTE, FIXED_PREC_SCALE,
|
|
1435
|
+
* AUTO_UNIQUE_VALUE, LOCAL_TYPE_NAME, MINIMUM_SCALE, MAXIMUM_SCALE,
|
|
1436
|
+
* SQL_DATA_TYPE, SQL_DATETIME_SUB, NUM_PREC_RADIX and INTERVAL_PRECISION.
|
|
1437
|
+
*/
|
|
1438
|
+
SQLRETURN SQLGetTypeInfo(
|
|
1439
|
+
SQLHSTMT StatementHandle,
|
|
1440
|
+
SQLSMALLINT DataType
|
|
1441
|
+
);
|
|
1442
|
+
|
|
1443
|
+
/*
|
|
1444
|
+
* SQLMoreResults closes the cursor, and moves to the next result set of the
|
|
1445
|
+
* executed statement. There's only ever one, so it returns SQL_NO_DATA (with
|
|
1446
|
+
* SQLSTATE 02001).
|
|
1447
|
+
*/
|
|
1448
|
+
SQLRETURN SQLMoreResults(
|
|
1449
|
+
SQLHSTMT StatementHandle
|
|
1450
|
+
);
|
|
1451
|
+
|
|
1452
|
+
/*
|
|
1453
|
+
* SQLNextResult opens the next result set of StatementHandle1 on
|
|
1454
|
+
* StatementHandle2. There's only ever one result set, so it returns
|
|
1455
|
+
* SQL_NO_DATA (with SQLSTATE 02001).
|
|
1456
|
+
*/
|
|
1457
|
+
SQLRETURN SQLNextResult(
|
|
1458
|
+
SQLHSTMT StatementHandle1,
|
|
1459
|
+
SQLHSTMT StatementHandle2
|
|
1460
|
+
);
|
|
1461
|
+
|
|
1462
|
+
/*
|
|
1463
|
+
* SQLNumResultCols sets ColumnCount to the number of columns of the cursor, or
|
|
1464
|
+
* 0 for a statement that isn't a query.
|
|
1465
|
+
*
|
|
1466
|
+
* SQLSMALLINT columns;
|
|
1467
|
+
*
|
|
1468
|
+
* SQLExecDirect(stmt, (SQLCHAR *)"SELECT * FROM foo", SQL_NTS);
|
|
1469
|
+
* SQLNumResultCols(stmt, &columns);
|
|
1470
|
+
*/
|
|
1471
|
+
SQLRETURN SQLNumResultCols(
|
|
1472
|
+
SQLHSTMT StatementHandle,
|
|
1473
|
+
SQLSMALLINT *ColumnCount
|
|
1474
|
+
);
|
|
1475
|
+
|
|
1476
|
+
/*
|
|
1477
|
+
* SQLParamData gives the value of each SQL_DATA_AT_EXEC parameter, after
|
|
1478
|
+
* SQLExecute (or SQLExecDirect) returns SQL_NEED_DATA. It sets Value to the
|
|
1479
|
+
* ParameterValue of the next parameter and returns SQL_NEED_DATA, and then
|
|
1480
|
+
* the value is given with SQLPutData. After the last one, it executes the
|
|
1481
|
+
* statement.
|
|
1482
|
+
*
|
|
1483
|
+
* SQLPOINTER p;
|
|
1484
|
+
* SQLINTEGER at_exec = SQL_DATA_AT_EXEC;
|
|
1485
|
+
*
|
|
1486
|
+
* SQLBindParameter(stmt, 1, SQL_PARAM_MODE_IN, SQL_CHAR, SQL_VARCHAR, 100,
|
|
1487
|
+
* 0, NULL, 0, &at_exec);
|
|
1488
|
+
* if (SQLExecute(stmt) == SQL_NEED_DATA) {
|
|
1489
|
+
* while (SQLParamData(stmt, &p) == SQL_NEED_DATA) {
|
|
1490
|
+
* SQLPutData(stmt, (SQLPOINTER) "hello ", SQL_NTS);
|
|
1491
|
+
* SQLPutData(stmt, (SQLPOINTER) "world", SQL_NTS);
|
|
1492
|
+
* }
|
|
1493
|
+
* }
|
|
1494
|
+
*/
|
|
1495
|
+
SQLRETURN SQLParamData(
|
|
1496
|
+
SQLHSTMT StatementHandle,
|
|
1497
|
+
SQLPOINTER *Value
|
|
1498
|
+
);
|
|
1499
|
+
|
|
1500
|
+
/*
|
|
1501
|
+
* SQLPrepare prepares a statement to be executed (maybe many times) with
|
|
1502
|
+
* SQLExecute. It may have dynamic parameters ("?"), see SQLBindParameter. A
|
|
1503
|
+
* syntax error is returned by SQLPrepare, but other errors (such as a table
|
|
1504
|
+
* that doesn't exist) are only returned by SQLExecute. The same statements are
|
|
1505
|
+
* allowed as SQLExecDirect.
|
|
1506
|
+
*/
|
|
1507
|
+
SQLRETURN SQLPrepare(
|
|
1508
|
+
SQLHSTMT StatementHandle,
|
|
1509
|
+
SQLCHAR *StatementText,
|
|
1510
|
+
SQLINTEGER TextLength
|
|
1511
|
+
);
|
|
1512
|
+
|
|
1513
|
+
/*
|
|
1514
|
+
* SQLPrimaryKeys returns a result set that describes the columns of the
|
|
1515
|
+
* PRIMARY KEY of a table (TableName can't be a null pointer). Its columns are
|
|
1516
|
+
* TABLE_CAT, TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, ORDINAL_POSITION and
|
|
1517
|
+
* PK_NAME. The names are not patterns.
|
|
1518
|
+
*/
|
|
1519
|
+
SQLRETURN SQLPrimaryKeys(
|
|
1520
|
+
SQLHSTMT StatementHandle,
|
|
1521
|
+
SQLCHAR *CatalogName,
|
|
1522
|
+
SQLSMALLINT NameLength1,
|
|
1523
|
+
SQLCHAR *SchemaName,
|
|
1524
|
+
SQLSMALLINT NameLength2,
|
|
1525
|
+
SQLCHAR *TableName,
|
|
1526
|
+
SQLSMALLINT NameLength3
|
|
1527
|
+
);
|
|
1528
|
+
|
|
1529
|
+
/*
|
|
1530
|
+
* SQLPutData gives the value of the SQL_DATA_AT_EXEC parameter, see
|
|
1531
|
+
* SQLParamData. StrLen_or_Ind is the length of a string (or SQL_NTS), or
|
|
1532
|
+
* SQL_NULL_DATA. A string can be given in pieces by calling SQLPutData again.
|
|
1533
|
+
*/
|
|
1534
|
+
SQLRETURN SQLPutData(
|
|
1535
|
+
SQLHSTMT StatementHandle,
|
|
1536
|
+
SQLPOINTER Data,
|
|
1537
|
+
SQLINTEGER StrLen_or_Ind
|
|
1538
|
+
);
|
|
1539
|
+
|
|
1540
|
+
/*
|
|
1541
|
+
* SQLRowCount sets RowCount to the number of rows inserted, updated or deleted
|
|
1542
|
+
* by the last statement that was executed, or 0 for any other statement.
|
|
1543
|
+
*
|
|
1544
|
+
* SQLINTEGER rows;
|
|
1545
|
+
*
|
|
1546
|
+
* SQLExecDirect(stmt, (SQLCHAR *)"DELETE FROM foo", SQL_NTS);
|
|
1547
|
+
* SQLRowCount(stmt, &rows);
|
|
1548
|
+
*/
|
|
1549
|
+
SQLRETURN SQLRowCount(
|
|
1550
|
+
SQLHSTMT StatementHandle,
|
|
1551
|
+
SQLINTEGER *RowCount
|
|
1552
|
+
);
|
|
1553
|
+
|
|
1554
|
+
/*
|
|
1555
|
+
* SQLSetConnectAttr sets an attribute of a connection:
|
|
1556
|
+
*
|
|
1557
|
+
* SQL_ATTR_SAVEPOINT_NAME a string of StringLength octets, or SQL_NTS
|
|
1558
|
+
* SQL_ATTR_AUTOCOMMIT SQLINTEGER, SQL_AUTOCOMMIT_OFF or _ON
|
|
1559
|
+
*
|
|
1560
|
+
* SQL_ATTR_AUTOCOMMIT isn't in the standard (it's the same as in ODBC). With
|
|
1561
|
+
* the default (SQL_AUTOCOMMIT_OFF), the first statement starts a transaction
|
|
1562
|
+
* that lasts until SQLEndTran. With SQL_AUTOCOMMIT_ON, a transaction that a
|
|
1563
|
+
* statement started is committed when the statement has finished and no cursor
|
|
1564
|
+
* of the connection is open, so a query is committed when its cursor is closed
|
|
1565
|
+
* (by SQLCloseCursor, SQLFreeStmt, SQLFreeHandle or SQLMoreResults), and a
|
|
1566
|
+
* statement that fails is rolled back. A transaction started
|
|
1567
|
+
* by SQLStartTran isn't committed until SQLEndTran. Turning it on commits the
|
|
1568
|
+
* active transaction, if there is one.
|
|
1569
|
+
*/
|
|
1570
|
+
SQLRETURN SQLSetConnectAttr(
|
|
1571
|
+
SQLHDBC ConnectionHandle,
|
|
1572
|
+
SQLINTEGER Attribute,
|
|
1573
|
+
SQLPOINTER Value,
|
|
1574
|
+
SQLINTEGER StringLength
|
|
1575
|
+
);
|
|
1576
|
+
|
|
1577
|
+
/*
|
|
1578
|
+
* SQLSetCursorName names the statement's cursor. The name is an identifier
|
|
1579
|
+
* (that doesn't start with SQL_CUR or SQLCUR), and two statements of a
|
|
1580
|
+
* connection can't have the same name. It isn't used yet, since positioned
|
|
1581
|
+
* UPDATE and DELETE are not supported.
|
|
1582
|
+
*/
|
|
1583
|
+
SQLRETURN SQLSetCursorName(
|
|
1584
|
+
SQLHSTMT StatementHandle,
|
|
1585
|
+
SQLCHAR *CursorName,
|
|
1586
|
+
SQLSMALLINT NameLength
|
|
1587
|
+
);
|
|
1588
|
+
|
|
1589
|
+
/*
|
|
1590
|
+
* SQLSetDescField sets a field of a descriptor (see SQLGetDescField). A record
|
|
1591
|
+
* field adds records up to RecordNumber. Value points to an SQLSMALLINT or
|
|
1592
|
+
* SQLINTEGER field, a pointer field is Value itself, and a string is
|
|
1593
|
+
* BufferLength octets (or SQL_NTS). Setting SQL_DESC_TYPE resets the
|
|
1594
|
+
* length, precision and scale for the type, and SQL_DESC_DATA_POINTER (which
|
|
1595
|
+
* must have a C type, otherwise it's HY021). The fields of an IRD can't be set
|
|
1596
|
+
* (HY091).
|
|
1597
|
+
*
|
|
1598
|
+
* SQLHDESC ard;
|
|
1599
|
+
* SQLDOUBLE x;
|
|
1600
|
+
* SQLSMALLINT type = SQL_DOUBLE;
|
|
1601
|
+
*
|
|
1602
|
+
* SQLGetStmtAttr(stmt, SQL_ATTR_APP_ROW_DESC, &ard, 0, NULL);
|
|
1603
|
+
* SQLSetDescField(ard, 1, SQL_DESC_TYPE, &type, 0);
|
|
1604
|
+
* SQLSetDescField(ard, 1, SQL_DESC_DATA_POINTER, &x, 0);
|
|
1605
|
+
*/
|
|
1606
|
+
SQLRETURN SQLSetDescField(
|
|
1607
|
+
SQLHDESC DescriptorHandle,
|
|
1608
|
+
SQLSMALLINT RecordNumber,
|
|
1609
|
+
SQLSMALLINT FieldIdentifier,
|
|
1610
|
+
SQLPOINTER Value,
|
|
1611
|
+
SQLINTEGER BufferLength
|
|
1612
|
+
);
|
|
1613
|
+
|
|
1614
|
+
/*
|
|
1615
|
+
* SQLSetDescRec sets the SQL_DESC_TYPE, SQL_DESC_DATETIME_INTERVAL_CODE
|
|
1616
|
+
* (SubType), SQL_DESC_PRECISION, SQL_DESC_SCALE, SQL_DESC_DATA_POINTER (Data),
|
|
1617
|
+
* SQL_DESC_OCTET_LENGTH_POINTER (StringLength) and SQL_DESC_INDICATOR_POINTER
|
|
1618
|
+
* (Indicator) fields of a record (starting at 1). Length is the
|
|
1619
|
+
* SQL_DESC_LENGTH of an IPD, and the SQL_DESC_OCTET_LENGTH of the other
|
|
1620
|
+
* descriptors. StringLength and Indicator are only set if they are not null
|
|
1621
|
+
* pointers.
|
|
1622
|
+
*
|
|
1623
|
+
* An IRD can't be changed. The standard names this condition ("cannot modify
|
|
1624
|
+
* an implementation row descriptor") but doesn't give it a SQLSTATE, so it's
|
|
1625
|
+
* HY016, the same as ODBC.
|
|
1626
|
+
*/
|
|
1627
|
+
SQLRETURN SQLSetDescRec(
|
|
1628
|
+
SQLHDESC DescriptorHandle,
|
|
1629
|
+
SQLSMALLINT RecordNumber,
|
|
1630
|
+
SQLSMALLINT Type,
|
|
1631
|
+
SQLSMALLINT SubType,
|
|
1632
|
+
SQLINTEGER Length,
|
|
1633
|
+
SQLSMALLINT Precision,
|
|
1634
|
+
SQLSMALLINT Scale,
|
|
1635
|
+
SQLPOINTER Data,
|
|
1636
|
+
SQLINTEGER *StringLength,
|
|
1637
|
+
SQLINTEGER *Indicator
|
|
1638
|
+
);
|
|
1639
|
+
|
|
1640
|
+
/*
|
|
1641
|
+
* SQLSetEnvAttr sets an attribute of an environment, before it has any
|
|
1642
|
+
* connections. The only one is SQL_ATTR_OUTPUT_NTS: SQL_TRUE (the default)
|
|
1643
|
+
* null terminates every string that's returned, and SQL_FALSE doesn't. Value
|
|
1644
|
+
* points to an SQLINTEGER, and StringLength isn't used.
|
|
1645
|
+
*
|
|
1646
|
+
* SQLINTEGER nts = SQL_FALSE;
|
|
1647
|
+
*
|
|
1648
|
+
* SQLSetEnvAttr(env, SQL_ATTR_OUTPUT_NTS, &nts, 0);
|
|
1649
|
+
*/
|
|
1650
|
+
SQLRETURN SQLSetEnvAttr(
|
|
1651
|
+
SQLHENV EnvironmentHandle,
|
|
1652
|
+
SQLINTEGER Attribute,
|
|
1653
|
+
SQLPOINTER Value,
|
|
1654
|
+
SQLINTEGER StringLength
|
|
1655
|
+
);
|
|
1656
|
+
|
|
1657
|
+
/*
|
|
1658
|
+
* SQLSetStmtAttr sets an attribute of a statement. Value points to an
|
|
1659
|
+
* SQLINTEGER (or an SQLHDESC), and StringLength isn't used. The attributes
|
|
1660
|
+
* are:
|
|
1661
|
+
*
|
|
1662
|
+
* SQL_ATTR_APP_ROW_DESC a descriptor from SQLAllocHandle, or the
|
|
1663
|
+
* SQL_ATTR_APP_PARAM_DESC statement's own one
|
|
1664
|
+
* SQL_ATTR_CURSOR_SCROLLABLE SQL_NONSCROLLABLE or SQL_SCROLLABLE
|
|
1665
|
+
* SQL_ATTR_CURSOR_SENSITIVITY SQL_ASENSITIVE or SQL_INSENSITIVE
|
|
1666
|
+
* SQL_ATTR_CURSOR_HOLDABLE SQL_NONHOLDABLE or SQL_HOLDABLE
|
|
1667
|
+
* SQL_ATTR_METADATA_ID SQL_FALSE or SQL_TRUE
|
|
1668
|
+
* SQL_ATTR_NEST_DESCRIPTOR SQL_FALSE or SQL_TRUE
|
|
1669
|
+
* SQL_ATTR_CURRENT_OF_POSITION the row of the rowset
|
|
1670
|
+
*
|
|
1671
|
+
* The cursor attributes can't be changed while a cursor is open. Every cursor
|
|
1672
|
+
* is a copy of the result, so a SQL_SENSITIVE cursor can't be opened (36001).
|
|
1673
|
+
*
|
|
1674
|
+
* SQLINTEGER holdable = SQL_NONHOLDABLE;
|
|
1675
|
+
*
|
|
1676
|
+
* SQLSetStmtAttr(stmt, SQL_ATTR_CURSOR_HOLDABLE, &holdable, 0);
|
|
1677
|
+
*/
|
|
1678
|
+
SQLRETURN SQLSetStmtAttr(
|
|
1679
|
+
SQLHSTMT StatementHandle,
|
|
1680
|
+
SQLINTEGER Attribute,
|
|
1681
|
+
SQLPOINTER Value,
|
|
1682
|
+
SQLINTEGER StringLength
|
|
1683
|
+
);
|
|
1684
|
+
|
|
1685
|
+
/*
|
|
1686
|
+
* SQLSpecialColumns returns a result set that describes the columns that
|
|
1687
|
+
* identify a row of a table (SQL_BEST_ROWID), which are its PRIMARY KEY. Its
|
|
1688
|
+
* columns are SCOPE (always SQL_SCOPE_SESSION), COLUMN_NAME, DATA_TYPE,
|
|
1689
|
+
* TYPE_NAME, COLUMN_SIZE, BUFFER_LENGTH, DECIMAL_DIGITS and PSEUDO_COLUMN
|
|
1690
|
+
* (always SQL_PC_NOT_PSEUDO). Scope is the minimum SCOPE, and Nullable is
|
|
1691
|
+
* SQL_NO_NULLS or SQL_NULLABLE (the columns of a PRIMARY KEY are never NULL).
|
|
1692
|
+
*/
|
|
1693
|
+
SQLRETURN SQLSpecialColumns(
|
|
1694
|
+
SQLHSTMT StatementHandle,
|
|
1695
|
+
SQLSMALLINT IdentifierType,
|
|
1696
|
+
SQLCHAR *CatalogName,
|
|
1697
|
+
SQLSMALLINT NameLength1,
|
|
1698
|
+
SQLCHAR *SchemaName,
|
|
1699
|
+
SQLSMALLINT NameLength2,
|
|
1700
|
+
SQLCHAR *TableName,
|
|
1701
|
+
SQLSMALLINT NameLength3,
|
|
1702
|
+
SQLSMALLINT Scope,
|
|
1703
|
+
SQLSMALLINT Nullable
|
|
1704
|
+
);
|
|
1705
|
+
|
|
1706
|
+
/*
|
|
1707
|
+
* SQLStartTran starts a transaction for a connection (SQL_HANDLE_DBC), or the
|
|
1708
|
+
* connection of an environment (SQL_HANDLE_ENV, which is 0A001 if it has more
|
|
1709
|
+
* than one). The connection becomes the current connection (see SQLConnect).
|
|
1710
|
+
* A transaction is also started by SQLExecDirect when there isn't one. vsql transactions are always
|
|
1711
|
+
* SQL_TRANSACTION_READ_WRITE (AccessMode) and SQL_TRANSACTION_READ_COMMITTED,
|
|
1712
|
+
* so SQL_TRANSACTION_READ_ONLY, SQL_TRANSACTION_REPEATABLE_READ and
|
|
1713
|
+
* SQL_TRANSACTION_SERIALIZABLE are HYC00.
|
|
1714
|
+
*
|
|
1715
|
+
* SQLStartTran(SQL_HANDLE_DBC, dbc, SQL_TRANSACTION_READ_WRITE,
|
|
1716
|
+
* SQL_TRANSACTION_READ_COMMITTED);
|
|
1717
|
+
*/
|
|
1718
|
+
SQLRETURN SQLStartTran(
|
|
1719
|
+
SQLSMALLINT HandleType,
|
|
1720
|
+
SQLINTEGER Handle,
|
|
1721
|
+
SQLINTEGER AccessMode,
|
|
1722
|
+
SQLINTEGER IsolationLevel
|
|
1723
|
+
);
|
|
1724
|
+
|
|
1725
|
+
/*
|
|
1726
|
+
* SQLTablePrivileges would return a result set that describes the privileges
|
|
1727
|
+
* of tables.
|
|
1728
|
+
* vsql doesn't have privileges, so it always returns SQL_ERROR with SQLSTATE
|
|
1729
|
+
* HYC00 (optional feature not implemented).
|
|
1730
|
+
*/
|
|
1731
|
+
SQLRETURN SQLTablePrivileges(
|
|
1732
|
+
SQLHSTMT StatementHandle,
|
|
1733
|
+
SQLCHAR *CatalogName,
|
|
1734
|
+
SQLSMALLINT NameLength1,
|
|
1735
|
+
SQLCHAR *SchemaName,
|
|
1736
|
+
SQLSMALLINT NameLength2,
|
|
1737
|
+
SQLCHAR *TableName,
|
|
1738
|
+
SQLSMALLINT NameLength3
|
|
1739
|
+
);
|
|
1740
|
+
|
|
1741
|
+
/*
|
|
1742
|
+
* SQLTables returns a result set that describes tables, from the
|
|
1743
|
+
* INFORMATION_SCHEMA. Its columns are TABLE_CAT, TABLE_SCHEM, TABLE_NAME,
|
|
1744
|
+
* TABLE_TYPE ("TABLE", "VIEW" or "SYSTEM TABLE"), REMARKS, SELF_REF_COLUMN,
|
|
1745
|
+
* REF_GENERATION, UDT_CAT, UDT_SCHEM and UDT_NAME. The name arguments are the
|
|
1746
|
+
* same as SQLColumns, and TableType is a comma-separated list of types (each
|
|
1747
|
+
* may be quoted), or a null pointer for any type.
|
|
1748
|
+
*
|
|
1749
|
+
* SQL_ALL_CATALOGS (with no SchemaName or TableName) returns the catalogs,
|
|
1750
|
+
* SQL_ALL_SCHEMAS (with no CatalogName or TableName) returns the schemas, and
|
|
1751
|
+
* SQL_ALL_TABLE_TYPES (with no other names) returns the table types.
|
|
1752
|
+
*
|
|
1753
|
+
* SQLTables(stmt, NULL, 0, (SQLCHAR *)"PUBLIC", SQL_NTS, NULL, 0,
|
|
1754
|
+
* (SQLCHAR *)"TABLE", SQL_NTS);
|
|
1755
|
+
*/
|
|
1756
|
+
SQLRETURN SQLTables(
|
|
1757
|
+
SQLHSTMT StatementHandle,
|
|
1758
|
+
SQLCHAR *CatalogName,
|
|
1759
|
+
SQLSMALLINT NameLength1,
|
|
1760
|
+
SQLCHAR *SchemaName,
|
|
1761
|
+
SQLSMALLINT NameLength2,
|
|
1762
|
+
SQLCHAR *TableName,
|
|
1763
|
+
SQLSMALLINT NameLength3,
|
|
1764
|
+
SQLCHAR *TableType,
|
|
1765
|
+
SQLSMALLINT NameLength4
|
|
1766
|
+
);
|
|
1767
|
+
|
|
1768
|
+
#ifdef __cplusplus
|
|
1769
|
+
}
|
|
1770
|
+
#endif
|
|
1771
|
+
|
|
1772
|
+
#endif
|