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