1 /**************************************************
2  * sql.h
3  *
4  * These should be consistent with the MS version.
5  *
6  **************************************************/
7 #ifndef __SQL_H
8 #define __SQL_H
9 
10 
11 /****************************
12  * default to 3.51 declare something else before here and you get a whole new ball of wax
13  ***************************/
14 #ifndef ODBCVER
15 #define ODBCVER 0x0380
16 #endif
17 
18 #ifndef __SQLTYPES_H
19 #include "sqltypes.h"
20 #endif
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 /****************************
27  * some ret values
28  ***************************/
29 #define SQL_NULL_DATA             (-1)
30 #define SQL_DATA_AT_EXEC          (-2)
31 #define SQL_SUCCESS                0
32 #define SQL_SUCCESS_WITH_INFO      1
33 #if (ODBCVER >= 0x0300)
34 #define SQL_NO_DATA              100
35 #endif
36 #define SQL_ERROR                 (-1)
37 #define SQL_INVALID_HANDLE        (-2)
38 #define SQL_STILL_EXECUTING        2
39 #define SQL_NEED_DATA             99
40 #define SQL_SUCCEEDED(rc) (((rc)&(~1))==0)
41 
42 #if (ODBCVER >= 0x0380)
43 #define SQL_PARAM_DATA_AVAILABLE    101
44 #endif
45 
46 /****************************
47  * use these to indicate string termination to some function
48  ***************************/
49 #define SQL_NTS                   (-3)
50 #define SQL_NTSL                  (-3L)
51 
52 /* maximum message length */
53 #define SQL_MAX_MESSAGE_LENGTH   512
54 
55 /* date/time length constants */
56 #if (ODBCVER >= 0x0300)
57 #define SQL_DATE_LEN           10
58 #define SQL_TIME_LEN            8  /* add P+1 if precision is nonzero */
59 #define SQL_TIMESTAMP_LEN      19  /* add P+1 if precision is nonzero */
60 #endif
61 
62 /* handle type identifiers */
63 #if (ODBCVER >= 0x0300)
64 #define SQL_HANDLE_ENV             1
65 #define SQL_HANDLE_DBC             2
66 #define SQL_HANDLE_STMT            3
67 #define SQL_HANDLE_DESC            4
68 #endif
69 
70 /* environment attribute */
71 #if (ODBCVER >= 0x0300)
72 #define SQL_ATTR_OUTPUT_NTS    10001
73 #endif
74 
75 /* connection attributes */
76 #if (ODBCVER >= 0x0300)
77 #define SQL_ATTR_AUTO_IPD      10001
78 #define SQL_ATTR_METADATA_ID   10014
79 #endif  /* ODBCVER >= 0x0300 */
80 
81 /* statement attributes */
82 #if (ODBCVER >= 0x0300)
83 #define SQL_ATTR_APP_ROW_DESC       10010
84 #define SQL_ATTR_APP_PARAM_DESC     10011
85 #define SQL_ATTR_IMP_ROW_DESC       10012
86 #define SQL_ATTR_IMP_PARAM_DESC     10013
87 #define SQL_ATTR_CURSOR_SCROLLABLE  (-1)
88 #define SQL_ATTR_CURSOR_SENSITIVITY (-2)
89 #endif
90 
91 /* SQL_ATTR_CURSOR_SCROLLABLE values */
92 #if (ODBCVER >= 0x0300)
93 #define SQL_NONSCROLLABLE			0
94 #define SQL_SCROLLABLE				1
95 #endif  /* ODBCVER >= 0x0300 */
96 
97 /* identifiers of fields in the SQL descriptor */
98 #if (ODBCVER >= 0x0300)
99 #define SQL_DESC_COUNT                  1001
100 #define SQL_DESC_TYPE                   1002
101 #define SQL_DESC_LENGTH                 1003
102 #define SQL_DESC_OCTET_LENGTH_PTR       1004
103 #define SQL_DESC_PRECISION              1005
104 #define SQL_DESC_SCALE                  1006
105 #define SQL_DESC_DATETIME_INTERVAL_CODE 1007
106 #define SQL_DESC_NULLABLE               1008
107 #define SQL_DESC_INDICATOR_PTR          1009
108 #define SQL_DESC_DATA_PTR               1010
109 #define SQL_DESC_NAME                   1011
110 #define SQL_DESC_UNNAMED                1012
111 #define SQL_DESC_OCTET_LENGTH           1013
112 #define SQL_DESC_ALLOC_TYPE             1099
113 #endif
114 
115 /* identifiers of fields in the diagnostics area */
116 #if (ODBCVER >= 0x0300)
117 #define SQL_DIAG_RETURNCODE        1
118 #define SQL_DIAG_NUMBER            2
119 #define SQL_DIAG_ROW_COUNT         3
120 #define SQL_DIAG_SQLSTATE          4
121 #define SQL_DIAG_NATIVE            5
122 #define SQL_DIAG_MESSAGE_TEXT      6
123 #define SQL_DIAG_DYNAMIC_FUNCTION  7
124 #define SQL_DIAG_CLASS_ORIGIN      8
125 #define SQL_DIAG_SUBCLASS_ORIGIN   9
126 #define SQL_DIAG_CONNECTION_NAME  10
127 #define SQL_DIAG_SERVER_NAME      11
128 #define SQL_DIAG_DYNAMIC_FUNCTION_CODE 12
129 #endif
130 
131 /* dynamic function codes */
132 #if (ODBCVER >= 0x0300)
133 #define SQL_DIAG_ALTER_DOMAIN			3
134 #define SQL_DIAG_ALTER_TABLE            4
135 #define SQL_DIAG_CALL					7
136 #define SQL_DIAG_CREATE_ASSERTION		6
137 #define SQL_DIAG_CREATE_CHARACTER_SET	8
138 #define SQL_DIAG_CREATE_COLLATION		10
139 #define SQL_DIAG_CREATE_DOMAIN			23
140 #define SQL_DIAG_CREATE_INDEX          (-1)
141 #define SQL_DIAG_CREATE_SCHEMA			64
142 #define SQL_DIAG_CREATE_TABLE          77
143 #define SQL_DIAG_CREATE_TRANSLATION		79
144 #define SQL_DIAG_CREATE_VIEW           84
145 #define SQL_DIAG_DELETE_WHERE          19
146 #define	SQL_DIAG_DROP_ASSERTION			24
147 #define	SQL_DIAG_DROP_CHARACTER_SET		25
148 #define	SQL_DIAG_DROP_COLLATION			26
149 #define	SQL_DIAG_DROP_DOMAIN			27
150 #define SQL_DIAG_DROP_INDEX            (-2)
151 #define SQL_DIAG_DROP_SCHEMA			31
152 #define SQL_DIAG_DROP_TABLE            32
153 #define SQL_DIAG_DROP_TRANSLATION      33
154 #define SQL_DIAG_DROP_VIEW             36
155 #define SQL_DIAG_DYNAMIC_DELETE_CURSOR 38
156 #define SQL_DIAG_DYNAMIC_UPDATE_CURSOR 81
157 #define SQL_DIAG_GRANT                 48
158 #define SQL_DIAG_INSERT                50
159 #define SQL_DIAG_REVOKE                59
160 #define SQL_DIAG_SELECT_CURSOR         85
161 #define SQL_DIAG_UNKNOWN_STATEMENT      0
162 #define SQL_DIAG_UPDATE_WHERE          82
163 #endif  /* ODBCVER >= 0x0300 */
164 
165 /* SQL data type codes */
166 #define	SQL_UNKNOWN_TYPE	0
167 #define SQL_CHAR            1
168 #define SQL_NUMERIC         2
169 #define SQL_DECIMAL         3
170 #define SQL_INTEGER         4
171 #define SQL_SMALLINT        5
172 #define SQL_FLOAT           6
173 #define SQL_REAL            7
174 #define SQL_DOUBLE          8
175 #if (ODBCVER >= 0x0300)
176 #define SQL_DATETIME        9
177 #endif
178 #define SQL_VARCHAR        12
179 
180 /* One-parameter shortcuts for date/time data types */
181 #if (ODBCVER >= 0x0300)
182 #define SQL_TYPE_DATE      91
183 #define SQL_TYPE_TIME      92
184 #define SQL_TYPE_TIMESTAMP 93
185 #endif
186 
187 /* Statement attribute values for cursor sensitivity */
188 #if (ODBCVER >= 0x0300)
189 #define SQL_UNSPECIFIED     0
190 #define SQL_INSENSITIVE     1
191 #define SQL_SENSITIVE       2
192 #endif
193 
194 /* GetTypeInfo() request for all data types */
195 #define SQL_ALL_TYPES       0
196 
197 /* Default conversion code for SQLBindCol(), SQLBindParam() and SQLGetData() */
198 #if (ODBCVER >= 0x0300)
199 #define SQL_DEFAULT        99
200 #endif
201 
202 /* SQLGetData() code indicating that the application row descriptor
203  * specifies the data type
204  */
205 #if (ODBCVER >= 0x0300)
206 #define SQL_ARD_TYPE      (-99)
207 #endif
208 
209 /* SQL date/time type subcodes */
210 #if (ODBCVER >= 0x0300)
211 #define SQL_CODE_DATE       1
212 #define SQL_CODE_TIME       2
213 #define SQL_CODE_TIMESTAMP  3
214 #endif
215 
216 /* CLI option values */
217 #if (ODBCVER >= 0x0300)
218 #define SQL_FALSE           0
219 #define SQL_TRUE            1
220 #endif
221 
222 /* values of NULLABLE field in descriptor */
223 #define SQL_NO_NULLS        0
224 #define SQL_NULLABLE        1
225 
226 /* Value returned by SQLGetTypeInfo() to denote that it is
227  * not known whether or not a data type supports null values.
228  */
229 #define SQL_NULLABLE_UNKNOWN  2
230 
231 /* Values returned by SQLGetTypeInfo() to show WHERE clause
232  * supported
233  */
234 #if (ODBCVER >= 0x0300)
235 #define SQL_PRED_NONE     0
236 #define SQL_PRED_CHAR     1
237 #define SQL_PRED_BASIC    2
238 #endif
239 
240 /* values of UNNAMED field in descriptor */
241 #if (ODBCVER >= 0x0300)
242 #define SQL_NAMED           0
243 #define SQL_UNNAMED         1
244 #endif
245 
246 /* values of ALLOC_TYPE field in descriptor */
247 #if (ODBCVER >= 0x0300)
248 #define SQL_DESC_ALLOC_AUTO 1
249 #define SQL_DESC_ALLOC_USER 2
250 #endif
251 
252 /* FreeStmt() options */
253 #define SQL_CLOSE           0
254 #define SQL_DROP            1
255 #define SQL_UNBIND          2
256 #define SQL_RESET_PARAMS    3
257 
258 /* Codes used for FetchOrientation in SQLFetchScroll(),
259    and in SQLDataSources()
260 */
261 #define SQL_FETCH_NEXT      1
262 #define SQL_FETCH_FIRST     2
263 
264 /* Other codes used for FetchOrientation in SQLFetchScroll() */
265 #define SQL_FETCH_LAST      3
266 #define SQL_FETCH_PRIOR     4
267 #define SQL_FETCH_ABSOLUTE  5
268 #define SQL_FETCH_RELATIVE  6
269 
270 /* SQLEndTran() options */
271 #define SQL_COMMIT          0
272 #define SQL_ROLLBACK        1
273 
274 /* null handles returned by SQLAllocHandle() */
275 #define SQL_NULL_HENV       0
276 #define SQL_NULL_HDBC       0
277 #define SQL_NULL_HSTMT      0
278 #if (ODBCVER >= 0x0300)
279 #define SQL_NULL_HDESC      0
280 #define SQL_NULL_DESC       0
281 #endif
282 
283 /* null handle used in place of parent handle when allocating HENV */
284 #if (ODBCVER >= 0x0300)
285 #define SQL_NULL_HANDLE     0L
286 #endif
287 
288 /* Values that may appear in the result set of SQLSpecialColumns() */
289 #define SQL_SCOPE_CURROW    0
290 #define SQL_SCOPE_TRANSACTION 1
291 #define SQL_SCOPE_SESSION   2
292 
293 #define SQL_PC_UNKNOWN      0
294 #if (ODBCVER >= 0x0300)
295 #define SQL_PC_NON_PSEUDO   1
296 #endif
297 #define SQL_PC_PSEUDO       2
298 
299 /* Reserved value for the IdentifierType argument of SQLSpecialColumns() */
300 #if (ODBCVER >= 0x0300)
301 #define SQL_ROW_IDENTIFIER  1
302 #endif
303 
304 /* Reserved values for UNIQUE argument of SQLStatistics() */
305 #define SQL_INDEX_UNIQUE    0
306 #define SQL_INDEX_ALL       1
307 
308 /* Values that may appear in the result set of SQLStatistics() */
309 #define SQL_INDEX_CLUSTERED 1
310 #define SQL_INDEX_HASHED    2
311 #define SQL_INDEX_OTHER     3
312 
313 /* SQLGetFunctions() values to identify ODBC APIs */
314 #define SQL_API_SQLALLOCCONNECT         1
315 #define SQL_API_SQLALLOCENV             2
316 #if (ODBCVER >= 0x0300)
317 #define SQL_API_SQLALLOCHANDLE       1001
318 #endif
319 #define SQL_API_SQLALLOCSTMT            3
320 #define SQL_API_SQLBINDCOL              4
321 #if (ODBCVER >= 0x0300)
322 #define SQL_API_SQLBINDPARAM         1002
323 #endif
324 #define SQL_API_SQLCANCEL               5
325 #if (ODBCVER >= 0x0300)
326 #define SQL_API_SQLCLOSECURSOR       1003
327 #define SQL_API_SQLCOLATTRIBUTE         6
328 #endif
329 #define SQL_API_SQLCOLUMNS             40
330 #define SQL_API_SQLCONNECT              7
331 #if (ODBCVER >= 0x0300)
332 #define SQL_API_SQLCOPYDESC          1004
333 #endif
334 #define SQL_API_SQLDATASOURCES         57
335 #define SQL_API_SQLDESCRIBECOL          8
336 #define SQL_API_SQLDISCONNECT           9
337 #if (ODBCVER >= 0x0300)
338 #define SQL_API_SQLENDTRAN           1005
339 #endif
340 #define SQL_API_SQLERROR               10
341 #define SQL_API_SQLEXECDIRECT          11
342 #define SQL_API_SQLEXECUTE             12
343 #define SQL_API_SQLFETCH               13
344 #if (ODBCVER >= 0x0300)
345 #define SQL_API_SQLFETCHSCROLL       1021
346 #endif
347 #define SQL_API_SQLFREECONNECT         14
348 #define SQL_API_SQLFREEENV             15
349 #if (ODBCVER >= 0x0300)
350 #define SQL_API_SQLFREEHANDLE        1006
351 #endif
352 #define SQL_API_SQLFREESTMT            16
353 #if (ODBCVER >= 0x0300)
354 #define SQL_API_SQLGETCONNECTATTR    1007
355 #endif
356 #define SQL_API_SQLGETCONNECTOPTION    42
357 #define SQL_API_SQLGETCURSORNAME       17
358 #define SQL_API_SQLGETDATA             43
359 #if (ODBCVER >= 0x0300)
360 #define SQL_API_SQLGETDESCFIELD      1008
361 #define SQL_API_SQLGETDESCREC        1009
362 #define SQL_API_SQLGETDIAGFIELD      1010
363 #define SQL_API_SQLGETDIAGREC        1011
364 #define SQL_API_SQLGETENVATTR        1012
365 #endif
366 #define SQL_API_SQLGETFUNCTIONS        44
367 #define SQL_API_SQLGETINFO             45
368 #if (ODBCVER >= 0x0300)
369 #define SQL_API_SQLGETSTMTATTR       1014
370 #endif
371 #define SQL_API_SQLGETSTMTOPTION       46
372 #define SQL_API_SQLGETTYPEINFO         47
373 #define SQL_API_SQLNUMRESULTCOLS       18
374 #define SQL_API_SQLPARAMDATA           48
375 #define SQL_API_SQLPREPARE             19
376 #define SQL_API_SQLPUTDATA             49
377 #define SQL_API_SQLROWCOUNT            20
378 #if (ODBCVER >= 0x0300)
379 #define SQL_API_SQLSETCONNECTATTR    1016
380 #endif
381 #define SQL_API_SQLSETCONNECTOPTION    50
382 #define SQL_API_SQLSETCURSORNAME       21
383 #if (ODBCVER >= 0x0300)
384 #define SQL_API_SQLSETDESCFIELD      1017
385 #define SQL_API_SQLSETDESCREC        1018
386 #define SQL_API_SQLSETENVATTR        1019
387 #endif
388 #define SQL_API_SQLSETPARAM            22
389 #if (ODBCVER >= 0x0300)
390 #define SQL_API_SQLSETSTMTATTR       1020
391 #endif
392 #define SQL_API_SQLSETSTMTOPTION       51
393 #define SQL_API_SQLSPECIALCOLUMNS      52
394 #define SQL_API_SQLSTATISTICS          53
395 #define SQL_API_SQLTABLES              54
396 #define SQL_API_SQLTRANSACT            23
397 
398 #if (ODBCVER >= 0x0380)
399 #define SQL_API_SQLCANCELHANDLE      1022
400 #endif
401 
402 /* Information requested by SQLGetInfo() */
403 #if (ODBCVER >= 0x0300)
404 #define SQL_MAX_DRIVER_CONNECTIONS           0
405 #define SQL_MAXIMUM_DRIVER_CONNECTIONS		SQL_MAX_DRIVER_CONNECTIONS
406 #define SQL_MAX_CONCURRENT_ACTIVITIES        1
407 #define SQL_MAXIMUM_CONCURRENT_ACTIVITIES	SQL_MAX_CONCURRENT_ACTIVITIES
408 #endif
409 #define SQL_DATA_SOURCE_NAME                 2
410 #define SQL_FETCH_DIRECTION                  8
411 #define SQL_SERVER_NAME                     13
412 #define SQL_SEARCH_PATTERN_ESCAPE           14
413 #define SQL_DBMS_NAME                       17
414 #define SQL_DBMS_VER                        18
415 #define SQL_ACCESSIBLE_TABLES               19
416 #define SQL_ACCESSIBLE_PROCEDURES        	20
417 #define SQL_CURSOR_COMMIT_BEHAVIOR          23
418 #define SQL_DATA_SOURCE_READ_ONLY           25
419 #define SQL_DEFAULT_TXN_ISOLATION           26
420 #define SQL_IDENTIFIER_CASE                 28
421 #define SQL_IDENTIFIER_QUOTE_CHAR           29
422 #define SQL_MAX_COLUMN_NAME_LEN             30
423 #define SQL_MAXIMUM_COLUMN_NAME_LENGTH		SQL_MAX_COLUMN_NAME_LEN
424 #define SQL_MAX_CURSOR_NAME_LEN             31
425 #define SQL_MAXIMUM_CURSOR_NAME_LENGTH		SQL_MAX_CURSOR_NAME_LEN
426 #define SQL_MAX_SCHEMA_NAME_LEN             32
427 #define SQL_MAXIMUM_SCHEMA_NAME_LENGTH		SQL_MAX_SCHEMA_NAME_LEN
428 #define SQL_MAX_CATALOG_NAME_LEN            34
429 #define SQL_MAXIMUM_CATALOG_NAME_LENGTH		SQL_MAX_CATALOG_NAME_LEN
430 #define SQL_MAX_TABLE_NAME_LEN              35
431 #define SQL_SCROLL_CONCURRENCY              43
432 #define SQL_TXN_CAPABLE                     46
433 #define SQL_TRANSACTION_CAPABLE				SQL_TXN_CAPABLE
434 #define SQL_USER_NAME                       47
435 #define SQL_TXN_ISOLATION_OPTION            72
436 #define SQL_TRANSACTION_ISOLATION_OPTION	SQL_TXN_ISOLATION_OPTION
437 #define SQL_INTEGRITY                       73
438 #define SQL_GETDATA_EXTENSIONS              81
439 #define SQL_NULL_COLLATION                  85
440 #define SQL_ALTER_TABLE                     86
441 #define SQL_ORDER_BY_COLUMNS_IN_SELECT      90
442 #define SQL_SPECIAL_CHARACTERS              94
443 #define SQL_MAX_COLUMNS_IN_GROUP_BY         97
444 #define SQL_MAXIMUM_COLUMNS_IN_GROUP_BY		SQL_MAX_COLUMNS_IN_GROUP_BY
445 #define SQL_MAX_COLUMNS_IN_INDEX            98
446 #define SQL_MAXIMUM_COLUMNS_IN_INDEX		SQL_MAX_COLUMNS_IN_INDEX
447 #define SQL_MAX_COLUMNS_IN_ORDER_BY         99
448 #define SQL_MAXIMUM_COLUMNS_IN_ORDER_BY		SQL_MAX_COLUMNS_IN_ORDER_BY
449 #define SQL_MAX_COLUMNS_IN_SELECT          100
450 #define SQL_MAXIMUM_COLUMNS_IN_SELECT	   SQL_MAX_COLUMNS_IN_SELECT
451 #define SQL_MAX_COLUMNS_IN_TABLE           101
452 #define SQL_MAX_INDEX_SIZE                 102
453 #define SQL_MAXIMUM_INDEX_SIZE			   SQL_MAX_INDEX_SIZE
454 #define SQL_MAX_ROW_SIZE                   104
455 #define SQL_MAXIMUM_ROW_SIZE			   SQL_MAX_ROW_SIZE
456 #define SQL_MAX_STATEMENT_LEN              105
457 #define SQL_MAXIMUM_STATEMENT_LENGTH	   SQL_MAX_STATEMENT_LEN
458 #define SQL_MAX_TABLES_IN_SELECT           106
459 #define SQL_MAXIMUM_TABLES_IN_SELECT	   SQL_MAX_TABLES_IN_SELECT
460 #define SQL_MAX_USER_NAME_LEN              107
461 #define SQL_MAXIMUM_USER_NAME_LENGTH	   SQL_MAX_USER_NAME_LEN
462 #if (ODBCVER >= 0x0300)
463 #define SQL_OJ_CAPABILITIES                115
464 #define SQL_OUTER_JOIN_CAPABILITIES		   SQL_OJ_CAPABILITIES
465 #endif /* ODBCVER >= 0x0300 */
466 
467 #if (ODBCVER >= 0x0300)
468 #define SQL_XOPEN_CLI_YEAR               10000
469 #define SQL_CURSOR_SENSITIVITY           10001
470 #define SQL_DESCRIBE_PARAMETER           10002
471 #define SQL_CATALOG_NAME                 10003
472 #define SQL_COLLATION_SEQ                10004
473 #define SQL_MAX_IDENTIFIER_LEN           10005
474 #define SQL_MAXIMUM_IDENTIFIER_LENGTH	 SQL_MAX_IDENTIFIER_LEN
475 #endif /* ODBCVER >= 0x0300 */
476 
477 /* SQL_ALTER_TABLE bitmasks */
478 #if (ODBCVER >= 0x0200)
479 #define SQL_AT_ADD_COLUMN                   	0x00000001L
480 #define SQL_AT_DROP_COLUMN                  	0x00000002L
481 #endif /* ODBCVER >= 0x0200 */
482 
483 #if (ODBCVER >= 0x0300)
484 #define SQL_AT_ADD_CONSTRAINT               	0x00000008L
485 
486 /* The following bitmasks are ODBC extensions and defined in sqlext.h
487 *#define	SQL_AT_COLUMN_SINGLE					0x00000020L
488 *#define	SQL_AT_ADD_COLUMN_DEFAULT				0x00000040L
489 *#define	SQL_AT_ADD_COLUMN_COLLATION				0x00000080L
490 *#define	SQL_AT_SET_COLUMN_DEFAULT				0x00000100L
491 *#define	SQL_AT_DROP_COLUMN_DEFAULT				0x00000200L
492 *#define	SQL_AT_DROP_COLUMN_CASCADE				0x00000400L
493 *#define	SQL_AT_DROP_COLUMN_RESTRICT				0x00000800L
494 *#define SQL_AT_ADD_TABLE_CONSTRAINT				0x00001000L
495 *#define SQL_AT_DROP_TABLE_CONSTRAINT_CASCADE		0x00002000L
496 *#define SQL_AT_DROP_TABLE_CONSTRAINT_RESTRICT		0x00004000L
497 *#define SQL_AT_CONSTRAINT_NAME_DEFINITION			0x00008000L
498 *#define SQL_AT_CONSTRAINT_INITIALLY_DEFERRED		0x00010000L
499 *#define SQL_AT_CONSTRAINT_INITIALLY_IMMEDIATE		0x00020000L
500 *#define SQL_AT_CONSTRAINT_DEFERRABLE				0x00040000L
501 *#define SQL_AT_CONSTRAINT_NON_DEFERRABLE			0x00080000L
502 */
503 #endif  /* ODBCVER >= 0x0300 */
504 
505 
506 /* SQL_ASYNC_MODE values */
507 #if (ODBCVER >= 0x0300)
508 #define SQL_AM_NONE                         0
509 #define SQL_AM_CONNECTION                   1
510 #define SQL_AM_STATEMENT                    2
511 #endif
512 
513 /* SQL_CURSOR_COMMIT_BEHAVIOR values */
514 #define SQL_CB_DELETE                       0
515 #define SQL_CB_CLOSE                        1
516 #define SQL_CB_PRESERVE                     2
517 
518 /* SQL_FETCH_DIRECTION bitmasks */
519 #define SQL_FD_FETCH_NEXT                   0x00000001L
520 #define SQL_FD_FETCH_FIRST                  0x00000002L
521 #define SQL_FD_FETCH_LAST                   0x00000004L
522 #define SQL_FD_FETCH_PRIOR                  0x00000008L
523 #define SQL_FD_FETCH_ABSOLUTE               0x00000010L
524 #define SQL_FD_FETCH_RELATIVE               0x00000020L
525 
526 /* SQL_GETDATA_EXTENSIONS bitmasks */
527 #define SQL_GD_ANY_COLUMN                   0x00000001L
528 #define SQL_GD_ANY_ORDER                    0x00000002L
529 
530 /* SQL_IDENTIFIER_CASE values */
531 #define SQL_IC_UPPER                        1
532 #define SQL_IC_LOWER                        2
533 #define SQL_IC_SENSITIVE                    3
534 #define SQL_IC_MIXED                        4
535 
536 /* SQL_OJ_CAPABILITIES bitmasks */
537 /* NB: this means 'outer join', not what  you may be thinking */
538 
539 
540 #if (ODBCVER >= 0x0201)
541 #define SQL_OJ_LEFT                         0x00000001L
542 #define SQL_OJ_RIGHT                        0x00000002L
543 #define SQL_OJ_FULL                         0x00000004L
544 #define SQL_OJ_NESTED                       0x00000008L
545 #define SQL_OJ_NOT_ORDERED                  0x00000010L
546 #define SQL_OJ_INNER                        0x00000020L
547 #define SQL_OJ_ALL_COMPARISON_OPS           0x00000040L
548 #endif
549 
550 /* SQL_SCROLL_CONCURRENCY bitmasks */
551 #define SQL_SCCO_READ_ONLY                  0x00000001L
552 #define SQL_SCCO_LOCK                       0x00000002L
553 #define SQL_SCCO_OPT_ROWVER                 0x00000004L
554 #define SQL_SCCO_OPT_VALUES                 0x00000008L
555 
556 /* SQL_TXN_CAPABLE values */
557 #define SQL_TC_NONE                         0
558 #define SQL_TC_DML                          1
559 #define SQL_TC_ALL                          2
560 #define SQL_TC_DDL_COMMIT                   3
561 #define SQL_TC_DDL_IGNORE                   4
562 
563 /* SQL_TXN_ISOLATION_OPTION bitmasks */
564 #define SQL_TXN_READ_UNCOMMITTED            0x00000001L
565 #define SQL_TRANSACTION_READ_UNCOMMITTED	SQL_TXN_READ_UNCOMMITTED
566 #define SQL_TXN_READ_COMMITTED              0x00000002L
567 #define SQL_TRANSACTION_READ_COMMITTED		SQL_TXN_READ_COMMITTED
568 #define SQL_TXN_REPEATABLE_READ             0x00000004L
569 #define SQL_TRANSACTION_REPEATABLE_READ		SQL_TXN_REPEATABLE_READ
570 #define SQL_TXN_SERIALIZABLE                0x00000008L
571 #define SQL_TRANSACTION_SERIALIZABLE		SQL_TXN_SERIALIZABLE
572 
573 /* SQL_NULL_COLLATION values */
574 #define SQL_NC_HIGH                         0
575 #define SQL_NC_LOW                          1
576 
577     SQLRETURN  SQL_API SQLAllocConnect(SQLHENV EnvironmentHandle,
578                                        SQLHDBC *ConnectionHandle);
579 
580     SQLRETURN  SQL_API SQLAllocEnv(SQLHENV *EnvironmentHandle);
581 
582 #if (ODBCVER >= 0x0300)
583     SQLRETURN  SQL_API SQLAllocHandle(SQLSMALLINT HandleType,
584                                       SQLHANDLE InputHandle, SQLHANDLE *OutputHandle);
585 #endif
586 
587     SQLRETURN  SQL_API SQLAllocStmt(SQLHDBC ConnectionHandle,
588                                     SQLHSTMT *StatementHandle);
589 
590     SQLRETURN  SQL_API SQLBindCol(SQLHSTMT StatementHandle,
591                                   SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
592                                   SQLPOINTER TargetValue, SQLLEN BufferLength,
593                                   SQLLEN *StrLen_or_Ind);
594 
595 #if (ODBCVER >= 0x0300)
596     SQLRETURN  SQL_API SQLBindParam(SQLHSTMT StatementHandle,
597                                     SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
598                                     SQLSMALLINT ParameterType, SQLULEN LengthPrecision,
599                                     SQLSMALLINT ParameterScale, SQLPOINTER ParameterValue,
600                                     SQLLEN *StrLen_or_Ind);
601 #endif
602 
603     SQLRETURN  SQL_API SQLCancel(SQLHSTMT StatementHandle);
604 
605 #if (ODBCVER >= 0x0380)
606 SQLRETURN  SQL_API SQLCancelHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle);
607 #endif
608 
609 
610 #if (ODBCVER >= 0x0300)
611     SQLRETURN  SQL_API SQLCloseCursor(SQLHSTMT StatementHandle);
612 
613     SQLRETURN  SQL_API SQLColAttribute(SQLHSTMT StatementHandle,
614                                         SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
615                                         SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength,
616                                         SQLSMALLINT *StringLength, SQLLEN *NumericAttribute );
617 
618 										/* spec says (SQLPOINTER) not (SQLEN*) - PAH */
619 										/* Ms now say SQLLEN*
620                                            http://msdn.microsoft.com/library/en-us/odbc/htm/dasdkodbcoverview_64bit.asp - NG */
621 
622 #endif
623 
624 
625     SQLRETURN  SQL_API SQLColumns(SQLHSTMT StatementHandle,
626                                   SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
627                                   SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
628                                   SQLCHAR *TableName, SQLSMALLINT NameLength3,
629                                   SQLCHAR *ColumnName, SQLSMALLINT NameLength4);
630 
631 
632     SQLRETURN  SQL_API SQLConnect(SQLHDBC ConnectionHandle,
633                                   SQLCHAR *ServerName, SQLSMALLINT NameLength1,
634                                   SQLCHAR *UserName, SQLSMALLINT NameLength2,
635                                   SQLCHAR *Authentication, SQLSMALLINT NameLength3);
636 
637 #if (ODBCVER >= 0x0300)
638     SQLRETURN  SQL_API SQLCopyDesc(SQLHDESC SourceDescHandle,
639                                    SQLHDESC TargetDescHandle);
640 #endif
641 
642     SQLRETURN  SQL_API SQLDataSources(SQLHENV EnvironmentHandle,
643                                       SQLUSMALLINT Direction, SQLCHAR *ServerName,
644                                       SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
645                                       SQLCHAR *Description, SQLSMALLINT BufferLength2,
646                                       SQLSMALLINT *NameLength2);
647 
648     SQLRETURN  SQL_API SQLDescribeCol(SQLHSTMT StatementHandle,
649                                       SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName,
650                                       SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
651                                       SQLSMALLINT *DataType, SQLULEN *ColumnSize,
652                                       SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable);
653 
654     SQLRETURN  SQL_API SQLDisconnect(SQLHDBC ConnectionHandle);
655 
656 #if (ODBCVER >= 0x0300)
657     SQLRETURN  SQL_API SQLEndTran(SQLSMALLINT HandleType, SQLHANDLE Handle,
658                                   SQLSMALLINT CompletionType);
659 #endif
660 
661     SQLRETURN  SQL_API SQLError(SQLHENV EnvironmentHandle,
662                                 SQLHDBC ConnectionHandle, SQLHSTMT StatementHandle,
663                                 SQLCHAR *Sqlstate, SQLINTEGER *NativeError,
664                                 SQLCHAR *MessageText, SQLSMALLINT BufferLength,
665                                 SQLSMALLINT *TextLength);
666 
667     SQLRETURN  SQL_API SQLExecDirect(SQLHSTMT StatementHandle,
668                                      SQLCHAR *StatementText, SQLINTEGER TextLength);
669 
670     SQLRETURN  SQL_API SQLExecute(SQLHSTMT StatementHandle);
671 
672     SQLRETURN  SQL_API SQLFetch(SQLHSTMT StatementHandle);
673 
674 #if (ODBCVER >= 0x0300)
675     SQLRETURN  SQL_API SQLFetchScroll(SQLHSTMT StatementHandle,
676                                       SQLSMALLINT FetchOrientation, SQLLEN FetchOffset);
677 #endif
678 
679     SQLRETURN  SQL_API SQLFreeConnect(SQLHDBC ConnectionHandle);
680 
681     SQLRETURN  SQL_API SQLFreeEnv(SQLHENV EnvironmentHandle);
682 
683 #if (ODBCVER >= 0x0300)
684     SQLRETURN  SQL_API SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle);
685 #endif
686 
687     SQLRETURN  SQL_API SQLFreeStmt(SQLHSTMT StatementHandle,
688                                    SQLUSMALLINT Option);
689 
690 #if (ODBCVER >= 0x0300)
691     SQLRETURN  SQL_API SQLGetConnectAttr(SQLHDBC ConnectionHandle,
692                                          SQLINTEGER Attribute, SQLPOINTER Value,
693                                          SQLINTEGER BufferLength, SQLINTEGER *StringLength);
694 #endif
695 
696     SQLRETURN  SQL_API SQLGetConnectOption(SQLHDBC ConnectionHandle,
697                                            SQLUSMALLINT Option, SQLPOINTER Value);
698 
699     SQLRETURN  SQL_API SQLGetCursorName(SQLHSTMT StatementHandle,
700                                         SQLCHAR *CursorName, SQLSMALLINT BufferLength,
701                                         SQLSMALLINT *NameLength);
702 
703     SQLRETURN  SQL_API SQLGetData(SQLHSTMT StatementHandle,
704                                   SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
705                                   SQLPOINTER TargetValue, SQLLEN BufferLength,
706                                   SQLLEN *StrLen_or_Ind);
707 
708 #if (ODBCVER >= 0x0300)
709     SQLRETURN   SQLGetDescField(SQLHDESC DescriptorHandle,
710                                 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
711                                 SQLPOINTER Value, SQLINTEGER BufferLength,
712                                 SQLINTEGER *StringLength);
713 
714     SQLRETURN  SQL_API SQLGetDescRec(SQLHDESC DescriptorHandle,
715                                      SQLSMALLINT RecNumber, SQLCHAR *Name,
716                                      SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
717                                      SQLSMALLINT *Type, SQLSMALLINT *SubType,
718                                      SQLLEN *Length, SQLSMALLINT *Precision,
719                                      SQLSMALLINT *Scale, SQLSMALLINT *Nullable);
720 
721     SQLRETURN  SQL_API SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle,
722                                        SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier,
723                                        SQLPOINTER DiagInfo, SQLSMALLINT BufferLength,
724                                        SQLSMALLINT *StringLength);
725 
726     SQLRETURN  SQL_API SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle,
727                                      SQLSMALLINT RecNumber, SQLCHAR *Sqlstate,
728                                      SQLINTEGER *NativeError, SQLCHAR *MessageText,
729                                      SQLSMALLINT BufferLength, SQLSMALLINT *TextLength);
730 
731     SQLRETURN  SQL_API SQLGetEnvAttr(SQLHENV EnvironmentHandle,
732                                      SQLINTEGER Attribute, SQLPOINTER Value,
733                                      SQLINTEGER BufferLength, SQLINTEGER *StringLength);
734 #endif  /* ODBCVER >= 0x0300 */
735 
736     SQLRETURN  SQL_API SQLGetFunctions(SQLHDBC ConnectionHandle,
737                                        SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported);
738 
739     SQLRETURN  SQL_API SQLGetInfo(SQLHDBC ConnectionHandle,
740                                   SQLUSMALLINT InfoType, SQLPOINTER InfoValue,
741                                   SQLSMALLINT BufferLength, SQLSMALLINT *StringLength);
742 
743 #if (ODBCVER >= 0x0300)
744     SQLRETURN  SQL_API SQLGetStmtAttr(SQLHSTMT StatementHandle,
745                                       SQLINTEGER Attribute, SQLPOINTER Value,
746                                       SQLINTEGER BufferLength, SQLINTEGER *StringLength);
747 #endif  /* ODBCVER >= 0x0300 */
748 
749     SQLRETURN  SQL_API SQLGetStmtOption(SQLHSTMT StatementHandle,
750                                         SQLUSMALLINT Option, SQLPOINTER Value);
751 
752     SQLRETURN  SQL_API SQLGetTypeInfo(SQLHSTMT StatementHandle,
753                                       SQLSMALLINT DataType);
754 
755     SQLRETURN  SQL_API SQLNumResultCols(SQLHSTMT StatementHandle,
756                                         SQLSMALLINT *ColumnCount);
757 
758     SQLRETURN  SQL_API SQLParamData(SQLHSTMT StatementHandle,
759                                     SQLPOINTER *Value);
760 
761     SQLRETURN  SQL_API SQLPrepare(SQLHSTMT StatementHandle,
762                                   SQLCHAR *StatementText, SQLINTEGER TextLength);
763 
764     SQLRETURN  SQL_API SQLPutData(SQLHSTMT StatementHandle,
765                                   SQLPOINTER Data, SQLLEN StrLen_or_Ind);
766 
767     SQLRETURN  SQL_API SQLRowCount(SQLHSTMT StatementHandle,
768                                    SQLLEN *RowCount);
769 
770 #if (ODBCVER >= 0x0300)
771     SQLRETURN  SQL_API SQLSetConnectAttr(SQLHDBC ConnectionHandle,
772                                          SQLINTEGER Attribute, SQLPOINTER Value,
773                                          SQLINTEGER StringLength);
774 #endif /* ODBCVER >= 0x0300 */
775 
776     SQLRETURN  SQL_API SQLSetConnectOption(SQLHDBC ConnectionHandle,
777                                            SQLUSMALLINT Option, SQLULEN Value);
778 
779     SQLRETURN  SQL_API SQLSetCursorName(SQLHSTMT StatementHandle,
780                                         SQLCHAR *CursorName, SQLSMALLINT NameLength);
781 
782 #if (ODBCVER >= 0x0300)
783     SQLRETURN  SQL_API SQLSetDescField(SQLHDESC DescriptorHandle,
784                                        SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
785                                        SQLPOINTER Value, SQLINTEGER BufferLength);
786 
787     SQLRETURN  SQL_API SQLSetDescRec(SQLHDESC DescriptorHandle,
788                                      SQLSMALLINT RecNumber, SQLSMALLINT Type,
789                                      SQLSMALLINT SubType, SQLLEN Length,
790                                      SQLSMALLINT Precision, SQLSMALLINT Scale,
791                                      SQLPOINTER Data, SQLLEN *StringLength,
792                                      SQLLEN *Indicator);
793 
794     SQLRETURN  SQL_API SQLSetEnvAttr(SQLHENV EnvironmentHandle,
795                                      SQLINTEGER Attribute, SQLPOINTER Value,
796                                      SQLINTEGER StringLength);
797 #endif /* ODBCVER >= 0x0300 */
798 
799     SQLRETURN  SQL_API SQLSetParam(SQLHSTMT StatementHandle,
800                                    SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
801                                    SQLSMALLINT ParameterType, SQLULEN LengthPrecision,
802                                    SQLSMALLINT ParameterScale, SQLPOINTER ParameterValue,
803                                    SQLLEN *StrLen_or_Ind);
804 
805 #if (ODBCVER >= 0x0300)
806     SQLRETURN  SQL_API SQLSetStmtAttr(SQLHSTMT StatementHandle,
807                                       SQLINTEGER Attribute, SQLPOINTER Value,
808                                       SQLINTEGER StringLength);
809 #endif
810 
811     SQLRETURN  SQL_API SQLSetStmtOption(SQLHSTMT StatementHandle,
812                                         SQLUSMALLINT Option, SQLULEN Value);
813 
814     SQLRETURN  SQL_API SQLSpecialColumns(SQLHSTMT StatementHandle,
815                                          SQLUSMALLINT IdentifierType, SQLCHAR *CatalogName,
816                                          SQLSMALLINT NameLength1, SQLCHAR *SchemaName,
817                                          SQLSMALLINT NameLength2, SQLCHAR *TableName,
818                                          SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
819                                          SQLUSMALLINT Nullable);
820 
821     SQLRETURN  SQL_API SQLStatistics(SQLHSTMT StatementHandle,
822                                      SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
823                                      SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
824                                      SQLCHAR *TableName, SQLSMALLINT NameLength3,
825                                      SQLUSMALLINT Unique, SQLUSMALLINT Reserved);
826 
827     SQLRETURN   SQL_API SQLTables(SQLHSTMT StatementHandle,
828                                   SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
829                                   SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
830                                   SQLCHAR *TableName, SQLSMALLINT NameLength3,
831                                   SQLCHAR *TableType, SQLSMALLINT NameLength4);
832 
833     SQLRETURN  SQL_API SQLTransact(SQLHENV EnvironmentHandle,
834                                    SQLHDBC ConnectionHandle, SQLUSMALLINT CompletionType);
835 
836 #ifdef __cplusplus
837 }
838 #endif
839 #endif
840