1 /***********************************************************************\
2 *                               sqltypes.d                              *
3 *                                                                       *
4 *                       Windows API header module                       *
5 *                                                                       *
6 *                 Translated from MinGW Windows headers                 *
7 *                                                                       *
8 *                       Placed into public domain                       *
9 \***********************************************************************/
10 module win32.sqltypes;
11 version(Windows):
12 
13 /* Conversion notes:
14   It's assumed that ODBC >= 0x0300.
15 */
16 
17 private import win32.windef;
18 private import win32.basetyps; // for GUID
19 
20 alias byte SCHAR, SQLSCHAR;
21 alias int SDWORD, SLONG, SQLINTEGER;
22 alias short SWORD, SSHORT, RETCODE, SQLSMALLINT;
23 alias ULONG UDWORD;
24 alias USHORT UWORD, SQLUSMALLINT;
25 alias double SDOUBLE, LDOUBLE;
26 alias float SFLOAT;
27 alias PVOID PTR, HENV, HDBC, HSTMT, SQLPOINTER;
28 alias UCHAR SQLCHAR;
29 // #ifndef _WIN64
30 alias UDWORD SQLUINTEGER;
31 // #endif
32 
33 //static if (ODBCVER >= 0x0300) {
34 alias TypeDef!(HANDLE) SQLHANDLE;
35 alias SQLHANDLE SQLHENV, SQLHDBC, SQLHSTMT, SQLHDESC;
36 /*
37 } else {
38 alias void* SQLHENV;
39 alias void* SQLHDBC;
40 alias void* SQLHSTMT;
41 }
42 */
43 alias SQLSMALLINT SQLRETURN;
44 alias HWND SQLHWND;
45 alias ULONG BOOKMARK;
46 
47 alias SQLINTEGER SQLLEN, SQLROWOFFSET;
48 alias SQLUINTEGER SQLROWCOUNT, SQLULEN;
49 alias DWORD SQLTRANSID;
50 alias SQLUSMALLINT SQLSETPOSIROW;
51 alias wchar SQLWCHAR;
52 
53 version(Unicode) {
54 	alias SQLWCHAR SQLTCHAR;
55 } else {
56 	alias SQLCHAR  SQLTCHAR;
57 }
58 //static if (ODBCVER >= 0x0300) {
59 alias ubyte  SQLDATE, SQLDECIMAL;
60 alias double SQLDOUBLE, SQLFLOAT;
61 alias ubyte  SQLNUMERIC;
62 alias float  SQLREAL;
63 alias ubyte  SQLTIME, SQLTIMESTAMP, SQLVARCHAR;
64 alias long   ODBCINT64, SQLBIGINT;
65 alias ulong  SQLUBIGINT;
66 //}
67 
68 struct DATE_STRUCT {
69 	SQLSMALLINT year;
70 	SQLUSMALLINT month;
71 	SQLUSMALLINT day;
72 }
73 
74 struct TIME_STRUCT {
75 	SQLUSMALLINT hour;
76 	SQLUSMALLINT minute;
77 	SQLUSMALLINT second;
78 }
79 
80 struct TIMESTAMP_STRUCT {
81 	SQLSMALLINT year;
82 	SQLUSMALLINT month;
83 	SQLUSMALLINT day;
84 	SQLUSMALLINT hour;
85 	SQLUSMALLINT minute;
86 	SQLUSMALLINT second;
87 	SQLUINTEGER fraction;
88 }
89 
90 //static if (ODBCVER >= 0x0300) {
91 alias DATE_STRUCT SQL_DATE_STRUCT;
92 alias TIME_STRUCT SQL_TIME_STRUCT;
93 alias TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT;
94 
95 enum SQLINTERVAL {
96 	SQL_IS_YEAR = 1,
97 	SQL_IS_MONTH,
98 	SQL_IS_DAY,
99 	SQL_IS_HOUR,
100 	SQL_IS_MINUTE,
101 	SQL_IS_SECOND,
102 	SQL_IS_YEAR_TO_MONTH,
103 	SQL_IS_DAY_TO_HOUR,
104 	SQL_IS_DAY_TO_MINUTE,
105 	SQL_IS_DAY_TO_SECOND,
106 	SQL_IS_HOUR_TO_MINUTE,
107 	SQL_IS_HOUR_TO_SECOND,
108 	SQL_IS_MINUTE_TO_SECOND
109 }
110 
111 struct SQL_YEAR_MONTH_STRUCT {
112 	SQLUINTEGER year;
113 	SQLUINTEGER month;
114 }
115 
116 struct SQL_DAY_SECOND_STRUCT {
117 	SQLUINTEGER day;
118 	SQLUINTEGER hour;
119 	SQLUINTEGER minute;
120 	SQLUINTEGER second;
121 	SQLUINTEGER fraction;
122 }
123 
124 struct SQL_INTERVAL_STRUCT {
125 	SQLINTERVAL interval_type;
126 	SQLSMALLINT interval_sign;
127 	union _intval {
128 		SQL_YEAR_MONTH_STRUCT year_month;
129 		SQL_DAY_SECOND_STRUCT day_second;
130 	}
131 	_intval intval;
132 }
133 
134 const SQL_MAX_NUMERIC_LEN = 16;
135 
136 struct SQL_NUMERIC_STRUCT {
137 	SQLCHAR precision;
138 	SQLSCHAR scale;
139 	SQLCHAR sign;
140 	SQLCHAR[SQL_MAX_NUMERIC_LEN] val;
141 }
142 // } ODBCVER >= 0x0300
143 alias GUID SQLGUID;