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