NCBI C++ ToolKit
sqltypes.h
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /*************************************************************
2  * sqltypes.h
3  *
4  * This is the lowest level include in unixODBC. It defines
5  * the basic types required by unixODBC and is heavily based
6  * upon the MS include of the same name (it has to be for
7  * binary compatability between drivers developed under different
8  * packages).
9  *
10  * You can include this file directly but it is almost always
11  * included indirectly, by including.. for example sqlext.h
12  *
13  * This include makes no effort to be usefull on any platforms other
14  * than Linux (with some exceptions for UNIX in general).
15  *
16  * !!!DO NOT CONTAMINATE THIS FILE WITH NON-Linux CODE!!!
17  *
18  *************************************************************/
19 #ifndef __SQLTYPES_H
20 #define __SQLTYPES_H
21 
22 /****************************
23  * default to the 3.80 definitions. should define ODBCVER before here if you want an older set of defines
24  ***************************/
25 #ifndef ODBCVER
26 #define ODBCVER 0x0380
27 #endif
28 
29 /*
30  * if thi sis set, then use a 4 byte unicode definition, insteead of the 2 bye that MS use
31  */
32 
33 #ifdef SQL_WCHART_CONVERT
34 /*
35  * Use this if you want to use the C/C++ portable definition of a wide char, wchar_t
36  * Microsoft hardcoded a definition of unsigned short which may not be compatible with
37  * your platform specific wide char definition.
38  */
39 #include <wchar.h>
40 #endif
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /*
47  * this is defined by configure, but will not be on a normal application build
48  * the install creates a unixodbc_conf.h file that contains the current build settings
49  */
50 
51 #ifndef SIZEOF_LONG_INT
52 #include "unixodbc_conf.h"
53 #endif
54 
55 #ifndef SIZEOF_LONG_INT
56 #error "Needs to know how big a long int is to continue!!!"
57 #endif
58 
59 /****************************
60  * These make up for having no windows.h
61  ***************************/
62 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
63 
64 #define FAR
65 #define CALLBACK
66 #ifdef __OS2__
67 #define SQL_API _System
68 #else
69 #define SQL_API
70 #endif
71 #define BOOL int
72 #ifndef _WINDOWS_
73 typedef void* HWND;
74 #endif
75 typedef char CHAR;
76 #ifdef UNICODE
77 
78 /*
79  * NOTE: The Microsoft unicode define is only for apps that want to use TCHARs and
80  * be able to compile for both unicode and non-unicode with the same source.
81  * This is not recommanded for linux applications and is not supported
82  * by the standard linux string header files.
83  */
84 #ifdef SQL_WCHART_CONVERT
85 typedef wchar_t TCHAR;
86 #else
87 typedef signed short TCHAR;
88 #endif
89 
90 #else
91 typedef char TCHAR;
92 #endif
93 
94 typedef unsigned short WORD;
95 #if (SIZEOF_INT == 2)
96 typedef unsigned long DWORD;
97 #else
98 typedef unsigned int DWORD;
99 #endif
100 typedef unsigned char BYTE;
101 
102 #ifdef SQL_WCHART_CONVERT
103 typedef wchar_t WCHAR;
104 #else
105 typedef unsigned short WCHAR;
106 #endif
107 
108 typedef WCHAR* LPWSTR;
109 typedef const char* LPCSTR;
110 typedef const WCHAR* LPCWSTR;
111 typedef TCHAR* LPTSTR;
112 typedef char* LPSTR;
113 typedef DWORD* LPDWORD;
114 
115 #ifndef _WINDOWS_
116 typedef void* HINSTANCE;
117 #endif
118 
119 #endif
120 
121 
122 /****************************
123  * standard SQL* data types. use these as much as possible when using ODBC calls/vars
124  ***************************/
125 typedef unsigned char SQLCHAR;
126 
127 #if (ODBCVER >= 0x0300)
128 typedef unsigned char SQLDATE;
129 typedef unsigned char SQLDECIMAL;
130 typedef double SQLDOUBLE;
131 typedef double SQLFLOAT;
132 #endif
133 
134 /*
135  * can't use a long it fails on 64 platforms
136  */
137 
138 /*
139  * Hopefully by now it should be safe to assume most drivers know about SQLLEN now
140  * and the defaukt is now sizeof( SQLLEN ) = 8 on 64 bit platforms
141  *
142  */
143 
144 #if (SIZEOF_LONG_INT == 8)
145 #ifdef BUILD_LEGACY_64_BIT_MODE
146 typedef int SQLINTEGER;
147 typedef unsigned int SQLUINTEGER;
148 #define SQLLEN SQLINTEGER
149 #define SQLULEN SQLUINTEGER
150 #define SQLSETPOSIROW SQLUSMALLINT
151 /*
152  * These are not supprted on 64bit ODBC according to MS, removed, so use at your peril
153  *
154  typedef SQLULEN SQLROWCOUNT;
155  typedef SQLULEN SQLROWSETSIZE;
156  typedef SQLULEN SQLTRANSID;
157  typedef SQLLEN SQLROWOFFSET;
158 */
159 #else
160 typedef int SQLINTEGER;
161 typedef unsigned int SQLUINTEGER;
162 typedef long SQLLEN;
163 typedef unsigned long SQLULEN;
164 typedef unsigned long SQLSETPOSIROW;
165 /*
166  * These are not supprted on 64bit ODBC according to MS, removed, so use at your peril
167  *
168  typedef SQLULEN SQLTRANSID;
169  typedef SQLULEN SQLROWCOUNT;
170  typedef SQLUINTEGER SQLROWSETSIZE;
171  typedef SQLLEN SQLROWOFFSET;
172  */
173 #endif
174 #else
175 #if SIZEOF_INT < 4
176 typedef long SQLINTEGER;
177 typedef unsigned long SQLUINTEGER;
178 #else
179 typedef int SQLINTEGER;
180 typedef unsigned int SQLUINTEGER;
181 #endif
182 #define SQLLEN SQLINTEGER
183 #define SQLULEN SQLUINTEGER
184 #define SQLSETPOSIROW SQLUSMALLINT
189 #endif
190 
191 #if (ODBCVER >= 0x0300)
192 typedef unsigned char SQLNUMERIC;
193 #endif
194 
195 typedef void * SQLPOINTER;
196 
197 #if (ODBCVER >= 0x0300)
198 typedef float SQLREAL;
199 #endif
200 
201 typedef signed short int SQLSMALLINT;
202 typedef unsigned short SQLUSMALLINT;
203 
204 #if (ODBCVER >= 0x0300)
205 typedef unsigned char SQLTIME;
206 typedef unsigned char SQLTIMESTAMP;
207 typedef unsigned char SQLVARCHAR;
208 #endif
209 
211 
212 #if (ODBCVER >= 0x0300)
213 typedef void * SQLHANDLE;
218 #else
219 typedef void * SQLHENV;
220 typedef void * SQLHDBC;
221 typedef void * SQLHSTMT;
222 /*
223  * some things like PHP won't build without this
224  */
225 typedef void * SQLHANDLE;
226 #endif
227 
228 /****************************
229  * These are cast into the actual struct that is being passed around. The
230  * DriverManager knows what its structs look like and the Driver knows about its
231  * structs... the app knows nothing about them... just void*
232  * These are deprecated in favour of SQLHENV, SQLHDBC, SQLHSTMT
233  ***************************/
234 
235 #if (ODBCVER >= 0x0300)
236 typedef SQLHANDLE HENV;
237 typedef SQLHANDLE HDBC;
238 typedef SQLHANDLE HSTMT;
239 #else
240 typedef void * HENV;
241 typedef void * HDBC;
242 typedef void * HSTMT;
243 #endif
244 
245 
246 /****************************
247  * more basic data types to augment what windows.h provides
248  ***************************/
249 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
250 
251 typedef unsigned char UCHAR;
252 typedef signed char SCHAR;
253 typedef SCHAR SQLSCHAR;
254 #if (SIZEOF_LONG_INT == 4)
255 typedef long int SDWORD;
256 typedef unsigned long int UDWORD;
257 #else
258 typedef int SDWORD;
259 typedef unsigned int UDWORD;
260 #endif
261 typedef signed short int SWORD;
262 typedef unsigned short int UWORD;
263 typedef unsigned int UINT;
264 typedef signed long SLONG;
265 typedef signed short SSHORT;
266 typedef unsigned long ULONG;
267 typedef unsigned short USHORT;
268 typedef double SDOUBLE;
269 typedef double LDOUBLE;
270 typedef float SFLOAT;
271 typedef void* PTR;
272 typedef signed short RETCODE;
273 typedef void* SQLHWND;
274 
275 #endif
276 
277 /****************************
278  * standard structs for working with date/times
279  ***************************/
280 #ifndef __SQLDATE
281 #define __SQLDATE
282 typedef struct tagDATE_STRUCT
283 {
288 
289 #if (ODBCVER >= 0x0300)
291 #endif
292 
293 typedef struct tagTIME_STRUCT
294 {
299 
300 #if (ODBCVER >= 0x0300)
302 #endif
303 
304 typedef struct tagTIMESTAMP_STRUCT
305 {
314 
315 #if (ODBCVER >= 0x0300)
317 #endif
318 
319 
320 #if (ODBCVER >= 0x0300)
321 typedef enum
322 {
337 
338 #endif
339 
340 #if (ODBCVER >= 0x0300)
341 typedef struct tagSQL_YEAR_MONTH
342 {
346 
347 typedef struct tagSQL_DAY_SECOND
348 {
355 
357 {
360  union {
364 
366 
367 #endif
368 
369 #endif
370 
371 /****************************
372  *
373  ***************************/
374 #ifndef ODBCINT64
375 # if (ODBCVER >= 0x0300)
376 # if (SIZEOF_LONG_INT == 8)
377 # define ODBCINT64 long
378 # define UODBCINT64 unsigned long
379 # define ODBCINT64_TYPE "long"
380 # define UODBCINT64_TYPE "unsigned long"
381 # else
382 # ifdef HAVE_LONG_LONG
383 # define ODBCINT64 long long
384 # define UODBCINT64 unsigned long long
385 # define ODBCINT64_TYPE "long long"
386 # define UODBCINT64_TYPE "unsigned long long"
387 # else
388 /*
389  * may fail in some cases, but what else can we do ?
390  */
392 {
393  int hiword;
394  unsigned int loword;
395 };
397 {
398  unsigned int hiword;
399  unsigned int loword;
400 };
401 # define ODBCINT64 struct __bigint_struct
402 # define UODBCINT64 struct __bigint_struct_u
403 # define ODBCINT64_TYPE "struct __bigint_struct"
404 # define UODBCINT64_TYPE "struct __bigint_struct_u"
405 # endif
406 # endif
407 #endif
408 #endif
409 
410 #ifdef ODBCINT64
411 typedef ODBCINT64 SQLBIGINT;
412 #endif
413 #ifdef UODBCINT64
414 typedef UODBCINT64 SQLUBIGINT;
415 #endif
416 
417 
418 /****************************
419  * cursor and bookmark
420  ***************************/
421 #if (ODBCVER >= 0x0300)
422 #define SQL_MAX_NUMERIC_LEN 16
423 typedef struct tagSQL_NUMERIC_STRUCT
424 {
427  SQLCHAR sign; /* 1=pos 0=neg */
430 #endif
431 
432 #if (ODBCVER >= 0x0350)
433 #ifdef GUID_DEFINED
434 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
435 typedef GUID SQLGUID;
436 #else
437 typedef struct tagSQLGUID
438 {
439  DWORD Data1;
440  WORD Data2;
441  WORD Data3;
442  BYTE Data4[ 8 ];
443 } SQLGUID;
444 #endif
445 #else
446 typedef struct tagSQLGUID
447 {
451  BYTE Data4[ 8 ];
453 #endif
454 #endif
455 
457 
458 typedef WCHAR SQLWCHAR;
459 
460 #ifdef UNICODE
461 typedef SQLWCHAR SQLTCHAR;
462 #else
464 #endif
465 
466 #ifdef __cplusplus
467 }
468 #endif
469 
470 #endif
471 
472 
473 
SQLUINTEGER SQLROWSETSIZE
Definition: sqltypes.h:186
char TCHAR
Definition: sqltypes.h:91
float SFLOAT
Definition: sqltypes.h:270
SQLHANDLE SQLHENV
Definition: sqltypes.h:214
struct tagSQL_NUMERIC_STRUCT SQL_NUMERIC_STRUCT
WCHAR * LPWSTR
Definition: sqltypes.h:108
#define SQLULEN
Definition: sqltypes.h:183
char * LPSTR
Definition: sqltypes.h:112
DWORD * LPDWORD
Definition: sqltypes.h:113
unsigned short WORD
Definition: sqltypes.h:94
float SQLREAL
Definition: sqltypes.h:198
SQLHANDLE HSTMT
Definition: sqltypes.h:238
unsigned char SQLNUMERIC
Definition: sqltypes.h:192
unsigned long SQLUINTEGER
Definition: sqltypes.h:177
struct tagDATE_STRUCT DATE_STRUCT
TCHAR * LPTSTR
Definition: sqltypes.h:111
unsigned short SQLUSMALLINT
Definition: sqltypes.h:202
#define ODBCINT64
Definition: sqltypes.h:401
void * SQLPOINTER
Definition: sqltypes.h:195
double SQLFLOAT
Definition: sqltypes.h:131
struct tagSQLGUID SQLGUID
SQLHANDLE HDBC
Definition: sqltypes.h:237
#define UODBCINT64
Definition: sqltypes.h:402
unsigned int UINT
Definition: sqltypes.h:263
SQLHANDLE SQLHDBC
Definition: sqltypes.h:215
void * SQLHWND
Definition: sqltypes.h:273
SQLUINTEGER SQLROWCOUNT
Definition: sqltypes.h:185
SQLCHAR SQLTCHAR
Definition: sqltypes.h:463
struct tagSQL_YEAR_MONTH SQL_YEAR_MONTH_STRUCT
double LDOUBLE
Definition: sqltypes.h:269
#define SQLLEN
Definition: sqltypes.h:182
double SQLDOUBLE
Definition: sqltypes.h:130
unsigned char BYTE
Definition: sqltypes.h:100
unsigned char SQLVARCHAR
Definition: sqltypes.h:207
unsigned char UCHAR
Definition: sqltypes.h:251
WCHAR SQLWCHAR
Definition: sqltypes.h:458
unsigned short WCHAR
Definition: sqltypes.h:105
unsigned short USHORT
Definition: sqltypes.h:267
unsigned char SQLTIME
Definition: sqltypes.h:205
void * PTR
Definition: sqltypes.h:271
SQLUINTEGER SQLTRANSID
Definition: sqltypes.h:187
void * HWND
Definition: sqltypes.h:73
long SQLINTEGER
Definition: sqltypes.h:176
struct tagTIMESTAMP_STRUCT TIMESTAMP_STRUCT
struct __bigint_struct SQLBIGINT
Definition: sqltypes.h:411
unsigned int DWORD
Definition: sqltypes.h:98
SQLINTEGER SQLROWOFFSET
Definition: sqltypes.h:188
SQLUINTEGER BOOKMARK
Definition: sqltypes.h:456
signed long SLONG
Definition: sqltypes.h:264
unsigned int UDWORD
Definition: sqltypes.h:259
SQLINTERVAL
Definition: sqltypes.h:322
@ SQL_IS_HOUR
Definition: sqltypes.h:326
@ SQL_IS_HOUR_TO_MINUTE
Definition: sqltypes.h:333
@ SQL_IS_HOUR_TO_SECOND
Definition: sqltypes.h:334
@ SQL_IS_YEAR_TO_MONTH
Definition: sqltypes.h:329
@ SQL_IS_DAY_TO_MINUTE
Definition: sqltypes.h:331
@ SQL_IS_SECOND
Definition: sqltypes.h:328
@ SQL_IS_DAY
Definition: sqltypes.h:325
@ SQL_IS_YEAR
Definition: sqltypes.h:323
@ SQL_IS_DAY_TO_HOUR
Definition: sqltypes.h:330
@ SQL_IS_MINUTE_TO_SECOND
Definition: sqltypes.h:335
@ SQL_IS_MONTH
Definition: sqltypes.h:324
@ SQL_IS_MINUTE
Definition: sqltypes.h:327
@ SQL_IS_DAY_TO_SECOND
Definition: sqltypes.h:332
const WCHAR * LPCWSTR
Definition: sqltypes.h:110
double SDOUBLE
Definition: sqltypes.h:268
int SDWORD
Definition: sqltypes.h:258
struct tagSQL_INTERVAL_STRUCT SQL_INTERVAL_STRUCT
signed short int SWORD
Definition: sqltypes.h:261
struct tagTIME_STRUCT TIME_STRUCT
SQLHANDLE SQLHSTMT
Definition: sqltypes.h:216
signed char SCHAR
Definition: sqltypes.h:252
unsigned char SQLCHAR
Definition: sqltypes.h:125
DATE_STRUCT SQL_DATE_STRUCT
Definition: sqltypes.h:290
unsigned char SQLTIMESTAMP
Definition: sqltypes.h:206
struct tagSQL_DAY_SECOND SQL_DAY_SECOND_STRUCT
signed short RETCODE
Definition: sqltypes.h:272
SQLHANDLE HENV
Definition: sqltypes.h:236
void * SQLHANDLE
Definition: sqltypes.h:213
unsigned char SQLDECIMAL
Definition: sqltypes.h:129
unsigned short int UWORD
Definition: sqltypes.h:262
TIME_STRUCT SQL_TIME_STRUCT
Definition: sqltypes.h:301
void * HINSTANCE
Definition: sqltypes.h:116
struct __bigint_struct_u SQLUBIGINT
Definition: sqltypes.h:414
const char * LPCSTR
Definition: sqltypes.h:109
signed short int SQLSMALLINT
Definition: sqltypes.h:201
signed short SSHORT
Definition: sqltypes.h:265
unsigned char SQLDATE
Definition: sqltypes.h:128
#define SQL_MAX_NUMERIC_LEN
Definition: sqltypes.h:422
char CHAR
Definition: sqltypes.h:75
#define SQLSETPOSIROW
Definition: sqltypes.h:184
TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT
Definition: sqltypes.h:316
SCHAR SQLSCHAR
Definition: sqltypes.h:253
SQLSMALLINT SQLRETURN
Definition: sqltypes.h:210
unsigned long ULONG
Definition: sqltypes.h:266
SQLHANDLE SQLHDESC
Definition: sqltypes.h:217
unsigned int loword
Definition: sqltypes.h:399
unsigned int hiword
Definition: sqltypes.h:398
unsigned int loword
Definition: sqltypes.h:394
SQLSMALLINT year
Definition: sqltypes.h:284
SQLUSMALLINT day
Definition: sqltypes.h:286
SQLUSMALLINT month
Definition: sqltypes.h:285
BYTE Data4[8]
Definition: sqltypes.h:451
WORD Data2
Definition: sqltypes.h:449
DWORD Data1
Definition: sqltypes.h:448
WORD Data3
Definition: sqltypes.h:450
SQLUINTEGER hour
Definition: sqltypes.h:350
SQLUINTEGER fraction
Definition: sqltypes.h:353
SQLUINTEGER day
Definition: sqltypes.h:349
SQLUINTEGER second
Definition: sqltypes.h:352
SQLUINTEGER minute
Definition: sqltypes.h:351
SQLSMALLINT interval_sign
Definition: sqltypes.h:359
union tagSQL_INTERVAL_STRUCT::@130 intval
SQL_YEAR_MONTH_STRUCT year_month
Definition: sqltypes.h:361
SQLINTERVAL interval_type
Definition: sqltypes.h:358
SQL_DAY_SECOND_STRUCT day_second
Definition: sqltypes.h:362
SQLCHAR val[16]
Definition: sqltypes.h:428
SQLUINTEGER year
Definition: sqltypes.h:343
SQLUINTEGER month
Definition: sqltypes.h:344
SQLUSMALLINT hour
Definition: sqltypes.h:309
SQLUINTEGER fraction
Definition: sqltypes.h:312
SQLUSMALLINT second
Definition: sqltypes.h:311
SQLSMALLINT year
Definition: sqltypes.h:306
SQLUSMALLINT month
Definition: sqltypes.h:307
SQLUSMALLINT day
Definition: sqltypes.h:308
SQLUSMALLINT minute
Definition: sqltypes.h:310
SQLUSMALLINT hour
Definition: sqltypes.h:295
SQLUSMALLINT minute
Definition: sqltypes.h:296
SQLUSMALLINT second
Definition: sqltypes.h:297
unsigned char BYTE
Definition: sybdb.h:334
Modified on Mon Apr 01 03:54:56 2024 by modify_doxy.py rev. 669887