1 /** 2 Declarations for interfacing with the ODBC library. 3 4 Adapted with minimal changes from the work of David L. Davis 5 (refer to the $(HTTP 6 forum.dlang.org/post/cfk7ql$(DOLLAR)1p4n$(DOLLAR)1@digitaldaemon.com, 7 original announcement)). 8 9 `odbc.sqlucode` corresponds to the `sqlucode.h` C include file. 10 11 See_Also: $(LINK2 https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/odbc-api-reference, 12 ODBC API Reference on MSN Online) 13 */ 14 15 /+ 16 sqlucode.d - This is the the unicode include for ODBC v3.0+ Core functions. 17 18 +/ 19 20 module odbc.sqlucode; 21 22 import odbc.sqlext; 23 import odbc.sqltypes; 24 25 extern (Windows): 26 27 enum 28 { 29 SQL_WCHAR = (-8), 30 SQL_WVARCHAR = (-9), 31 SQL_WLONGVARCHAR = (-10), 32 SQL_C_WCHAR = SQL_WCHAR, 33 SQL_C_TCHAR = SQL_C_WCHAR 34 } 35 36 enum int SQL_SQLSTATE_SIZEW = 10; /* size of SQLSTATE for unicode */ 37 38 // UNICODE versions 39 40 SQLRETURN SQLColAttributeW 41 ( 42 SQLHSTMT hstmt, 43 SQLUSMALLINT iCol, 44 SQLUSMALLINT iField, 45 SQLPOINTER pCharAttr, 46 SQLSMALLINT cbCharAttrMax, 47 SQLSMALLINT *pcbCharAttr, 48 SQLPOINTER pNumAttr 49 ); 50 51 SQLRETURN SQLColAttributesW 52 ( 53 SQLHSTMT hstmt, 54 SQLUSMALLINT icol, 55 SQLUSMALLINT fDescType, 56 SQLPOINTER rgbDesc, 57 SQLSMALLINT cbDescMax, 58 SQLSMALLINT *pcbDesc, 59 SQLINTEGER *pfDesc 60 ); 61 62 SQLRETURN SQLConnectW 63 ( 64 SQLHDBC hdbc, 65 SQLWCHAR *szDSN, 66 SQLSMALLINT cbDSN, 67 SQLWCHAR *szUID, 68 SQLSMALLINT cbUID, 69 SQLWCHAR *szAuthStr, 70 SQLSMALLINT cbAuthStr 71 ); 72 73 SQLRETURN SQLDescribeColW 74 ( 75 SQLHSTMT hstmt, 76 SQLUSMALLINT icol, 77 SQLWCHAR *szColName, 78 SQLSMALLINT cbColNameMax, 79 SQLSMALLINT *pcbColName, 80 SQLSMALLINT *pfSqlType, 81 SQLUINTEGER *pcbColDef, 82 SQLSMALLINT *pibScale, 83 SQLSMALLINT *pfNullable 84 ); 85 86 SQLRETURN SQLErrorW 87 ( 88 SQLHENV henv, 89 SQLHDBC hdbc, 90 SQLHSTMT hstmt, 91 SQLWCHAR *szSqlState, 92 SQLINTEGER *pfNativeError, 93 SQLWCHAR *szErrorMsg, 94 SQLSMALLINT cbErrorMsgMax, 95 SQLSMALLINT *pcbErrorMsg 96 ); 97 98 SQLRETURN SQLExecDirectW 99 ( 100 SQLHSTMT hstmt, 101 SQLWCHAR *szSqlStr, 102 SQLINTEGER cbSqlStr 103 ); 104 105 SQLRETURN SQLGetConnectAttrW 106 ( 107 SQLHDBC hdbc, 108 SQLINTEGER fAttribute, 109 SQLPOINTER rgbValue, 110 SQLINTEGER cbValueMax, 111 SQLINTEGER *pcbValue 112 ); 113 114 SQLRETURN SQLGetCursorNameW 115 ( 116 SQLHSTMT hstmt, 117 SQLWCHAR *szCursor, 118 SQLSMALLINT cbCursorMax, 119 SQLSMALLINT *pcbCursor 120 ); 121 122 SQLRETURN SQLSetDescFieldW 123 ( 124 SQLHDESC DescriptorHandle, 125 SQLSMALLINT RecNumber, 126 SQLSMALLINT FieldIdentifier, 127 SQLPOINTER Value, 128 SQLINTEGER BufferLength 129 ); 130 131 SQLRETURN SQLGetDescFieldW 132 ( 133 SQLHDESC hdesc, 134 SQLSMALLINT iRecord, 135 SQLSMALLINT iField, 136 SQLPOINTER rgbValue, 137 SQLINTEGER cbValueMax, 138 SQLINTEGER *pcbValue 139 ); 140 141 SQLRETURN SQLGetDescRecW 142 ( 143 SQLHDESC hdesc, 144 SQLSMALLINT iRecord, 145 SQLWCHAR *szName, 146 SQLSMALLINT cbNameMax, 147 SQLSMALLINT *pcbName, 148 SQLSMALLINT *pfType, 149 SQLSMALLINT *pfSubType, 150 SQLINTEGER *pLength, 151 SQLSMALLINT *pPrecision, 152 SQLSMALLINT *pScale, 153 SQLSMALLINT *pNullable 154 ); 155 156 SQLRETURN SQLGetDiagFieldW 157 ( 158 SQLSMALLINT fHandleType, 159 SQLHANDLE handle, 160 SQLSMALLINT iRecord, 161 SQLSMALLINT fDiagField, 162 SQLPOINTER rgbDiagInfo, 163 SQLSMALLINT cbDiagInfoMax, 164 SQLSMALLINT *pcbDiagInfo 165 ); 166 167 SQLRETURN SQLGetDiagRecW 168 ( 169 SQLSMALLINT fHandleType, 170 SQLHANDLE handle, 171 SQLSMALLINT iRecord, 172 SQLWCHAR *szSqlState, 173 SQLINTEGER *pfNativeError, 174 SQLWCHAR *szErrorMsg, 175 SQLSMALLINT cbErrorMsgMax, 176 SQLSMALLINT *pcbErrorMsg 177 ); 178 179 SQLRETURN SQLPrepareW 180 ( 181 SQLHSTMT hstmt, 182 SQLWCHAR *szSqlStr, 183 SQLINTEGER cbSqlStr 184 ); 185 186 SQLRETURN SQLSetConnectAttrW 187 ( 188 SQLHDBC hdbc, 189 SQLINTEGER fAttribute, 190 SQLPOINTER rgbValue, 191 SQLINTEGER cbValue 192 ); 193 194 SQLRETURN SQLSetCursorNameW 195 ( 196 SQLHSTMT hstmt, 197 SQLWCHAR *szCursor, 198 SQLSMALLINT cbCursor 199 ); 200 201 SQLRETURN SQLColumnsW 202 ( 203 SQLHSTMT hstmt, 204 SQLWCHAR *szCatalogName, 205 SQLSMALLINT cbCatalogName, 206 SQLWCHAR *szSchemaName, 207 SQLSMALLINT cbSchemaName, 208 SQLWCHAR *szTableName, 209 SQLSMALLINT cbTableName, 210 SQLWCHAR *szColumnName, 211 SQLSMALLINT cbColumnName 212 ); 213 214 SQLRETURN SQLGetConnectOptionW 215 ( 216 SQLHDBC hdbc, 217 SQLUSMALLINT fOption, 218 SQLPOINTER pvParam 219 ); 220 221 SQLRETURN SQLGetInfoW 222 ( 223 SQLHDBC hdbc, 224 SQLUSMALLINT fInfoType, 225 SQLPOINTER rgbInfoValue, 226 SQLSMALLINT cbInfoValueMax, 227 SQLSMALLINT *pcbInfoValue 228 ); 229 230 SQLRETURN SQLGetTypeInfoW 231 ( 232 SQLHSTMT StatementHandle, 233 SQLSMALLINT DataType 234 ); 235 236 237 SQLRETURN SQLSetConnectOptionW 238 ( 239 SQLHDBC hdbc, 240 SQLUSMALLINT fOption, 241 SQLUINTEGER vParam 242 ); 243 244 SQLRETURN SQLSpecialColumnsW 245 ( 246 SQLHSTMT hstmt, 247 SQLUSMALLINT fColType, 248 SQLWCHAR *szCatalogName, 249 SQLSMALLINT cbCatalogName, 250 SQLWCHAR *szSchemaName, 251 SQLSMALLINT cbSchemaName, 252 SQLWCHAR *szTableName, 253 SQLSMALLINT cbTableName, 254 SQLUSMALLINT fScope, 255 SQLUSMALLINT fNullable 256 ); 257 258 SQLRETURN SQLStatisticsW 259 ( 260 SQLHSTMT hstmt, 261 SQLWCHAR *szCatalogName, 262 SQLSMALLINT cbCatalogName, 263 SQLWCHAR *szSchemaName, 264 SQLSMALLINT cbSchemaName, 265 SQLWCHAR *szTableName, 266 SQLSMALLINT cbTableName, 267 SQLUSMALLINT fUnique, 268 SQLUSMALLINT fAccuracy 269 ); 270 271 SQLRETURN SQLTablesW 272 ( 273 SQLHSTMT hstmt, 274 SQLWCHAR *szCatalogName, 275 SQLSMALLINT cbCatalogName, 276 SQLWCHAR *szSchemaName, 277 SQLSMALLINT cbSchemaName, 278 SQLWCHAR *szTableName, 279 SQLSMALLINT cbTableName, 280 SQLWCHAR *szTableType, 281 SQLSMALLINT cbTableType 282 ); 283 284 SQLRETURN SQLDataSourcesW 285 ( 286 SQLHENV henv, 287 SQLUSMALLINT fDirection, 288 SQLWCHAR *szDSN, 289 SQLSMALLINT cbDSNMax, 290 SQLSMALLINT *pcbDSN, 291 SQLWCHAR *szDescription, 292 SQLSMALLINT cbDescriptionMax, 293 SQLSMALLINT *pcbDescription 294 ); 295 296 SQLRETURN SQLDriverConnectW 297 ( 298 SQLHDBC hdbc, 299 SQLHWND hwnd, 300 SQLWCHAR *szConnStrIn, 301 SQLSMALLINT cbConnStrIn, 302 SQLWCHAR *szConnStrOut, 303 SQLSMALLINT cbConnStrOutMax, 304 SQLSMALLINT *pcbConnStrOut, 305 SQLUSMALLINT fDriverCompletion 306 ); 307 308 SQLRETURN SQLBrowseConnectW 309 ( 310 SQLHDBC hdbc, 311 SQLWCHAR *szConnStrIn, 312 SQLSMALLINT cbConnStrIn, 313 SQLWCHAR *szConnStrOut, 314 SQLSMALLINT cbConnStrOutMax, 315 SQLSMALLINT *pcbConnStrOut 316 ); 317 318 SQLRETURN SQLColumnPrivilegesW 319 ( 320 SQLHSTMT hstmt, 321 SQLWCHAR *szCatalogName, 322 SQLSMALLINT cbCatalogName, 323 SQLWCHAR *szSchemaName, 324 SQLSMALLINT cbSchemaName, 325 SQLWCHAR *szTableName, 326 SQLSMALLINT cbTableName, 327 SQLWCHAR *szColumnName, 328 SQLSMALLINT cbColumnName 329 ); 330 331 SQLRETURN SQLGetStmtAttrW 332 ( 333 SQLHSTMT hstmt, 334 SQLINTEGER fAttribute, 335 SQLPOINTER rgbValue, 336 SQLINTEGER cbValueMax, 337 SQLINTEGER *pcbValue 338 ); 339 340 SQLRETURN SQLSetStmtAttrW 341 ( 342 SQLHSTMT hstmt, 343 SQLINTEGER fAttribute, 344 SQLPOINTER rgbValue, 345 SQLINTEGER cbValueMax 346 ); 347 348 SQLRETURN SQLForeignKeysW 349 ( 350 SQLHSTMT hstmt, 351 SQLWCHAR *szPkCatalogName, 352 SQLSMALLINT cbPkCatalogName, 353 SQLWCHAR *szPkSchemaName, 354 SQLSMALLINT cbPkSchemaName, 355 SQLWCHAR *szPkTableName, 356 SQLSMALLINT cbPkTableName, 357 SQLWCHAR *szFkCatalogName, 358 SQLSMALLINT cbFkCatalogName, 359 SQLWCHAR *szFkSchemaName, 360 SQLSMALLINT cbFkSchemaName, 361 SQLWCHAR *szFkTableName, 362 SQLSMALLINT cbFkTableName 363 ); 364 365 SQLRETURN SQLNativeSqlW 366 ( 367 SQLHDBC hdbc, 368 SQLWCHAR *szSqlStrIn, 369 SQLINTEGER cbSqlStrIn, 370 SQLWCHAR *szSqlStr, 371 SQLINTEGER cbSqlStrMax, 372 SQLINTEGER *pcbSqlStr 373 ); 374 375 SQLRETURN SQLPrimaryKeysW 376 ( 377 SQLHSTMT hstmt, 378 SQLWCHAR *szCatalogName, 379 SQLSMALLINT cbCatalogName, 380 SQLWCHAR *szSchemaName, 381 SQLSMALLINT cbSchemaName, 382 SQLWCHAR *szTableName, 383 SQLSMALLINT cbTableName 384 ); 385 386 SQLRETURN SQLProcedureColumnsW 387 ( 388 SQLHSTMT hstmt, 389 SQLWCHAR *szCatalogName, 390 SQLSMALLINT cbCatalogName, 391 SQLWCHAR *szSchemaName, 392 SQLSMALLINT cbSchemaName, 393 SQLWCHAR *szProcName, 394 SQLSMALLINT cbProcName, 395 SQLWCHAR *szColumnName, 396 SQLSMALLINT cbColumnName 397 ); 398 399 SQLRETURN SQLProceduresW 400 ( 401 SQLHSTMT hstmt, 402 SQLWCHAR *szCatalogName, 403 SQLSMALLINT cbCatalogName, 404 SQLWCHAR *szSchemaName, 405 SQLSMALLINT cbSchemaName, 406 SQLWCHAR *szProcName, 407 SQLSMALLINT cbProcName 408 ); 409 410 SQLRETURN SQLTablePrivilegesW 411 ( 412 SQLHSTMT hstmt, 413 SQLWCHAR *szCatalogName, 414 SQLSMALLINT cbCatalogName, 415 SQLWCHAR *szSchemaName, 416 SQLSMALLINT cbSchemaName, 417 SQLWCHAR *szTableName, 418 SQLSMALLINT cbTableName 419 ); 420 421 SQLRETURN SQLDriversW 422 ( 423 SQLHENV henv, 424 SQLUSMALLINT fDirection, 425 SQLWCHAR *szDriverDesc, 426 SQLSMALLINT cbDriverDescMax, 427 SQLSMALLINT *pcbDriverDesc, 428 SQLWCHAR *szDriverAttributes, 429 SQLSMALLINT cbDrvrAttrMax, 430 SQLSMALLINT *pcbDrvrAttr 431 ); 432 433 //--------------------------------------------- 434 // Mapping Unicode Functions 435 //--------------------------------------------- 436 /+ 437 alias SQLColAttributeW SQLColAttribute; 438 alias SQLColAttributesW SQLColAttributes; 439 alias SQLConnectW SQLConnect; 440 alias SQLDescribeColW SQLDescribeCol; 441 alias SQLErrorW SQLError; 442 alias SQLExecDirectW SQLExecDirect; 443 alias SQLGetConnectAttrW SQLGetConnectAttr; 444 alias SQLGetCursorNameW SQLGetCursorName; 445 alias SQLGetDescFieldW SQLGetDescField; 446 alias SQLGetDescRecW SQLGetDescRec; 447 alias SQLGetDiagFieldW SQLGetDiagField; 448 alias SQLGetDiagRecW SQLGetDiagRec; 449 alias SQLPrepareW SQLPrepare; 450 alias SQLSetConnectAttrW SQLSetConnectAttr; 451 alias SQLSetCursorNameW SQLSetCursorName; 452 alias SQLSetDescFieldW SQLSetDescField; 453 alias SQLSetStmtAttrW SQLSetStmtAttr; 454 alias SQLColumnsW SQLColumns; 455 alias SQLGetConnectOptionW SQLGetConnectOption; 456 alias SQLGetInfoW SQLGetInfo; 457 alias SQLGetTypeInfoW SQLGetTypeInfo; 458 alias SQLSetConnectOptionW SQLSetConnectOption; 459 alias SQLSpecialColumnsW SQLSpecialColumns; 460 alias SQLStatisticsW SQLStatistics; 461 alias SQLTablesW SQLTables; 462 alias SQLDataSourcesW SQLDataSources; 463 alias SQLDriverConnectW SQLDriverConnect; 464 alias SQLBrowseConnectW SQLBrowseConnect; 465 alias SQLColumnPrivilegesW SQLColumnPrivileges; 466 alias SQLForeignKeysW SQLForeignKeys; 467 alias SQLNativeSqlW SQLNativeSql; 468 alias SQLPrimaryKeysW SQLPrimaryKeys; 469 alias SQLProcedureColumnsW SQLProcedureColumns; 470 alias SQLProceduresW SQLProcedures; 471 alias SQLTablePrivilegesW SQLTablePrivileges; 472 alias SQLDriversW SQLDrivers; 473 +/