sqltypes.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. /*
  2. * sqltypes.h
  3. *
  4. * $Id: sqltypes.h,v 1.25 2009/09/09 20:06:24 source Exp $
  5. *
  6. * ODBC typedefs
  7. *
  8. * The iODBC driver manager.
  9. *
  10. * Copyright (C) 1995 by Ke Jin <[email protected]>
  11. * Copyright (C) 1996-2009 by OpenLink Software <[email protected]>
  12. * All Rights Reserved.
  13. *
  14. * This software is released under the terms of either of the following
  15. * licenses:
  16. *
  17. * - GNU Library General Public License (see LICENSE.LGPL)
  18. * - The BSD License (see LICENSE.BSD).
  19. *
  20. * Note that the only valid version of the LGPL license as far as this
  21. * project is concerned is the original GNU Library General Public License
  22. * Version 2, dated June 1991.
  23. *
  24. * While not mandated by the BSD license, any patches you make to the
  25. * iODBC source code may be contributed back into the iODBC project
  26. * at your discretion. Contributions will benefit the Open Source and
  27. * Data Access community as a whole. Submissions may be made at:
  28. *
  29. * http://www.iodbc.org
  30. *
  31. *
  32. * GNU Library Generic Public License Version 2
  33. * ============================================
  34. * This library is free software; you can redistribute it and/or
  35. * modify it under the terms of the GNU Library General Public
  36. * License as published by the Free Software Foundation; only
  37. * Version 2 of the License dated June 1991.
  38. *
  39. * This library is distributed in the hope that it will be useful,
  40. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  41. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  42. * Library General Public License for more details.
  43. *
  44. * You should have received a copy of the GNU Library General Public
  45. * License along with this library; if not, write to the Free
  46. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  47. *
  48. *
  49. * The BSD License
  50. * ===============
  51. * Redistribution and use in source and binary forms, with or without
  52. * modification, are permitted provided that the following conditions
  53. * are met:
  54. *
  55. * 1. Redistributions of source code must retain the above copyright
  56. * notice, this list of conditions and the following disclaimer.
  57. * 2. Redistributions in binary form must reproduce the above copyright
  58. * notice, this list of conditions and the following disclaimer in
  59. * the documentation and/or other materials provided with the
  60. * distribution.
  61. * 3. Neither the name of OpenLink Software Inc. nor the names of its
  62. * contributors may be used to endorse or promote products derived
  63. * from this software without specific prior written permission.
  64. *
  65. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  66. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  67. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  68. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OPENLINK OR
  69. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  70. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  71. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  72. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  73. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  74. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  75. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  76. */
  77. #ifndef _SQLTYPES_H
  78. #define _SQLTYPES_H
  79. /*
  80. * Set default specification to ODBC 3.51
  81. */
  82. #ifndef ODBCVER
  83. #define ODBCVER 0x0351
  84. #endif
  85. /*
  86. * Include Windows style defines and typedefs on Unix
  87. */
  88. #ifndef _IODBCUNIX_H
  89. #include <iODBC/iodbcunix.h>
  90. #endif
  91. #ifdef __cplusplus
  92. extern "C" {
  93. #endif
  94. /*
  95. * Environment specific definitions
  96. */
  97. #ifndef EXPORT
  98. #define EXPORT
  99. #endif
  100. #ifdef WIN32
  101. #define SQL_API __stdcall
  102. #else
  103. #define SQL_API
  104. #endif
  105. /*
  106. * API declaration data types
  107. */
  108. typedef unsigned char SQLCHAR;
  109. typedef signed short SQLSMALLINT;
  110. typedef unsigned short SQLUSMALLINT;
  111. #if (SIZEOF_LONG == 8)
  112. typedef signed int SQLINTEGER;
  113. typedef unsigned int SQLUINTEGER;
  114. #else
  115. typedef signed long SQLINTEGER;
  116. typedef unsigned long SQLUINTEGER;
  117. #endif
  118. typedef void * SQLPOINTER;
  119. #if (ODBCVER >= 0x0300)
  120. typedef signed char SQLSCHAR;
  121. typedef unsigned char SQLDATE;
  122. typedef unsigned char SQLDECIMAL;
  123. typedef unsigned char SQLNUMERIC;
  124. typedef double SQLDOUBLE;
  125. typedef double SQLFLOAT;
  126. typedef float SQLREAL;
  127. typedef unsigned char SQLTIME;
  128. typedef unsigned char SQLTIMESTAMP;
  129. typedef unsigned char SQLVARCHAR;
  130. #endif /* ODBCVER >= 0x0300 */
  131. /*
  132. * New Win64 datatypes
  133. */
  134. #ifdef _WIN64
  135. typedef INT64 SQLLEN;
  136. typedef UINT64 SQLULEN;
  137. typedef UINT64 SQLSETPOSIROW;
  138. #elif defined(STRICT_ODBC_TYPES)
  139. typedef long SQLLEN;
  140. typedef unsigned long SQLULEN;
  141. typedef unsigned short SQLSETPOSIROW;
  142. #else
  143. #define SQLLEN long
  144. #define SQLULEN unsigned long
  145. #define SQLSETPOSIROW unsigned short
  146. #endif
  147. /*
  148. * Backward compatibility with older platform sdks
  149. */
  150. typedef SQLULEN SQLROWCOUNT;
  151. typedef SQLULEN SQLROWSETSIZE;
  152. typedef SQLULEN SQLTRANSID;
  153. typedef SQLLEN SQLROWOFFSET;
  154. /*
  155. * Generic pointer types
  156. */
  157. typedef void * PTR;
  158. typedef void * SQLHANDLE;
  159. /*
  160. * Handles
  161. */
  162. typedef void * HENV;
  163. typedef void * HDBC;
  164. typedef void * HSTMT;
  165. typedef SQLHANDLE SQLHENV;
  166. typedef SQLHANDLE SQLHDBC;
  167. typedef SQLHANDLE SQLHSTMT;
  168. #if (ODBCVER >= 0x0300)
  169. typedef SQLHANDLE SQLHDESC;
  170. #endif /* ODBCVER >= 0x0300 */
  171. /*
  172. * Window Handle
  173. */
  174. #if defined(WIN32) || defined (_WIN64) || defined(OS2)
  175. typedef HWND SQLHWND;
  176. #elif defined(macintosh)
  177. #include <Dialogs.h>
  178. typedef WindowPtr HWND;
  179. typedef HWND SQLHWND;
  180. #else
  181. typedef SQLPOINTER HWND;
  182. typedef SQLPOINTER SQLHWND;
  183. #endif
  184. /*
  185. * SQL portable types for C
  186. */
  187. typedef unsigned char UCHAR;
  188. typedef signed char SCHAR;
  189. typedef short int SWORD;
  190. typedef unsigned short int UWORD;
  191. typedef long int SDWORD;
  192. typedef unsigned long int UDWORD;
  193. typedef signed short SSHORT;
  194. typedef unsigned short USHORT;
  195. typedef signed long SLONG;
  196. typedef unsigned long ULONG;
  197. typedef float SFLOAT;
  198. typedef double SDOUBLE;
  199. typedef double LDOUBLE;
  200. /*
  201. * Return type for functions
  202. */
  203. typedef signed short RETCODE;
  204. typedef SQLSMALLINT SQLRETURN;
  205. /*
  206. * SQL portable types for C - DATA, TIME, TIMESTAMP, and BOOKMARK
  207. */
  208. typedef SQLULEN BOOKMARK;
  209. typedef struct tagDATE_STRUCT
  210. {
  211. SQLSMALLINT year;
  212. SQLUSMALLINT month;
  213. SQLUSMALLINT day;
  214. }
  215. DATE_STRUCT;
  216. #if (ODBCVER >= 0x0300)
  217. typedef DATE_STRUCT SQL_DATE_STRUCT;
  218. #endif /* ODBCVER >= 0x0300 */
  219. typedef struct tagTIME_STRUCT
  220. {
  221. SQLUSMALLINT hour;
  222. SQLUSMALLINT minute;
  223. SQLUSMALLINT second;
  224. }
  225. TIME_STRUCT;
  226. #if (ODBCVER >= 0x0300)
  227. typedef TIME_STRUCT SQL_TIME_STRUCT;
  228. #endif /* ODBCVER >= 0x0300 */
  229. typedef struct tagTIMESTAMP_STRUCT
  230. {
  231. SQLSMALLINT year;
  232. SQLUSMALLINT month;
  233. SQLUSMALLINT day;
  234. SQLUSMALLINT hour;
  235. SQLUSMALLINT minute;
  236. SQLUSMALLINT second;
  237. SQLUINTEGER fraction;
  238. }
  239. TIMESTAMP_STRUCT;
  240. #if (ODBCVER >= 0x0300)
  241. typedef TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT;
  242. #endif /* ODBCVER >= 0x0300 */
  243. /*
  244. * Enumeration for DATETIME_INTERVAL_SUBCODE values for interval data types
  245. *
  246. * These values are from SQL-92
  247. */
  248. #if (ODBCVER >= 0x0300)
  249. typedef enum
  250. {
  251. SQL_IS_YEAR = 1,
  252. SQL_IS_MONTH = 2,
  253. SQL_IS_DAY = 3,
  254. SQL_IS_HOUR = 4,
  255. SQL_IS_MINUTE = 5,
  256. SQL_IS_SECOND = 6,
  257. SQL_IS_YEAR_TO_MONTH = 7,
  258. SQL_IS_DAY_TO_HOUR = 8,
  259. SQL_IS_DAY_TO_MINUTE = 9,
  260. SQL_IS_DAY_TO_SECOND = 10,
  261. SQL_IS_HOUR_TO_MINUTE = 11,
  262. SQL_IS_HOUR_TO_SECOND = 12,
  263. SQL_IS_MINUTE_TO_SECOND = 13
  264. }
  265. SQLINTERVAL;
  266. typedef struct tagSQL_YEAR_MONTH
  267. {
  268. SQLUINTEGER year;
  269. SQLUINTEGER month;
  270. }
  271. SQL_YEAR_MONTH_STRUCT;
  272. typedef struct tagSQL_DAY_SECOND
  273. {
  274. SQLUINTEGER day;
  275. SQLUINTEGER hour;
  276. SQLUINTEGER minute;
  277. SQLUINTEGER second;
  278. SQLUINTEGER fraction;
  279. }
  280. SQL_DAY_SECOND_STRUCT;
  281. typedef struct tagSQL_INTERVAL_STRUCT
  282. {
  283. SQLINTERVAL interval_type;
  284. SQLSMALLINT interval_sign;
  285. union
  286. {
  287. SQL_YEAR_MONTH_STRUCT year_month;
  288. SQL_DAY_SECOND_STRUCT day_second;
  289. }
  290. intval;
  291. }
  292. SQL_INTERVAL_STRUCT;
  293. #endif /* ODBCVER >= 0x0300 */
  294. /*
  295. * The ODBC C types for SQL_C_SBIGINT and SQL_C_UBIGINT
  296. */
  297. #if (ODBCVER >= 0x0300)
  298. #if (_MSC_VER >= 900)
  299. # define ODBCINT64 __int64
  300. #endif
  301. #ifndef ODBCINT64
  302. # if (SIZEOF_LONG == 8)
  303. # define ODBCINT64 long
  304. # else
  305. # define ODBCINT64 long long
  306. # endif
  307. #endif /* ODBCINT64 */
  308. #if defined (ODBCINT64)
  309. typedef signed ODBCINT64 SQLBIGINT;
  310. typedef unsigned ODBCINT64 SQLUBIGINT;
  311. #endif /* ODBCINT64 */
  312. #endif /* ODBCVER >= 0x0300 */
  313. /*
  314. * The internal representation of the numeric data type
  315. */
  316. #if (ODBCVER >= 0x0300)
  317. #define SQL_MAX_NUMERIC_LEN 16
  318. typedef struct tagSQL_NUMERIC_STRUCT
  319. {
  320. SQLCHAR precision;
  321. SQLSCHAR scale;
  322. SQLCHAR sign; /* 0 for negative, 1 for positive */
  323. SQLCHAR val[SQL_MAX_NUMERIC_LEN];
  324. }
  325. SQL_NUMERIC_STRUCT;
  326. #endif /* ODBCVER >= 0x0300 */
  327. #if (ODBCVER >= 0x0350)
  328. #ifdef GUID_DEFINED
  329. typedef GUID SQLGUID;
  330. #else
  331. typedef struct tagSQLGUID
  332. {
  333. unsigned int Data1;
  334. unsigned short Data2;
  335. unsigned short Data3;
  336. unsigned char Data4[8]; /* BYTE */
  337. }
  338. SQLGUID;
  339. #endif /* GUID_DEFINED */
  340. #endif /* ODBCVER >= 0x0350 */
  341. #if defined(WIN32)
  342. typedef unsigned short SQLWCHAR;
  343. #else
  344. # include <stdlib.h>
  345. # if defined(__cplusplus) || \
  346. defined(_WCHAR_T) || \
  347. defined(_WCHAR_T_DEFINED) || \
  348. defined(_WCHAR_T_DEFINED_) || \
  349. defined(_WCHAR_T_DECLARED) || \
  350. defined(_BSD_WCHAR_T_DEFINED_) || \
  351. defined(_BSD_WCHAR_T_) || \
  352. defined(_BSD_CT_RUNE_T_)
  353. typedef wchar_t SQLWCHAR;
  354. # else
  355. # error Please make sure your system supports the wchar_t type
  356. # endif
  357. #endif /* WIN32 */
  358. #ifdef UNICODE
  359. typedef SQLWCHAR SQLTCHAR;
  360. #else
  361. typedef SQLCHAR SQLTCHAR;
  362. #endif /* UNICODE */
  363. #ifdef __cplusplus
  364. }
  365. #endif
  366. #endif /* _SQLTYPES_H */