4 * Copyright 1999 Xiang Li, Corel Corporation
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 * Proxy ODBC driver manager. This manager delegates all ODBC
22 * calls to a real ODBC driver manager named by the environment
23 * variable LIB_ODBC_DRIVER_MANAGER, or to libodbc.so if the
24 * variable is not set.
29 #include "wine/port.h"
40 #include "wine/debug.h"
41 #include "wine/library.h"
42 #include "wine/unicode.h"
48 static BOOL ODBC_LoadDriverManager(void);
49 static BOOL ODBC_LoadDMFunctions(void);
51 WINE_DEFAULT_DEBUG_CHANNEL(odbc);
53 static SQLRETURN (*pSQLAllocConnect)(SQLHENV,SQLHDBC*);
54 static SQLRETURN (*pSQLAllocEnv)(SQLHENV*);
55 static SQLRETURN (*pSQLAllocHandle)(SQLSMALLINT,SQLHANDLE,SQLHANDLE*);
56 static SQLRETURN (*pSQLAllocHandleStd)(SQLSMALLINT,SQLHANDLE,SQLHANDLE*);
57 static SQLRETURN (*pSQLAllocStmt)(SQLHDBC,SQLHSTMT*);
58 static SQLRETURN (*pSQLBindCol)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
59 static SQLRETURN (*pSQLBindParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLUINTEGER,SQLSMALLINT,SQLPOINTER,SQLINTEGER*);
60 static SQLRETURN (*pSQLBindParameter)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLUINTEGER,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
61 static SQLRETURN (*pSQLBrowseConnect)(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
62 static SQLRETURN (*pSQLBrowseConnectW)(SQLHDBC,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
63 static SQLRETURN (*pSQLBulkOperations)(SQLHSTMT,SQLSMALLINT);
64 static SQLRETURN (*pSQLCancel)(SQLHSTMT);
65 static SQLRETURN (*pSQLCloseCursor)(SQLHSTMT);
66 static SQLRETURN (*pSQLColAttribute)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER);
67 static SQLRETURN (*pSQLColAttributeW)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER);
68 static SQLRETURN (*pSQLColAttributes)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLINTEGER*);
69 static SQLRETURN (*pSQLColAttributesW)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLPOINTER);
70 static SQLRETURN (*pSQLColumnPrivileges)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
71 static SQLRETURN (*pSQLColumnPrivilegesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
72 static SQLRETURN (*pSQLColumns)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
73 static SQLRETURN (*pSQLColumnsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
74 static SQLRETURN (*pSQLConnect)(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
75 static SQLRETURN (*pSQLConnectW)(SQLHDBC,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
76 static SQLRETURN (*pSQLCopyDesc)(SQLHDESC,SQLHDESC);
77 static SQLRETURN (*pSQLDataSources)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
78 static SQLRETURN (*pSQLDataSourcesA)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
79 static SQLRETURN (*pSQLDataSourcesW)(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
80 static SQLRETURN (*pSQLDescribeCol)(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLUINTEGER*,SQLSMALLINT*,SQLSMALLINT*);
81 static SQLRETURN (*pSQLDescribeColW)(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*);
82 static SQLRETURN (*pSQLDescribeParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT*,SQLUINTEGER*,SQLSMALLINT*,SQLSMALLINT*);
83 static SQLRETURN (*pSQLDisconnect)(SQLHDBC);
84 static SQLRETURN (*pSQLDriverConnect)(SQLHDBC,SQLHWND,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT);
85 static SQLRETURN (*pSQLDriverConnectW)(SQLHDBC,SQLHWND,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT);
86 static SQLRETURN (*pSQLDrivers)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
87 static SQLRETURN (*pSQLDriversW)(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
88 static SQLRETURN (*pSQLEndTran)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT);
89 static SQLRETURN (*pSQLError)(SQLHENV,SQLHDBC,SQLHSTMT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
90 static SQLRETURN (*pSQLErrorW)(SQLHENV,SQLHDBC,SQLHSTMT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
91 static SQLRETURN (*pSQLExecDirect)(SQLHSTMT,SQLCHAR*,SQLINTEGER);
92 static SQLRETURN (*pSQLExecDirectW)(SQLHSTMT,SQLWCHAR*,SQLINTEGER);
93 static SQLRETURN (*pSQLExecute)(SQLHSTMT);
94 static SQLRETURN (*pSQLExtendedFetch)(SQLHSTMT,SQLUSMALLINT,SQLINTEGER,SQLUINTEGER*,SQLUSMALLINT*);
95 static SQLRETURN (*pSQLFetch)(SQLHSTMT);
96 static SQLRETURN (*pSQLFetchScroll)(SQLHSTMT,SQLSMALLINT,SQLINTEGER);
97 static SQLRETURN (*pSQLForeignKeys)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
98 static SQLRETURN (*pSQLForeignKeysW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
99 static SQLRETURN (*pSQLFreeConnect)(SQLHDBC);
100 static SQLRETURN (*pSQLFreeEnv)(SQLHENV);
101 static SQLRETURN (*pSQLFreeHandle)(SQLSMALLINT,SQLHANDLE);
102 static SQLRETURN (*pSQLFreeStmt)(SQLHSTMT,SQLUSMALLINT);
103 static SQLRETURN (*pSQLGetConnectAttr)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
104 static SQLRETURN (*pSQLGetConnectAttrW)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
105 static SQLRETURN (*pSQLGetConnectOption)(SQLHDBC,SQLUSMALLINT,SQLPOINTER);
106 static SQLRETURN (*pSQLGetConnectOptionW)(SQLHDBC,SQLUSMALLINT,SQLPOINTER);
107 static SQLRETURN (*pSQLGetCursorName)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
108 static SQLRETURN (*pSQLGetCursorNameW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
109 static SQLRETURN (*pSQLGetData)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
110 static SQLRETURN (*pSQLGetDescField)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
111 static SQLRETURN (*pSQLGetDescFieldW)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
112 static SQLRETURN (*pSQLGetDescRec)(SQLHDESC,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLINTEGER*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*);
113 static SQLRETURN (*pSQLGetDescRecW)(SQLHDESC,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLLEN*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*);
114 static SQLRETURN (*pSQLGetDiagField)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
115 static SQLRETURN (*pSQLGetDiagFieldW)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
116 static SQLRETURN (*pSQLGetDiagRec)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
117 static SQLRETURN (*pSQLGetDiagRecW)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
118 static SQLRETURN (*pSQLGetEnvAttr)(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
119 static SQLRETURN (*pSQLGetFunctions)(SQLHDBC,SQLUSMALLINT,SQLUSMALLINT*);
120 static SQLRETURN (*pSQLGetInfo)(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
121 static SQLRETURN (*pSQLGetInfoW)(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
122 static SQLRETURN (*pSQLGetStmtAttr)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
123 static SQLRETURN (*pSQLGetStmtAttrW)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
124 static SQLRETURN (*pSQLGetStmtOption)(SQLHSTMT,SQLUSMALLINT,SQLPOINTER);
125 static SQLRETURN (*pSQLGetTypeInfo)(SQLHSTMT,SQLSMALLINT);
126 static SQLRETURN (*pSQLGetTypeInfoW)(SQLHSTMT,SQLSMALLINT);
127 static SQLRETURN (*pSQLMoreResults)(SQLHSTMT);
128 static SQLRETURN (*pSQLNativeSql)(SQLHDBC,SQLCHAR*,SQLINTEGER,SQLCHAR*,SQLINTEGER,SQLINTEGER*);
129 static SQLRETURN (*pSQLNativeSqlW)(SQLHDBC,SQLWCHAR*,SQLINTEGER,SQLWCHAR*,SQLINTEGER,SQLINTEGER*);
130 static SQLRETURN (*pSQLNumParams)(SQLHSTMT,SQLSMALLINT*);
131 static SQLRETURN (*pSQLNumResultCols)(SQLHSTMT,SQLSMALLINT*);
132 static SQLRETURN (*pSQLParamData)(SQLHSTMT,SQLPOINTER*);
133 static SQLRETURN (*pSQLParamOptions)(SQLHSTMT,SQLUINTEGER,SQLUINTEGER*);
134 static SQLRETURN (*pSQLPrepare)(SQLHSTMT,SQLCHAR*,SQLINTEGER);
135 static SQLRETURN (*pSQLPrepareW)(SQLHSTMT,SQLWCHAR*,SQLINTEGER);
136 static SQLRETURN (*pSQLPrimaryKeys)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
137 static SQLRETURN (*pSQLPrimaryKeysW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
138 static SQLRETURN (*pSQLProcedureColumns)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
139 static SQLRETURN (*pSQLProcedureColumnsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
140 static SQLRETURN (*pSQLProcedures)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
141 static SQLRETURN (*pSQLProceduresW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
142 static SQLRETURN (*pSQLPutData)(SQLHSTMT,SQLPOINTER,SQLINTEGER);
143 static SQLRETURN (*pSQLRowCount)(SQLHSTMT,SQLINTEGER*);
144 static SQLRETURN (*pSQLSetConnectAttr)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER);
145 static SQLRETURN (*pSQLSetConnectAttrW)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER);
146 static SQLRETURN (*pSQLSetConnectOption)(SQLHDBC,SQLUSMALLINT,SQLUINTEGER);
147 static SQLRETURN (*pSQLSetConnectOptionW)(SQLHDBC,SQLUSMALLINT,SQLULEN);
148 static SQLRETURN (*pSQLSetCursorName)(SQLHSTMT,SQLCHAR*,SQLSMALLINT);
149 static SQLRETURN (*pSQLSetCursorNameW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT);
150 static SQLRETURN (*pSQLSetDescField)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER);
151 static SQLRETURN (*pSQLSetDescFieldW)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER);
152 static SQLRETURN (*pSQLSetDescRec)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLINTEGER,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER*,SQLINTEGER*);
153 static SQLRETURN (*pSQLSetEnvAttr)(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER);
154 static SQLRETURN (*pSQLSetParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLUINTEGER,SQLSMALLINT,SQLPOINTER,SQLINTEGER*);
155 static SQLRETURN (*pSQLSetPos)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
156 static SQLRETURN (*pSQLSetScrollOptions)(SQLHSTMT,SQLUSMALLINT,SQLINTEGER,SQLUSMALLINT);
157 static SQLRETURN (*pSQLSetStmtAttr)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER);
158 static SQLRETURN (*pSQLSetStmtAttrW)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER);
159 static SQLRETURN (*pSQLSetStmtOption)(SQLHSTMT,SQLUSMALLINT,SQLUINTEGER);
160 static SQLRETURN (*pSQLSpecialColumns)(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
161 static SQLRETURN (*pSQLSpecialColumnsW)(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
162 static SQLRETURN (*pSQLStatistics)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
163 static SQLRETURN (*pSQLStatisticsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
164 static SQLRETURN (*pSQLTablePrivileges)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
165 static SQLRETURN (*pSQLTablePrivilegesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
166 static SQLRETURN (*pSQLTables)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
167 static SQLRETURN (*pSQLTablesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
168 static SQLRETURN (*pSQLTransact)(SQLHENV,SQLHDBC,SQLUSMALLINT);
171 #define ERROR_SQLERROR 1
172 #define ERROR_LIBRARY_NOT_FOUND 2
174 static void *dmHandle;
175 static int nErrorType;
177 /***********************************************************************
178 * ODBC_ReplicateODBCInstToRegistry
184 * Utility to ODBC_ReplicateToRegistry to replicate the drivers of the
185 * ODBCINST.INI settings
187 * The driver settings are not replicated to the registry. If we were to
188 * replicate them we would need to decide whether to replicate all settings
189 * or to do some translation; whether to remove any entries present only in
190 * the windows registry, etc.
193 static void ODBC_ReplicateODBCInstToRegistry (SQLHENV hEnv)
200 TRACE ("Driver settings are not currently replicated to the registry\n");
201 if ((reg_ret = RegCreateKeyExA (HKEY_LOCAL_MACHINE,
202 "Software\\ODBC\\ODBCINST.INI", 0, NULL,
203 REG_OPTION_NON_VOLATILE,
204 KEY_ALL_ACCESS /* a couple more than we need */, NULL,
205 &hODBCInst, NULL)) == ERROR_SUCCESS)
208 if ((reg_ret = RegCreateKeyExA (hODBCInst, "ODBC Drivers", 0,
209 NULL, REG_OPTION_NON_VOLATILE,
210 KEY_ALL_ACCESS /* overkill */, NULL, &hDrivers, NULL))
216 SQLSMALLINT sizedesc;
219 dirn = SQL_FETCH_FIRST;
220 while ((sql_ret = SQLDrivers (hEnv, dirn, (SQLCHAR*)desc, sizeof(desc),
221 &sizedesc, NULL, 0, NULL)) == SQL_SUCCESS ||
222 sql_ret == SQL_SUCCESS_WITH_INFO)
224 /* FIXME Do some proper handling of the SUCCESS_WITH_INFO */
225 dirn = SQL_FETCH_NEXT;
226 if (sizedesc == lstrlenA(desc))
229 if ((reg_ret = RegQueryValueExA (hDrivers, desc, NULL,
230 NULL, NULL, NULL)) == ERROR_FILE_NOT_FOUND)
232 if ((reg_ret = RegSetValueExA (hDrivers, desc, 0,
233 REG_SZ, (const BYTE *)"Installed", 10)) != ERROR_SUCCESS)
235 TRACE ("Error %d replicating driver %s\n",
240 else if (reg_ret != ERROR_SUCCESS)
242 TRACE ("Error %d checking for %s in drivers\n",
246 if ((reg_ret = RegCreateKeyExA (hODBCInst, desc, 0,
247 NULL, REG_OPTION_NON_VOLATILE,
248 KEY_ALL_ACCESS, NULL, &hThis, NULL))
251 /* FIXME This is where the settings go.
252 * I suggest that if the disposition says it
253 * exists then we leave it alone. Alternatively
254 * include an extra value to flag that it is
255 * a replication of the unixODBC/iODBC/...
257 if ((reg_ret = RegCloseKey (hThis)) !=
259 TRACE ("Error %d closing %s key\n", reg_ret,
264 TRACE ("Error %d ensuring driver key %s\n",
271 WARN ("Unusually long driver name %s not replicated\n",
276 if (sql_ret != SQL_NO_DATA)
278 TRACE ("Error %d enumerating drivers\n", (int)sql_ret);
281 if ((reg_ret = RegCloseKey (hDrivers)) != ERROR_SUCCESS)
283 TRACE ("Error %d closing hDrivers\n", reg_ret);
288 TRACE ("Error %d opening HKLM\\S\\O\\OI\\Drivers\n", reg_ret);
290 if ((reg_ret = RegCloseKey (hODBCInst)) != ERROR_SUCCESS)
292 TRACE ("Error %d closing HKLM\\S\\O\\ODBCINST.INI\n", reg_ret);
297 TRACE ("Error %d opening HKLM\\S\\O\\ODBCINST.INI\n", reg_ret);
301 WARN ("May not have replicated all ODBC drivers to the registry\n");
305 /***********************************************************************
306 * ODBC_ReplicateODBCToRegistry
312 * Utility to ODBC_ReplicateToRegistry to replicate either the USER or
315 * For now simply place the "Driver description" (as returned by SQLDataSources)
316 * into the registry as the driver. This is enough to satisfy Crystal's
317 * requirement that there be a driver entry. (It doesn't seem to care what
319 * A slightly more accurate setting would be to access the registry to find
320 * the actual driver library for the given description (which appears to map
321 * to one of the HKLM/Software/ODBC/ODBCINST.INI keys). (If you do this note
322 * that this will add a requirement that this function be called after
323 * ODBC_ReplicateODBCInstToRegistry)
325 static void ODBC_ReplicateODBCToRegistry (int is_user, SQLHENV hEnv)
331 CHAR dsn [SQL_MAX_DSN_LENGTH + 1];
334 SQLSMALLINT sizedesc;
336 const char *which = is_user ? "user" : "system";
339 if ((reg_ret = RegCreateKeyExA (
340 is_user ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
341 "Software\\ODBC\\ODBC.INI", 0, NULL, REG_OPTION_NON_VOLATILE,
342 KEY_ALL_ACCESS /* a couple more than we need */, NULL, &hODBC,
343 NULL)) == ERROR_SUCCESS)
346 dirn = is_user ? SQL_FETCH_FIRST_USER : SQL_FETCH_FIRST_SYSTEM;
347 while ((sql_ret = SQLDataSources (hEnv, dirn,
348 (SQLCHAR*)dsn, sizeof(dsn), &sizedsn,
349 (SQLCHAR*)desc, sizeof(desc), &sizedesc)) == SQL_SUCCESS
350 || sql_ret == SQL_SUCCESS_WITH_INFO)
352 /* FIXME Do some proper handling of the SUCCESS_WITH_INFO */
353 dirn = SQL_FETCH_NEXT;
354 if (sizedsn == lstrlenA(dsn) && sizedesc == lstrlenA(desc))
357 if ((reg_ret = RegCreateKeyExA (hODBC, dsn, 0,
358 NULL, REG_OPTION_NON_VOLATILE,
359 KEY_ALL_ACCESS, NULL, &hDSN, NULL))
362 static const char DRIVERKEY[] = "Driver";
363 if ((reg_ret = RegQueryValueExA (hDSN, DRIVERKEY,
364 NULL, NULL, NULL, NULL))
365 == ERROR_FILE_NOT_FOUND)
367 if ((reg_ret = RegSetValueExA (hDSN, DRIVERKEY, 0,
368 REG_SZ, (LPBYTE)desc, sizedesc)) != ERROR_SUCCESS)
370 TRACE ("Error %d replicating description of "
371 "%s(%s)\n", reg_ret, dsn, desc);
375 else if (reg_ret != ERROR_SUCCESS)
377 TRACE ("Error %d checking for description of %s\n",
381 if ((reg_ret = RegCloseKey (hDSN)) != ERROR_SUCCESS)
383 TRACE ("Error %d closing %s DSN key %s\n",
384 reg_ret, which, dsn);
389 TRACE ("Error %d opening %s DSN key %s\n",
390 reg_ret, which, dsn);
396 WARN ("Unusually long %s data source name %s (%s) not "
397 "replicated\n", which, dsn, desc);
401 if (sql_ret != SQL_NO_DATA)
403 TRACE ("Error %d enumerating %s datasources\n",
404 (int)sql_ret, which);
407 if ((reg_ret = RegCloseKey (hODBC)) != ERROR_SUCCESS)
409 TRACE ("Error %d closing %s ODBC.INI registry key\n", reg_ret,
415 TRACE ("Error %d creating/opening %s ODBC.INI registry key\n",
420 WARN ("May not have replicated all %s ODBC DSNs to the registry\n",
425 /***********************************************************************
426 * ODBC_ReplicateToRegistry
432 * Unfortunately some of the functions that Windows documents as being part
433 * of the ODBC API it implements directly during compilation or something
434 * in terms of registry access functions.
435 * e.g. SQLGetInstalledDrivers queries the list at
436 * HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINST.INI\ODBC Drivers
438 * This function is called when the driver manager is loaded and is used
439 * to replicate the appropriate details into the Wine registry
442 static void ODBC_ReplicateToRegistry (void)
447 if ((sql_ret = SQLAllocEnv (&hEnv)) == SQL_SUCCESS)
449 ODBC_ReplicateODBCInstToRegistry (hEnv);
450 ODBC_ReplicateODBCToRegistry (0 /* system dsns */, hEnv);
451 ODBC_ReplicateODBCToRegistry (1 /* user dsns */, hEnv);
453 if ((sql_ret = SQLFreeEnv (hEnv)) != SQL_SUCCESS)
455 TRACE ("Error %d freeing the SQL environment.\n", (int)sql_ret);
460 TRACE ("Error %d opening an SQL environment.\n", (int)sql_ret);
461 WARN ("The external ODBC settings have not been replicated to the"
466 /***********************************************************************
467 * DllMain [Internal] Initializes the internal 'ODBC32.DLL'.
470 * hinstDLL [I] handle to the DLL's instance
472 * lpvReserved [I] reserved, must be NULL
479 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
481 TRACE("Initializing or Finalizing proxy ODBC: %p,%x,%p\n", hinstDLL, fdwReason, lpvReserved);
483 if (fdwReason == DLL_PROCESS_ATTACH)
485 TRACE("Loading ODBC...\n");
486 DisableThreadLibraryCalls(hinstDLL);
487 if (ODBC_LoadDriverManager())
489 ODBC_LoadDMFunctions();
490 ODBC_ReplicateToRegistry();
493 else if (fdwReason == DLL_PROCESS_DETACH)
495 TRACE("Unloading ODBC...\n");
498 wine_dlclose(dmHandle,NULL,0);
506 /***********************************************************************
507 * ODBC_LoadDriverManager [Internal] Load ODBC library.
516 static BOOL ODBC_LoadDriverManager(void)
518 const char *s = getenv("LIB_ODBC_DRIVER_MANAGER");
523 #ifdef SONAME_LIBODBC
524 if (!s || !s[0]) s = SONAME_LIBODBC;
526 if (!s || !s[0]) goto failed;
528 dmHandle = wine_dlopen(s, RTLD_LAZY | RTLD_GLOBAL, error, sizeof(error));
530 if (dmHandle != NULL)
532 nErrorType = ERROR_FREE;
536 WARN("failed to open library %s: %s\n", debugstr_a(s), error);
537 nErrorType = ERROR_LIBRARY_NOT_FOUND;
542 /***********************************************************************
543 * ODBC_LoadDMFunctions [Internal] Populate function table.
552 static BOOL ODBC_LoadDMFunctions(void)
556 if (dmHandle == NULL)
559 #define LOAD_FUNC(name) \
560 if ((p##name = wine_dlsym( dmHandle, #name, error, sizeof(error) ))); \
561 else WARN( "Failed to load %s: %s\n", #name, error )
563 LOAD_FUNC(SQLAllocConnect);
564 LOAD_FUNC(SQLAllocEnv);
565 LOAD_FUNC(SQLAllocHandle);
566 LOAD_FUNC(SQLAllocHandleStd);
567 LOAD_FUNC(SQLAllocStmt);
568 LOAD_FUNC(SQLBindCol);
569 LOAD_FUNC(SQLBindParam);
570 LOAD_FUNC(SQLBindParameter);
571 LOAD_FUNC(SQLBrowseConnect);
572 LOAD_FUNC(SQLBrowseConnectW);
573 LOAD_FUNC(SQLBulkOperations);
574 LOAD_FUNC(SQLCancel);
575 LOAD_FUNC(SQLCloseCursor);
576 LOAD_FUNC(SQLColAttribute);
577 LOAD_FUNC(SQLColAttributeW);
578 LOAD_FUNC(SQLColAttributes);
579 LOAD_FUNC(SQLColAttributesW);
580 LOAD_FUNC(SQLColumnPrivileges);
581 LOAD_FUNC(SQLColumnPrivilegesW);
582 LOAD_FUNC(SQLColumns);
583 LOAD_FUNC(SQLColumnsW);
584 LOAD_FUNC(SQLConnect);
585 LOAD_FUNC(SQLConnectW);
586 LOAD_FUNC(SQLCopyDesc);
587 LOAD_FUNC(SQLDataSources);
588 LOAD_FUNC(SQLDataSourcesA);
589 LOAD_FUNC(SQLDataSourcesW);
590 LOAD_FUNC(SQLDescribeCol);
591 LOAD_FUNC(SQLDescribeColW);
592 LOAD_FUNC(SQLDescribeParam);
593 LOAD_FUNC(SQLDisconnect);
594 LOAD_FUNC(SQLDriverConnect);
595 LOAD_FUNC(SQLDriverConnectW);
596 LOAD_FUNC(SQLDrivers);
597 LOAD_FUNC(SQLDriversW);
598 LOAD_FUNC(SQLEndTran);
600 LOAD_FUNC(SQLErrorW);
601 LOAD_FUNC(SQLExecDirect);
602 LOAD_FUNC(SQLExecDirectW);
603 LOAD_FUNC(SQLExecute);
604 LOAD_FUNC(SQLExtendedFetch);
606 LOAD_FUNC(SQLFetchScroll);
607 LOAD_FUNC(SQLForeignKeys);
608 LOAD_FUNC(SQLForeignKeysW);
609 LOAD_FUNC(SQLFreeConnect);
610 LOAD_FUNC(SQLFreeEnv);
611 LOAD_FUNC(SQLFreeHandle);
612 LOAD_FUNC(SQLFreeStmt);
613 LOAD_FUNC(SQLGetConnectAttr);
614 LOAD_FUNC(SQLGetConnectAttrW);
615 LOAD_FUNC(SQLGetConnectOption);
616 LOAD_FUNC(SQLGetConnectOptionW);
617 LOAD_FUNC(SQLGetCursorName);
618 LOAD_FUNC(SQLGetCursorNameW);
619 LOAD_FUNC(SQLGetData);
620 LOAD_FUNC(SQLGetDescField);
621 LOAD_FUNC(SQLGetDescFieldW);
622 LOAD_FUNC(SQLGetDescRec);
623 LOAD_FUNC(SQLGetDescRecW);
624 LOAD_FUNC(SQLGetDiagField);
625 LOAD_FUNC(SQLGetDiagFieldW);
626 LOAD_FUNC(SQLGetDiagRec);
627 LOAD_FUNC(SQLGetDiagRecW);
628 LOAD_FUNC(SQLGetEnvAttr);
629 LOAD_FUNC(SQLGetFunctions);
630 LOAD_FUNC(SQLGetInfo);
631 LOAD_FUNC(SQLGetInfoW);
632 LOAD_FUNC(SQLGetStmtAttr);
633 LOAD_FUNC(SQLGetStmtAttrW);
634 LOAD_FUNC(SQLGetStmtOption);
635 LOAD_FUNC(SQLGetTypeInfo);
636 LOAD_FUNC(SQLGetTypeInfoW);
637 LOAD_FUNC(SQLMoreResults);
638 LOAD_FUNC(SQLNativeSql);
639 LOAD_FUNC(SQLNativeSqlW);
640 LOAD_FUNC(SQLNumParams);
641 LOAD_FUNC(SQLNumResultCols);
642 LOAD_FUNC(SQLParamData);
643 LOAD_FUNC(SQLParamOptions);
644 LOAD_FUNC(SQLPrepare);
645 LOAD_FUNC(SQLPrepareW);
646 LOAD_FUNC(SQLPrimaryKeys);
647 LOAD_FUNC(SQLPrimaryKeysW);
648 LOAD_FUNC(SQLProcedureColumns);
649 LOAD_FUNC(SQLProcedureColumnsW);
650 LOAD_FUNC(SQLProcedures);
651 LOAD_FUNC(SQLProceduresW);
652 LOAD_FUNC(SQLPutData);
653 LOAD_FUNC(SQLRowCount);
654 LOAD_FUNC(SQLSetConnectAttr);
655 LOAD_FUNC(SQLSetConnectAttrW);
656 LOAD_FUNC(SQLSetConnectOption);
657 LOAD_FUNC(SQLSetConnectOptionW);
658 LOAD_FUNC(SQLSetCursorName);
659 LOAD_FUNC(SQLSetCursorNameW);
660 LOAD_FUNC(SQLSetDescField);
661 LOAD_FUNC(SQLSetDescFieldW);
662 LOAD_FUNC(SQLSetDescRec);
663 LOAD_FUNC(SQLSetEnvAttr);
664 LOAD_FUNC(SQLSetParam);
665 LOAD_FUNC(SQLSetPos);
666 LOAD_FUNC(SQLSetScrollOptions);
667 LOAD_FUNC(SQLSetStmtAttr);
668 LOAD_FUNC(SQLSetStmtAttrW);
669 LOAD_FUNC(SQLSetStmtOption);
670 LOAD_FUNC(SQLSpecialColumns);
671 LOAD_FUNC(SQLSpecialColumnsW);
672 LOAD_FUNC(SQLStatistics);
673 LOAD_FUNC(SQLStatisticsW);
674 LOAD_FUNC(SQLTablePrivileges);
675 LOAD_FUNC(SQLTablePrivilegesW);
676 LOAD_FUNC(SQLTables);
677 LOAD_FUNC(SQLTablesW);
678 LOAD_FUNC(SQLTransact);
685 /*************************************************************************
686 * SQLAllocConnect [ODBC32.001]
688 SQLRETURN WINAPI SQLAllocConnect(SQLHENV EnvironmentHandle, SQLHDBC *ConnectionHandle)
691 TRACE("Env=%p\n",EnvironmentHandle);
693 if (!pSQLAllocConnect)
695 *ConnectionHandle = SQL_NULL_HDBC;
696 TRACE("Not ready\n");
700 ret = pSQLAllocConnect(EnvironmentHandle, ConnectionHandle);
701 TRACE("Returns ret=%d, Handle %p\n",ret, *ConnectionHandle);
706 /*************************************************************************
707 * SQLAllocEnv [ODBC32.002]
709 SQLRETURN WINAPI SQLAllocEnv(SQLHENV *EnvironmentHandle)
716 *EnvironmentHandle = SQL_NULL_HENV;
717 TRACE("Not ready\n");
721 ret = pSQLAllocEnv(EnvironmentHandle);
722 TRACE("Returns ret=%d, Env=%p\n",ret, *EnvironmentHandle);
727 /*************************************************************************
728 * SQLAllocHandle [ODBC32.024]
730 SQLRETURN WINAPI SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, SQLHANDLE *OutputHandle)
733 TRACE("(Type=%d, Handle=%p)\n",HandleType,InputHandle);
735 if (!pSQLAllocHandle)
737 if (nErrorType == ERROR_LIBRARY_NOT_FOUND)
738 WARN("ProxyODBC: Cannot load ODBC driver manager library.\n");
740 if (HandleType == SQL_HANDLE_ENV)
741 *OutputHandle = SQL_NULL_HENV;
742 else if (HandleType == SQL_HANDLE_DBC)
743 *OutputHandle = SQL_NULL_HDBC;
744 else if (HandleType == SQL_HANDLE_STMT)
745 *OutputHandle = SQL_NULL_HSTMT;
746 else if (HandleType == SQL_HANDLE_DESC)
747 *OutputHandle = SQL_NULL_HDESC;
749 TRACE ("Not ready\n");
753 ret = pSQLAllocHandle(HandleType, InputHandle, OutputHandle);
754 TRACE("Returns ret=%d, Handle=%p\n",ret, *OutputHandle);
759 /*************************************************************************
760 * SQLAllocStmt [ODBC32.003]
762 SQLRETURN WINAPI SQLAllocStmt(SQLHDBC ConnectionHandle, SQLHSTMT *StatementHandle)
766 TRACE("(Connection=%p)\n",ConnectionHandle);
770 *StatementHandle = SQL_NULL_HSTMT;
771 TRACE ("Not ready\n");
775 ret = pSQLAllocStmt(ConnectionHandle, StatementHandle);
776 TRACE ("Returns ret=%d, Handle=%p\n", ret, *StatementHandle);
781 /*************************************************************************
782 * SQLAllocHandleStd [ODBC32.077]
784 SQLRETURN WINAPI SQLAllocHandleStd( SQLSMALLINT HandleType,
785 SQLHANDLE InputHandle, SQLHANDLE *OutputHandle)
787 TRACE("ProxyODBC: SQLAllocHandleStd.\n");
789 if (!pSQLAllocHandleStd)
791 if (nErrorType == ERROR_LIBRARY_NOT_FOUND)
792 WARN("ProxyODBC: Cannot load ODBC driver manager library.\n");
794 if (HandleType == SQL_HANDLE_ENV)
795 *OutputHandle = SQL_NULL_HENV;
796 else if (HandleType == SQL_HANDLE_DBC)
797 *OutputHandle = SQL_NULL_HDBC;
798 else if (HandleType == SQL_HANDLE_STMT)
799 *OutputHandle = SQL_NULL_HSTMT;
800 else if (HandleType == SQL_HANDLE_DESC)
801 *OutputHandle = SQL_NULL_HDESC;
806 return pSQLAllocHandleStd(HandleType, InputHandle, OutputHandle);
810 /*************************************************************************
811 * SQLBindCol [ODBC32.004]
813 SQLRETURN WINAPI SQLBindCol(SQLHSTMT StatementHandle,
814 SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
815 SQLPOINTER TargetValue, SQLINTEGER BufferLength,
816 SQLINTEGER *StrLen_or_Ind)
822 TRACE ("Not ready\n");
826 return pSQLBindCol(StatementHandle, ColumnNumber, TargetType,
827 TargetValue, BufferLength, StrLen_or_Ind);
831 /*************************************************************************
832 * SQLBindParam [ODBC32.025]
834 SQLRETURN WINAPI SQLBindParam(SQLHSTMT StatementHandle,
835 SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
836 SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision,
837 SQLSMALLINT ParameterScale, SQLPOINTER ParameterValue,
838 SQLINTEGER *StrLen_or_Ind)
842 if (!pSQLBindParam) return SQL_ERROR;
843 return pSQLBindParam(StatementHandle, ParameterNumber, ValueType,
844 ParameterType, LengthPrecision, ParameterScale,
845 ParameterValue, StrLen_or_Ind);
849 /*************************************************************************
850 * SQLCancel [ODBC32.005]
852 SQLRETURN WINAPI SQLCancel(SQLHSTMT StatementHandle)
856 if (!pSQLCancel) return SQL_ERROR;
857 return pSQLCancel(StatementHandle);
861 /*************************************************************************
862 * SQLCloseCursor [ODBC32.026]
864 SQLRETURN WINAPI SQLCloseCursor(SQLHSTMT StatementHandle)
867 TRACE("(Handle=%p)\n",StatementHandle);
869 if (!pSQLCloseCursor) return SQL_ERROR;
871 ret = pSQLCloseCursor(StatementHandle);
872 TRACE("returns %d\n",ret);
877 /*************************************************************************
878 * SQLColAttribute [ODBC32.027]
880 SQLRETURN WINAPI SQLColAttribute (SQLHSTMT StatementHandle,
881 SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
882 SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength,
883 SQLSMALLINT *StringLength, SQLPOINTER NumericAttribute)
887 if (!pSQLColAttribute) return SQL_ERROR;
888 return pSQLColAttribute(StatementHandle, ColumnNumber, FieldIdentifier,
889 CharacterAttribute, BufferLength, StringLength, NumericAttribute);
893 /*************************************************************************
894 * SQLColumns [ODBC32.040]
896 SQLRETURN WINAPI SQLColumns(SQLHSTMT StatementHandle,
897 SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
898 SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
899 SQLCHAR *TableName, SQLSMALLINT NameLength3,
900 SQLCHAR *ColumnName, SQLSMALLINT NameLength4)
904 if (!pSQLColumns) return SQL_ERROR;
905 return pSQLColumns(StatementHandle, CatalogName, NameLength1,
906 SchemaName, NameLength2, TableName, NameLength3, ColumnName, NameLength4);
910 /*************************************************************************
911 * SQLConnect [ODBC32.007]
913 SQLRETURN WINAPI SQLConnect(SQLHDBC ConnectionHandle,
914 SQLCHAR *ServerName, SQLSMALLINT NameLength1,
915 SQLCHAR *UserName, SQLSMALLINT NameLength2,
916 SQLCHAR *Authentication, SQLSMALLINT NameLength3)
919 TRACE("(Server=%.*s)\n",NameLength1, ServerName);
921 if (!pSQLConnect) return SQL_ERROR;
923 ret = pSQLConnect(ConnectionHandle, ServerName, NameLength1,
924 UserName, NameLength2, Authentication, NameLength3);
926 TRACE("returns %d\n",ret);
931 /*************************************************************************
932 * SQLCopyDesc [ODBC32.028]
934 SQLRETURN WINAPI SQLCopyDesc(SQLHDESC SourceDescHandle, SQLHDESC TargetDescHandle)
938 if (!pSQLCopyDesc) return SQL_ERROR;
939 return pSQLCopyDesc(SourceDescHandle, TargetDescHandle);
943 /*************************************************************************
944 * SQLDataSources [ODBC32.057]
946 SQLRETURN WINAPI SQLDataSources(SQLHENV EnvironmentHandle,
947 SQLUSMALLINT Direction, SQLCHAR *ServerName,
948 SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
949 SQLCHAR *Description, SQLSMALLINT BufferLength2,
950 SQLSMALLINT *NameLength2)
954 TRACE("EnvironmentHandle = %p\n", EnvironmentHandle);
956 if (!pSQLDataSources) return SQL_ERROR;
958 ret = pSQLDataSources(EnvironmentHandle, Direction, ServerName,
959 BufferLength1, NameLength1, Description, BufferLength2, NameLength2);
963 TRACE("returns: %d \t", ret);
964 if (NameLength1 && *NameLength1 > 0)
965 TRACE("DataSource = %s,", ServerName);
966 if (NameLength2 && *NameLength2 > 0)
967 TRACE(" Description = %s", Description);
974 SQLRETURN WINAPI SQLDataSourcesA(SQLHENV EnvironmentHandle,
975 SQLUSMALLINT Direction, SQLCHAR *ServerName,
976 SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
977 SQLCHAR *Description, SQLSMALLINT BufferLength2,
978 SQLSMALLINT *NameLength2)
982 TRACE("EnvironmentHandle = %p\n", EnvironmentHandle);
984 if (!pSQLDataSourcesA) return SQL_ERROR;
986 ret = pSQLDataSourcesA(EnvironmentHandle, Direction, ServerName,
987 BufferLength1, NameLength1, Description, BufferLength2, NameLength2);
990 TRACE("returns: %d \t", ret);
991 if (NameLength1 && *NameLength1 > 0)
992 TRACE("DataSource = %s,", ServerName);
993 if (NameLength2 && *NameLength2 > 0)
994 TRACE(" Description = %s", Description);
1001 /*************************************************************************
1002 * SQLDescribeCol [ODBC32.008]
1004 SQLRETURN WINAPI SQLDescribeCol(SQLHSTMT StatementHandle,
1005 SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName,
1006 SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
1007 SQLSMALLINT *DataType, SQLUINTEGER *ColumnSize,
1008 SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
1012 if (!pSQLDescribeCol) return SQL_ERROR;
1013 return pSQLDescribeCol(StatementHandle, ColumnNumber, ColumnName,
1014 BufferLength, NameLength, DataType, ColumnSize, DecimalDigits, Nullable);
1018 /*************************************************************************
1019 * SQLDisconnect [ODBC32.009]
1021 SQLRETURN WINAPI SQLDisconnect(SQLHDBC ConnectionHandle)
1024 TRACE("(Handle=%p)\n", ConnectionHandle);
1026 if (!pSQLDisconnect) return SQL_ERROR;
1028 ret = pSQLDisconnect(ConnectionHandle);
1029 TRACE("returns %d\n",ret);
1034 /*************************************************************************
1035 * SQLEndTran [ODBC32.029]
1037 SQLRETURN WINAPI SQLEndTran(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT CompletionType)
1041 if (!pSQLEndTran) return SQL_ERROR;
1042 return pSQLEndTran(HandleType, Handle, CompletionType);
1046 /*************************************************************************
1047 * SQLError [ODBC32.010]
1049 SQLRETURN WINAPI SQLError(SQLHENV EnvironmentHandle,
1050 SQLHDBC ConnectionHandle, SQLHSTMT StatementHandle,
1051 SQLCHAR *Sqlstate, SQLINTEGER *NativeError,
1052 SQLCHAR *MessageText, SQLSMALLINT BufferLength,
1053 SQLSMALLINT *TextLength)
1057 if (!pSQLError) return SQL_ERROR;
1058 return pSQLError(EnvironmentHandle, ConnectionHandle, StatementHandle,
1059 Sqlstate, NativeError, MessageText, BufferLength, TextLength);
1063 /*************************************************************************
1064 * SQLExecDirect [ODBC32.011]
1066 SQLRETURN WINAPI SQLExecDirect(SQLHSTMT StatementHandle, SQLCHAR *StatementText, SQLINTEGER TextLength)
1070 if (!pSQLExecDirect) return SQL_ERROR;
1071 return pSQLExecDirect(StatementHandle, StatementText, TextLength);
1075 /*************************************************************************
1076 * SQLExecute [ODBC32.012]
1078 SQLRETURN WINAPI SQLExecute(SQLHSTMT StatementHandle)
1082 if (!pSQLExecute) return SQL_ERROR;
1083 return pSQLExecute(StatementHandle);
1087 /*************************************************************************
1088 * SQLFetch [ODBC32.013]
1090 SQLRETURN WINAPI SQLFetch(SQLHSTMT StatementHandle)
1094 if (!pSQLFetch) return SQL_ERROR;
1095 return pSQLFetch(StatementHandle);
1099 /*************************************************************************
1100 * SQLFetchScroll [ODBC32.030]
1102 SQLRETURN WINAPI SQLFetchScroll(SQLHSTMT StatementHandle, SQLSMALLINT FetchOrientation, SQLINTEGER FetchOffset)
1106 if (!pSQLFetchScroll) return SQL_ERROR;
1107 return pSQLFetchScroll(StatementHandle, FetchOrientation, FetchOffset);
1111 /*************************************************************************
1112 * SQLFreeConnect [ODBC32.014]
1114 SQLRETURN WINAPI SQLFreeConnect(SQLHDBC ConnectionHandle)
1117 TRACE("(Handle=%p)\n",ConnectionHandle);
1119 if (!pSQLFreeConnect) return SQL_ERROR;
1121 ret = pSQLFreeConnect(ConnectionHandle);
1122 TRACE("Returns %d\n",ret);
1127 /*************************************************************************
1128 * SQLFreeEnv [ODBC32.015]
1130 SQLRETURN WINAPI SQLFreeEnv(SQLHENV EnvironmentHandle)
1133 TRACE("(Env=%p)\n",EnvironmentHandle);
1135 if (!pSQLFreeEnv) return SQL_ERROR;
1137 ret = pSQLFreeEnv(EnvironmentHandle);
1138 TRACE("Returns %d\n",ret);
1143 /*************************************************************************
1144 * SQLFreeHandle [ODBC32.031]
1146 SQLRETURN WINAPI SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle)
1149 TRACE("(Type=%d, Handle=%p)\n",HandleType,Handle);
1151 if (!pSQLFreeHandle) return SQL_ERROR;
1153 ret = pSQLFreeHandle(HandleType, Handle);
1154 TRACE ("Returns %d\n",ret);
1159 /*************************************************************************
1160 * SQLFreeStmt [ODBC32.016]
1162 SQLRETURN WINAPI SQLFreeStmt(SQLHSTMT StatementHandle, SQLUSMALLINT Option)
1165 TRACE("(Handle %p, Option=%d)\n",StatementHandle, Option);
1167 if (!pSQLFreeStmt) return SQL_ERROR;
1169 ret = pSQLFreeStmt(StatementHandle, Option);
1170 TRACE("Returns %d\n",ret);
1175 /*************************************************************************
1176 * SQLGetConnectAttr [ODBC32.032]
1178 SQLRETURN WINAPI SQLGetConnectAttr(SQLHDBC ConnectionHandle,
1179 SQLINTEGER Attribute, SQLPOINTER Value,
1180 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
1184 if (!pSQLGetConnectAttr) return SQL_ERROR;
1185 return pSQLGetConnectAttr(ConnectionHandle, Attribute, Value,
1186 BufferLength, StringLength);
1190 /*************************************************************************
1191 * SQLGetConnectOption [ODBC32.042]
1193 SQLRETURN WINAPI SQLGetConnectOption(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLPOINTER Value)
1197 if (!pSQLGetConnectOption) return SQL_ERROR;
1198 return pSQLGetConnectOption(ConnectionHandle, Option, Value);
1202 /*************************************************************************
1203 * SQLGetCursorName [ODBC32.017]
1205 SQLRETURN WINAPI SQLGetCursorName(SQLHSTMT StatementHandle,
1206 SQLCHAR *CursorName, SQLSMALLINT BufferLength,
1207 SQLSMALLINT *NameLength)
1211 if (!pSQLGetCursorName) return SQL_ERROR;
1212 return pSQLGetCursorName(StatementHandle, CursorName, BufferLength, NameLength);
1216 /*************************************************************************
1217 * SQLGetData [ODBC32.043]
1219 SQLRETURN WINAPI SQLGetData(SQLHSTMT StatementHandle,
1220 SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
1221 SQLPOINTER TargetValue, SQLINTEGER BufferLength,
1222 SQLINTEGER *StrLen_or_Ind)
1226 if (!pSQLGetData) return SQL_ERROR;
1227 return pSQLGetData(StatementHandle, ColumnNumber, TargetType,
1228 TargetValue, BufferLength, StrLen_or_Ind);
1232 /*************************************************************************
1233 * SQLGetDescField [ODBC32.033]
1235 SQLRETURN WINAPI SQLGetDescField(SQLHDESC DescriptorHandle,
1236 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
1237 SQLPOINTER Value, SQLINTEGER BufferLength,
1238 SQLINTEGER *StringLength)
1242 if (!pSQLGetDescField) return SQL_ERROR;
1243 return pSQLGetDescField(DescriptorHandle, RecNumber, FieldIdentifier,
1244 Value, BufferLength, StringLength);
1248 /*************************************************************************
1249 * SQLGetDescRec [ODBC32.034]
1251 SQLRETURN WINAPI SQLGetDescRec(SQLHDESC DescriptorHandle,
1252 SQLSMALLINT RecNumber, SQLCHAR *Name,
1253 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
1254 SQLSMALLINT *Type, SQLSMALLINT *SubType,
1255 SQLINTEGER *Length, SQLSMALLINT *Precision,
1256 SQLSMALLINT *Scale, SQLSMALLINT *Nullable)
1260 if (!pSQLGetDescRec) return SQL_ERROR;
1261 return pSQLGetDescRec(DescriptorHandle, RecNumber, Name, BufferLength,
1262 StringLength, Type, SubType, Length, Precision, Scale, Nullable);
1266 /*************************************************************************
1267 * SQLGetDiagField [ODBC32.035]
1269 SQLRETURN WINAPI SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle,
1270 SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier,
1271 SQLPOINTER DiagInfo, SQLSMALLINT BufferLength,
1272 SQLSMALLINT *StringLength)
1276 if (!pSQLGetDiagField) return SQL_ERROR;
1277 return pSQLGetDiagField(HandleType, Handle, RecNumber, DiagIdentifier,
1278 DiagInfo, BufferLength, StringLength);
1282 /*************************************************************************
1283 * SQLGetDiagRec [ODBC32.036]
1285 SQLRETURN WINAPI SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle,
1286 SQLSMALLINT RecNumber, SQLCHAR *Sqlstate,
1287 SQLINTEGER *NativeError, SQLCHAR *MessageText,
1288 SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
1292 if (!pSQLGetDiagRec) return SQL_ERROR;
1293 return pSQLGetDiagRec(HandleType, Handle, RecNumber, Sqlstate, NativeError,
1294 MessageText, BufferLength, TextLength);
1298 /*************************************************************************
1299 * SQLGetEnvAttr [ODBC32.037]
1301 SQLRETURN WINAPI SQLGetEnvAttr(SQLHENV EnvironmentHandle,
1302 SQLINTEGER Attribute, SQLPOINTER Value,
1303 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
1307 if (!pSQLGetEnvAttr) return SQL_ERROR;
1308 return pSQLGetEnvAttr(EnvironmentHandle, Attribute, Value, BufferLength, StringLength);
1312 /*************************************************************************
1313 * SQLGetFunctions [ODBC32.044]
1315 SQLRETURN WINAPI SQLGetFunctions(SQLHDBC ConnectionHandle, SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported)
1319 if (!pSQLGetFunctions) return SQL_ERROR;
1320 return pSQLGetFunctions(ConnectionHandle, FunctionId, Supported);
1324 /*************************************************************************
1325 * SQLGetInfo [ODBC32.045]
1327 SQLRETURN WINAPI SQLGetInfo(SQLHDBC ConnectionHandle,
1328 SQLUSMALLINT InfoType, SQLPOINTER InfoValue,
1329 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
1333 if (!pSQLGetInfo) return SQL_ERROR;
1334 return pSQLGetInfo(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLength);
1338 /*************************************************************************
1339 * SQLGetStmtAttr [ODBC32.038]
1341 SQLRETURN WINAPI SQLGetStmtAttr(SQLHSTMT StatementHandle,
1342 SQLINTEGER Attribute, SQLPOINTER Value,
1343 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
1347 if (!pSQLGetStmtAttr) return SQL_ERROR;
1348 return pSQLGetStmtAttr(StatementHandle, Attribute, Value, BufferLength, StringLength);
1352 /*************************************************************************
1353 * SQLGetStmtOption [ODBC32.046]
1355 SQLRETURN WINAPI SQLGetStmtOption(SQLHSTMT StatementHandle, SQLUSMALLINT Option, SQLPOINTER Value)
1359 if (!pSQLGetStmtOption) return SQL_ERROR;
1360 return pSQLGetStmtOption(StatementHandle, Option, Value);
1364 /*************************************************************************
1365 * SQLGetTypeInfo [ODBC32.047]
1367 SQLRETURN WINAPI SQLGetTypeInfo(SQLHSTMT StatementHandle, SQLSMALLINT DataType)
1371 if (!pSQLGetTypeInfo) return SQL_ERROR;
1372 return pSQLGetTypeInfo(StatementHandle, DataType);
1376 /*************************************************************************
1377 * SQLNumResultCols [ODBC32.018]
1379 SQLRETURN WINAPI SQLNumResultCols(SQLHSTMT StatementHandle, SQLSMALLINT *ColumnCount)
1383 if (!pSQLNumResultCols) return SQL_ERROR;
1384 return pSQLNumResultCols(StatementHandle, ColumnCount);
1388 /*************************************************************************
1389 * SQLParamData [ODBC32.048]
1391 SQLRETURN WINAPI SQLParamData(SQLHSTMT StatementHandle, SQLPOINTER *Value)
1395 if (!pSQLParamData) return SQL_ERROR;
1396 return pSQLParamData(StatementHandle, Value);
1400 /*************************************************************************
1401 * SQLPrepare [ODBC32.019]
1403 SQLRETURN WINAPI SQLPrepare(SQLHSTMT StatementHandle, SQLCHAR *StatementText, SQLINTEGER TextLength)
1407 if (!pSQLPrepare) return SQL_ERROR;
1408 return pSQLPrepare(StatementHandle, StatementText, TextLength);
1412 /*************************************************************************
1413 * SQLPutData [ODBC32.049]
1415 SQLRETURN WINAPI SQLPutData(SQLHSTMT StatementHandle, SQLPOINTER Data, SQLINTEGER StrLen_or_Ind)
1419 if (!pSQLPutData) return SQL_ERROR;
1420 return pSQLPutData(StatementHandle, Data, StrLen_or_Ind);
1424 /*************************************************************************
1425 * SQLRowCount [ODBC32.020]
1427 SQLRETURN WINAPI SQLRowCount(SQLHSTMT StatementHandle, SQLINTEGER *RowCount)
1431 if (!pSQLRowCount) return SQL_ERROR;
1432 return pSQLRowCount(StatementHandle, RowCount);
1436 /*************************************************************************
1437 * SQLSetConnectAttr [ODBC32.039]
1439 SQLRETURN WINAPI SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribute,
1440 SQLPOINTER Value, SQLINTEGER StringLength)
1444 if (!pSQLSetConnectAttr) return SQL_ERROR;
1445 return pSQLSetConnectAttr(ConnectionHandle, Attribute, Value, StringLength);
1449 /*************************************************************************
1450 * SQLSetConnectOption [ODBC32.050]
1452 SQLRETURN WINAPI SQLSetConnectOption(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLUINTEGER Value)
1456 if (!pSQLSetConnectOption) return SQL_ERROR;
1457 return pSQLSetConnectOption(ConnectionHandle, Option, Value);
1461 /*************************************************************************
1462 * SQLSetCursorName [ODBC32.021]
1464 SQLRETURN WINAPI SQLSetCursorName(SQLHSTMT StatementHandle, SQLCHAR *CursorName, SQLSMALLINT NameLength)
1468 if (!pSQLSetCursorName) return SQL_ERROR;
1469 return pSQLSetCursorName(StatementHandle, CursorName, NameLength);
1473 /*************************************************************************
1474 * SQLSetDescField [ODBC32.073]
1476 SQLRETURN WINAPI SQLSetDescField(SQLHDESC DescriptorHandle,
1477 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
1478 SQLPOINTER Value, SQLINTEGER BufferLength)
1482 if (!pSQLSetDescField) return SQL_ERROR;
1483 return pSQLSetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength);
1487 /*************************************************************************
1488 * SQLSetDescRec [ODBC32.074]
1490 SQLRETURN WINAPI SQLSetDescRec(SQLHDESC DescriptorHandle,
1491 SQLSMALLINT RecNumber, SQLSMALLINT Type,
1492 SQLSMALLINT SubType, SQLINTEGER Length,
1493 SQLSMALLINT Precision, SQLSMALLINT Scale,
1494 SQLPOINTER Data, SQLINTEGER *StringLength,
1495 SQLINTEGER *Indicator)
1499 if (!pSQLSetDescRec) return SQL_ERROR;
1500 return pSQLSetDescRec(DescriptorHandle, RecNumber, Type, SubType, Length,
1501 Precision, Scale, Data, StringLength, Indicator);
1505 /*************************************************************************
1506 * SQLSetEnvAttr [ODBC32.075]
1508 SQLRETURN WINAPI SQLSetEnvAttr(SQLHENV EnvironmentHandle,
1509 SQLINTEGER Attribute, SQLPOINTER Value,
1510 SQLINTEGER StringLength)
1514 if (!pSQLSetEnvAttr) return SQL_ERROR;
1515 return pSQLSetEnvAttr(EnvironmentHandle, Attribute, Value, StringLength);
1519 /*************************************************************************
1520 * SQLSetParam [ODBC32.022]
1522 SQLRETURN WINAPI SQLSetParam(SQLHSTMT StatementHandle,
1523 SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
1524 SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision,
1525 SQLSMALLINT ParameterScale, SQLPOINTER ParameterValue,
1526 SQLINTEGER *StrLen_or_Ind)
1530 if (!pSQLSetParam) return SQL_ERROR;
1531 return pSQLSetParam(StatementHandle, ParameterNumber, ValueType, ParameterType, LengthPrecision,
1532 ParameterScale, ParameterValue, StrLen_or_Ind);
1536 /*************************************************************************
1537 * SQLSetStmtAttr [ODBC32.076]
1539 SQLRETURN WINAPI SQLSetStmtAttr(SQLHSTMT StatementHandle,
1540 SQLINTEGER Attribute, SQLPOINTER Value,
1541 SQLINTEGER StringLength)
1545 if (!pSQLSetStmtAttr) return SQL_ERROR;
1546 return pSQLSetStmtAttr(StatementHandle, Attribute, Value, StringLength);
1550 /*************************************************************************
1551 * SQLSetStmtOption [ODBC32.051]
1553 SQLRETURN WINAPI SQLSetStmtOption(SQLHSTMT StatementHandle, SQLUSMALLINT Option, SQLUINTEGER Value)
1557 if (!pSQLSetStmtOption) return SQL_ERROR;
1558 return pSQLSetStmtOption(StatementHandle, Option, Value);
1562 /*************************************************************************
1563 * SQLSpecialColumns [ODBC32.052]
1565 SQLRETURN WINAPI SQLSpecialColumns(SQLHSTMT StatementHandle,
1566 SQLUSMALLINT IdentifierType, SQLCHAR *CatalogName,
1567 SQLSMALLINT NameLength1, SQLCHAR *SchemaName,
1568 SQLSMALLINT NameLength2, SQLCHAR *TableName,
1569 SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
1570 SQLUSMALLINT Nullable)
1573 if (!pSQLSpecialColumns) return SQL_ERROR;
1574 return pSQLSpecialColumns(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName,
1575 NameLength2, TableName, NameLength3, Scope, Nullable);
1579 /*************************************************************************
1580 * SQLStatistics [ODBC32.053]
1582 SQLRETURN WINAPI SQLStatistics(SQLHSTMT StatementHandle,
1583 SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
1584 SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
1585 SQLCHAR *TableName, SQLSMALLINT NameLength3,
1586 SQLUSMALLINT Unique, SQLUSMALLINT Reserved)
1590 if (!pSQLStatistics) return SQL_ERROR;
1591 return pSQLStatistics(StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2,
1592 TableName, NameLength3, Unique, Reserved);
1596 /*************************************************************************
1597 * SQLTables [ODBC32.054]
1599 SQLRETURN WINAPI SQLTables(SQLHSTMT StatementHandle,
1600 SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
1601 SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
1602 SQLCHAR *TableName, SQLSMALLINT NameLength3,
1603 SQLCHAR *TableType, SQLSMALLINT NameLength4)
1607 if (!pSQLTables) return SQL_ERROR;
1608 return pSQLTables(StatementHandle, CatalogName, NameLength1,
1609 SchemaName, NameLength2, TableName, NameLength3, TableType, NameLength4);
1613 /*************************************************************************
1614 * SQLTransact [ODBC32.023]
1616 SQLRETURN WINAPI SQLTransact(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle,
1617 SQLUSMALLINT CompletionType)
1621 if (!pSQLTransact) return SQL_ERROR;
1622 return pSQLTransact(EnvironmentHandle, ConnectionHandle, CompletionType);
1626 /*************************************************************************
1627 * SQLBrowseConnect [ODBC32.055]
1629 SQLRETURN WINAPI SQLBrowseConnect(
1631 SQLCHAR *szConnStrIn,
1632 SQLSMALLINT cbConnStrIn,
1633 SQLCHAR *szConnStrOut,
1634 SQLSMALLINT cbConnStrOutMax,
1635 SQLSMALLINT *pcbConnStrOut)
1639 if (!pSQLBrowseConnect) return SQL_ERROR;
1640 return pSQLBrowseConnect(hdbc, szConnStrIn, cbConnStrIn, szConnStrOut, cbConnStrOutMax, pcbConnStrOut);
1644 /*************************************************************************
1645 * SQLBulkOperations [ODBC32.078]
1647 SQLRETURN WINAPI SQLBulkOperations(
1648 SQLHSTMT StatementHandle,
1649 SQLSMALLINT Operation)
1653 if (!pSQLBulkOperations) return SQL_ERROR;
1654 return pSQLBulkOperations(StatementHandle, Operation);
1658 /*************************************************************************
1659 * SQLColAttributes [ODBC32.006]
1661 SQLRETURN WINAPI SQLColAttributes(
1664 SQLUSMALLINT fDescType,
1666 SQLSMALLINT cbDescMax,
1667 SQLSMALLINT *pcbDesc,
1672 if (!pSQLColAttributes) return SQL_ERROR;
1673 return pSQLColAttributes(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
1677 /*************************************************************************
1678 * SQLColumnPrivileges [ODBC32.056]
1680 SQLRETURN WINAPI SQLColumnPrivileges(
1682 SQLCHAR *szCatalogName,
1683 SQLSMALLINT cbCatalogName,
1684 SQLCHAR *szSchemaName,
1685 SQLSMALLINT cbSchemaName,
1686 SQLCHAR *szTableName,
1687 SQLSMALLINT cbTableName,
1688 SQLCHAR *szColumnName,
1689 SQLSMALLINT cbColumnName)
1693 if (!pSQLColumnPrivileges) return SQL_ERROR;
1694 return pSQLColumnPrivileges(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1695 szTableName, cbTableName, szColumnName, cbColumnName);
1699 /*************************************************************************
1700 * SQLDescribeParam [ODBC32.058]
1702 SQLRETURN WINAPI SQLDescribeParam(
1705 SQLSMALLINT *pfSqlType,
1706 SQLUINTEGER *pcbParamDef,
1707 SQLSMALLINT *pibScale,
1708 SQLSMALLINT *pfNullable)
1712 if (!pSQLDescribeParam) return SQL_ERROR;
1713 return pSQLDescribeParam(hstmt, ipar, pfSqlType, pcbParamDef, pibScale, pfNullable);
1717 /*************************************************************************
1718 * SQLExtendedFetch [ODBC32.059]
1720 SQLRETURN WINAPI SQLExtendedFetch(
1722 SQLUSMALLINT fFetchType,
1725 SQLUSMALLINT *rgfRowStatus)
1729 if (!pSQLExtendedFetch) return SQL_ERROR;
1730 return pSQLExtendedFetch(hstmt, fFetchType, irow, pcrow, rgfRowStatus);
1734 /*************************************************************************
1735 * SQLForeignKeys [ODBC32.060]
1737 SQLRETURN WINAPI SQLForeignKeys(
1739 SQLCHAR *szPkCatalogName,
1740 SQLSMALLINT cbPkCatalogName,
1741 SQLCHAR *szPkSchemaName,
1742 SQLSMALLINT cbPkSchemaName,
1743 SQLCHAR *szPkTableName,
1744 SQLSMALLINT cbPkTableName,
1745 SQLCHAR *szFkCatalogName,
1746 SQLSMALLINT cbFkCatalogName,
1747 SQLCHAR *szFkSchemaName,
1748 SQLSMALLINT cbFkSchemaName,
1749 SQLCHAR *szFkTableName,
1750 SQLSMALLINT cbFkTableName)
1754 if (!pSQLForeignKeys) return SQL_ERROR;
1755 return pSQLForeignKeys(hstmt, szPkCatalogName, cbPkCatalogName, szPkSchemaName, cbPkSchemaName,
1756 szPkTableName, cbPkTableName, szFkCatalogName, cbFkCatalogName,
1757 szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName);
1761 /*************************************************************************
1762 * SQLMoreResults [ODBC32.061]
1764 SQLRETURN WINAPI SQLMoreResults(SQLHSTMT hstmt)
1768 if (!pSQLMoreResults) return SQL_ERROR;
1769 return pSQLMoreResults(hstmt);
1773 /*************************************************************************
1774 * SQLNativeSql [ODBC32.062]
1776 SQLRETURN WINAPI SQLNativeSql(
1778 SQLCHAR *szSqlStrIn,
1779 SQLINTEGER cbSqlStrIn,
1781 SQLINTEGER cbSqlStrMax,
1782 SQLINTEGER *pcbSqlStr)
1786 if (!pSQLNativeSql) return SQL_ERROR;
1787 return pSQLNativeSql(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr);
1791 /*************************************************************************
1792 * SQLNumParams [ODBC32.063]
1794 SQLRETURN WINAPI SQLNumParams(
1800 if (!pSQLNumParams) return SQL_ERROR;
1801 return pSQLNumParams(hstmt, pcpar);
1805 /*************************************************************************
1806 * SQLParamOptions [ODBC32.064]
1808 SQLRETURN WINAPI SQLParamOptions(
1815 if (!pSQLParamOptions) return SQL_ERROR;
1816 return pSQLParamOptions(hstmt, crow, pirow);
1820 /*************************************************************************
1821 * SQLPrimaryKeys [ODBC32.065]
1823 SQLRETURN WINAPI SQLPrimaryKeys(
1825 SQLCHAR *szCatalogName,
1826 SQLSMALLINT cbCatalogName,
1827 SQLCHAR *szSchemaName,
1828 SQLSMALLINT cbSchemaName,
1829 SQLCHAR *szTableName,
1830 SQLSMALLINT cbTableName)
1834 if (!pSQLPrimaryKeys) return SQL_ERROR;
1835 return pSQLPrimaryKeys(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1836 szTableName, cbTableName);
1840 /*************************************************************************
1841 * SQLProcedureColumns [ODBC32.066]
1843 SQLRETURN WINAPI SQLProcedureColumns(
1845 SQLCHAR *szCatalogName,
1846 SQLSMALLINT cbCatalogName,
1847 SQLCHAR *szSchemaName,
1848 SQLSMALLINT cbSchemaName,
1849 SQLCHAR *szProcName,
1850 SQLSMALLINT cbProcName,
1851 SQLCHAR *szColumnName,
1852 SQLSMALLINT cbColumnName)
1856 if (!pSQLProcedureColumns) return SQL_ERROR;
1857 return pSQLProcedureColumns(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1858 szProcName, cbProcName, szColumnName, cbColumnName);
1862 /*************************************************************************
1863 * SQLProcedures [ODBC32.067]
1865 SQLRETURN WINAPI SQLProcedures(
1867 SQLCHAR *szCatalogName,
1868 SQLSMALLINT cbCatalogName,
1869 SQLCHAR *szSchemaName,
1870 SQLSMALLINT cbSchemaName,
1871 SQLCHAR *szProcName,
1872 SQLSMALLINT cbProcName)
1876 if (!pSQLProcedures) return SQL_ERROR;
1877 return pSQLProcedures(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1878 szProcName, cbProcName);
1882 /*************************************************************************
1883 * SQLSetPos [ODBC32.068]
1885 SQLRETURN WINAPI SQLSetPos(
1888 SQLUSMALLINT fOption,
1893 if (!pSQLSetPos) return SQL_ERROR;
1894 return pSQLSetPos(hstmt, irow, fOption, fLock);
1898 /*************************************************************************
1899 * SQLTablePrivileges [ODBC32.070]
1901 SQLRETURN WINAPI SQLTablePrivileges(
1903 SQLCHAR *szCatalogName,
1904 SQLSMALLINT cbCatalogName,
1905 SQLCHAR *szSchemaName,
1906 SQLSMALLINT cbSchemaName,
1907 SQLCHAR *szTableName,
1908 SQLSMALLINT cbTableName)
1912 if (!pSQLTablePrivileges) return SQL_ERROR;
1913 return pSQLTablePrivileges(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1914 szTableName, cbTableName);
1918 /*************************************************************************
1919 * SQLDrivers [ODBC32.071]
1921 SQLRETURN WINAPI SQLDrivers(
1923 SQLUSMALLINT fDirection,
1924 SQLCHAR *szDriverDesc,
1925 SQLSMALLINT cbDriverDescMax,
1926 SQLSMALLINT *pcbDriverDesc,
1927 SQLCHAR *szDriverAttributes,
1928 SQLSMALLINT cbDriverAttrMax,
1929 SQLSMALLINT *pcbDriverAttr)
1933 if (!pSQLDrivers) return SQL_ERROR;
1934 return pSQLDrivers(henv, fDirection, szDriverDesc, cbDriverDescMax, pcbDriverDesc,
1935 szDriverAttributes, cbDriverAttrMax, pcbDriverAttr);
1939 /*************************************************************************
1940 * SQLBindParameter [ODBC32.072]
1942 SQLRETURN WINAPI SQLBindParameter(
1945 SQLSMALLINT fParamType,
1947 SQLSMALLINT fSqlType,
1948 SQLUINTEGER cbColDef,
1949 SQLSMALLINT ibScale,
1950 SQLPOINTER rgbValue,
1951 SQLINTEGER cbValueMax,
1952 SQLINTEGER *pcbValue)
1956 if (!pSQLBindParameter) return SQL_ERROR;
1957 return pSQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale,
1958 rgbValue, cbValueMax, pcbValue);
1962 /*************************************************************************
1963 * SQLDriverConnect [ODBC32.041]
1965 SQLRETURN WINAPI SQLDriverConnect(
1968 SQLCHAR *conn_str_in,
1969 SQLSMALLINT len_conn_str_in,
1970 SQLCHAR *conn_str_out,
1971 SQLSMALLINT conn_str_out_max,
1972 SQLSMALLINT *ptr_conn_str_out,
1973 SQLUSMALLINT driver_completion )
1977 if (!pSQLDriverConnect) return SQL_ERROR;
1978 return pSQLDriverConnect(hdbc, hwnd, conn_str_in, len_conn_str_in, conn_str_out,
1979 conn_str_out_max, ptr_conn_str_out, driver_completion);
1983 /*************************************************************************
1984 * SQLSetScrollOptions [ODBC32.069]
1986 SQLRETURN WINAPI SQLSetScrollOptions(
1987 SQLHSTMT statement_handle,
1988 SQLUSMALLINT f_concurrency,
1989 SQLINTEGER crow_keyset,
1990 SQLUSMALLINT crow_rowset )
1994 if (!pSQLSetScrollOptions) return SQL_ERROR;
1995 return pSQLSetScrollOptions(statement_handle, f_concurrency, crow_keyset, crow_rowset);
1998 static int SQLColAttributes_KnownStringAttribute(SQLUSMALLINT fDescType)
2000 static const SQLUSMALLINT attrList[] =
2002 SQL_COLUMN_OWNER_NAME,
2003 SQL_COLUMN_QUALIFIER_NAME,
2006 SQL_COLUMN_TABLE_NAME,
2007 SQL_COLUMN_TYPE_NAME,
2008 SQL_DESC_BASE_COLUMN_NAME,
2009 SQL_DESC_BASE_TABLE_NAME,
2010 SQL_DESC_CATALOG_NAME,
2012 SQL_DESC_LITERAL_PREFIX,
2013 SQL_DESC_LITERAL_SUFFIX,
2014 SQL_DESC_LOCAL_TYPE_NAME,
2016 SQL_DESC_SCHEMA_NAME,
2017 SQL_DESC_TABLE_NAME,
2022 for (i = 0; i < sizeof(attrList) / sizeof(SQLUSMALLINT); i++) {
2023 if (attrList[i] == fDescType) return 1;
2028 /*************************************************************************
2029 * SQLColAttributesW [ODBC32.106]
2031 SQLRETURN WINAPI SQLColAttributesW(
2034 SQLUSMALLINT fDescType,
2036 SQLSMALLINT cbDescMax,
2037 SQLSMALLINT *pcbDesc,
2042 TRACE("hstmt=%p icol=%d fDescType=%d rgbDesc=%p cbDescMax=%d pcbDesc=%p pfDesc=%p\n",
2043 hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
2045 if (!pSQLColAttributesW) return SQL_ERROR;
2047 iResult = pSQLColAttributesW(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
2048 if (iResult == SQL_SUCCESS && rgbDesc != NULL && SQLColAttributes_KnownStringAttribute(fDescType)) {
2050 TRACE("Dumping values fetched via SQLColAttributesW:\n");
2051 TRACE(" Attribute name : %s\n", debugstr_w(rgbDesc));
2052 TRACE(" Declared length: %d\n", *pcbDesc);
2054 if (*pcbDesc != lstrlenW(rgbDesc) * 2) {
2055 TRACE("CHEAT: resetting name length for ADO\n");
2056 *pcbDesc = lstrlenW(rgbDesc) * 2;
2062 /*************************************************************************
2063 * SQLConnectW [ODBC32.107]
2065 SQLRETURN WINAPI SQLConnectW(SQLHDBC ConnectionHandle,
2066 WCHAR *ServerName, SQLSMALLINT NameLength1,
2067 WCHAR *UserName, SQLSMALLINT NameLength2,
2068 WCHAR *Authentication, SQLSMALLINT NameLength3)
2071 TRACE("(Server=%.*s)\n",NameLength1+3, debugstr_w(ServerName));
2073 if (!pSQLConnectW) return SQL_ERROR;
2075 ret = pSQLConnectW(ConnectionHandle, ServerName, NameLength1,
2076 UserName, NameLength2, Authentication, NameLength3);
2078 TRACE("returns %d\n",ret);
2082 /*************************************************************************
2083 * SQLDescribeColW [ODBC32.108]
2085 SQLRETURN WINAPI SQLDescribeColW(SQLHSTMT StatementHandle,
2086 SQLUSMALLINT ColumnNumber, WCHAR *ColumnName,
2087 SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
2088 SQLSMALLINT *DataType, SQLULEN *ColumnSize,
2089 SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
2094 if (!pSQLDescribeColW) return SQL_ERROR;
2096 iResult = pSQLDescribeColW(StatementHandle, ColumnNumber, ColumnName,
2097 BufferLength, NameLength, DataType, ColumnSize,
2098 DecimalDigits, Nullable);
2100 TRACE("Successfully recovered the following column information:\n");
2101 TRACE("\tRequested column index: %d\n", ColumnNumber);
2102 TRACE("\tAvailable length for column name: %d\n", BufferLength);
2103 if (NameLength != NULL)
2104 TRACE("\tActual length for column name: %d\n", *NameLength);
2105 else TRACE("\tActual length for column name: (null)\n");
2106 TRACE("\tReturned column name: %s\n", debugstr_w(ColumnName));
2111 /*************************************************************************
2112 * SQLErrorW [ODBC32.110]
2114 SQLRETURN WINAPI SQLErrorW(SQLHENV EnvironmentHandle,
2115 SQLHDBC ConnectionHandle, SQLHSTMT StatementHandle,
2116 WCHAR *Sqlstate, SQLINTEGER *NativeError,
2117 WCHAR *MessageText, SQLSMALLINT BufferLength,
2118 SQLSMALLINT *TextLength)
2122 if (!pSQLErrorW) return SQL_ERROR;
2123 return pSQLErrorW(EnvironmentHandle, ConnectionHandle, StatementHandle,
2124 Sqlstate, NativeError, MessageText, BufferLength, TextLength);
2127 /*************************************************************************
2128 * SQLExecDirectW [ODBC32.111]
2130 SQLRETURN WINAPI SQLExecDirectW(SQLHSTMT StatementHandle,
2131 WCHAR *StatementText, SQLINTEGER TextLength)
2135 if (!pSQLExecDirectW) return SQL_ERROR;
2136 return pSQLExecDirectW(StatementHandle, StatementText, TextLength);
2139 /*************************************************************************
2140 * SQLGetCursorNameW [ODBC32.117]
2142 SQLRETURN WINAPI SQLGetCursorNameW(SQLHSTMT StatementHandle,
2143 WCHAR *CursorName, SQLSMALLINT BufferLength,
2144 SQLSMALLINT *NameLength)
2148 if (!pSQLGetCursorNameW) return SQL_ERROR;
2149 return pSQLGetCursorNameW(StatementHandle, CursorName, BufferLength, NameLength);
2152 /*************************************************************************
2153 * SQLPrepareW [ODBC32.119]
2155 SQLRETURN WINAPI SQLPrepareW(SQLHSTMT StatementHandle,
2156 WCHAR *StatementText, SQLINTEGER TextLength)
2160 if (!pSQLPrepareW) return SQL_ERROR;
2161 return pSQLPrepareW(StatementHandle, StatementText, TextLength);
2164 /*************************************************************************
2165 * SQLSetCursorNameW [ODBC32.121]
2167 SQLRETURN WINAPI SQLSetCursorNameW(SQLHSTMT StatementHandle, WCHAR *CursorName, SQLSMALLINT NameLength)
2171 if (!pSQLSetCursorNameW) return SQL_ERROR;
2172 return pSQLSetCursorNameW(StatementHandle, CursorName, NameLength);
2175 /*************************************************************************
2176 * SQLColAttributeW [ODBC32.127]
2178 SQLRETURN WINAPI SQLColAttributeW (SQLHSTMT StatementHandle,
2179 SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
2180 SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength,
2181 SQLSMALLINT *StringLength, SQLPOINTER NumericAttribute)
2185 TRACE("StatementHandle=%p ColumnNumber=%d FieldIdentifier=%d CharacterAttribute=%p BufferLength=%d StringLength=%p NumericAttribute=%p\n",
2186 StatementHandle, ColumnNumber, FieldIdentifier,
2187 CharacterAttribute, BufferLength, StringLength, NumericAttribute);
2189 if (!pSQLColAttributeW) return SQL_ERROR;
2191 iResult = pSQLColAttributeW(StatementHandle, ColumnNumber, FieldIdentifier,
2192 CharacterAttribute, BufferLength, StringLength, NumericAttribute);
2193 if (iResult == SQL_SUCCESS && CharacterAttribute != NULL && SQLColAttributes_KnownStringAttribute(FieldIdentifier)) {
2195 TRACE("Dumping values fetched via SQLColAttributeW:\n");
2196 TRACE(" Attribute name : %s\n", debugstr_w(rgbDesc));
2197 TRACE(" Declared length: %d\n", *pcbDesc);
2199 if (*StringLength != lstrlenW(CharacterAttribute) * 2) {
2200 TRACE("CHEAT: resetting name length for ADO\n");
2201 *StringLength = lstrlenW(CharacterAttribute) * 2;
2207 /*************************************************************************
2208 * SQLGetConnectAttrW [ODBC32.132]
2210 SQLRETURN WINAPI SQLGetConnectAttrW(SQLHDBC ConnectionHandle,
2211 SQLINTEGER Attribute, SQLPOINTER Value,
2212 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
2216 if (!pSQLGetConnectAttrW) return SQL_ERROR;
2217 return pSQLGetConnectAttrW(ConnectionHandle, Attribute, Value,
2218 BufferLength, StringLength);
2221 /*************************************************************************
2222 * SQLGetDescFieldW [ODBC32.133]
2224 SQLRETURN WINAPI SQLGetDescFieldW(SQLHDESC DescriptorHandle,
2225 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
2226 SQLPOINTER Value, SQLINTEGER BufferLength,
2227 SQLINTEGER *StringLength)
2231 if (!pSQLGetDescFieldW) return SQL_ERROR;
2232 return pSQLGetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier,
2233 Value, BufferLength, StringLength);
2236 /*************************************************************************
2237 * SQLGetDescRecW [ODBC32.134]
2239 SQLRETURN WINAPI SQLGetDescRecW(SQLHDESC DescriptorHandle,
2240 SQLSMALLINT RecNumber, WCHAR *Name,
2241 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
2242 SQLSMALLINT *Type, SQLSMALLINT *SubType,
2243 SQLLEN *Length, SQLSMALLINT *Precision,
2244 SQLSMALLINT *Scale, SQLSMALLINT *Nullable)
2248 if (!pSQLGetDescRecW) return SQL_ERROR;
2249 return pSQLGetDescRecW(DescriptorHandle, RecNumber, Name, BufferLength,
2250 StringLength, Type, SubType, Length, Precision, Scale, Nullable);
2253 /*************************************************************************
2254 * SQLGetDiagFieldW [ODBC32.135]
2256 SQLRETURN WINAPI SQLGetDiagFieldW(SQLSMALLINT HandleType, SQLHANDLE Handle,
2257 SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier,
2258 SQLPOINTER DiagInfo, SQLSMALLINT BufferLength,
2259 SQLSMALLINT *StringLength)
2263 if (!pSQLGetDiagFieldW) return SQL_ERROR;
2264 return pSQLGetDiagFieldW(HandleType, Handle, RecNumber, DiagIdentifier,
2265 DiagInfo, BufferLength, StringLength);
2268 /*************************************************************************
2269 * SQLGetDiagRecW [ODBC32.136]
2271 SQLRETURN WINAPI SQLGetDiagRecW(SQLSMALLINT HandleType, SQLHANDLE Handle,
2272 SQLSMALLINT RecNumber, WCHAR *Sqlstate,
2273 SQLINTEGER *NativeError, WCHAR *MessageText,
2274 SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
2278 if (!pSQLGetDiagRecW) return SQL_ERROR;
2279 return pSQLGetDiagRecW(HandleType, Handle, RecNumber, Sqlstate, NativeError,
2280 MessageText, BufferLength, TextLength);
2283 /*************************************************************************
2284 * SQLGetStmtAttrW [ODBC32.138]
2286 SQLRETURN WINAPI SQLGetStmtAttrW(SQLHSTMT StatementHandle,
2287 SQLINTEGER Attribute, SQLPOINTER Value,
2288 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
2292 TRACE("Attribute = (%02d) Value = %p BufferLength = (%d) StringLength = %p\n",
2293 Attribute, Value, BufferLength, StringLength);
2295 if (Value == NULL) {
2296 WARN("Unexpected NULL in Value return address\n");
2297 iResult = SQL_ERROR;
2299 } else if (StringLength == NULL) {
2300 WARN("Unexpected NULL in StringLength return address\n");
2301 iResult = SQL_ERROR;
2304 if (!pSQLGetStmtAttrW) return SQL_ERROR;
2305 iResult = pSQLGetStmtAttrW(StatementHandle, Attribute, Value, BufferLength, StringLength);
2306 TRACE("returning %d...\n", iResult);
2311 /*************************************************************************
2312 * SQLSetConnectAttrW [ODBC32.139]
2314 SQLRETURN WINAPI SQLSetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribute,
2315 SQLPOINTER Value, SQLINTEGER StringLength)
2319 if (!pSQLSetConnectAttrW) return SQL_ERROR;
2320 return pSQLSetConnectAttrW(ConnectionHandle, Attribute, Value, StringLength);
2323 /*************************************************************************
2324 * SQLColumnsW [ODBC32.140]
2326 SQLRETURN WINAPI SQLColumnsW(SQLHSTMT StatementHandle,
2327 WCHAR *CatalogName, SQLSMALLINT NameLength1,
2328 WCHAR *SchemaName, SQLSMALLINT NameLength2,
2329 WCHAR *TableName, SQLSMALLINT NameLength3,
2330 WCHAR *ColumnName, SQLSMALLINT NameLength4)
2334 if (!pSQLColumnsW) return SQL_ERROR;
2335 return pSQLColumnsW(StatementHandle, CatalogName, NameLength1,
2336 SchemaName, NameLength2, TableName, NameLength3, ColumnName, NameLength4);
2339 /*************************************************************************
2340 * SQLDriverConnectW [ODBC32.141]
2342 SQLRETURN WINAPI SQLDriverConnectW(
2346 SQLSMALLINT len_conn_str_in,
2347 WCHAR *conn_str_out,
2348 SQLSMALLINT conn_str_out_max,
2349 SQLSMALLINT *ptr_conn_str_out,
2350 SQLUSMALLINT driver_completion )
2352 TRACE("ConnStrIn (%d bytes) --> %s\n", len_conn_str_in, debugstr_w(conn_str_in));
2354 if (!pSQLDriverConnectW) return SQL_ERROR;
2355 return pSQLDriverConnectW(hdbc, hwnd, conn_str_in, len_conn_str_in, conn_str_out,
2356 conn_str_out_max, ptr_conn_str_out, driver_completion);
2359 /*************************************************************************
2360 * SQLGetConnectOptionW [ODBC32.142]
2362 SQLRETURN WINAPI SQLGetConnectOptionW(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLPOINTER Value)
2366 if (!pSQLGetConnectOptionW) return SQL_ERROR;
2367 return pSQLGetConnectOptionW(ConnectionHandle, Option, Value);
2370 /*************************************************************************
2371 * SQLGetInfoW [ODBC32.145]
2373 SQLRETURN WINAPI SQLGetInfoW(SQLHDBC ConnectionHandle,
2374 SQLUSMALLINT InfoType, SQLPOINTER InfoValue,
2375 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
2379 TRACE("InfoType = (%02u), InfoValue = %p, BufferLength = %d bytes\n", InfoType, InfoValue, BufferLength);
2380 if (InfoValue == NULL) {
2381 WARN("Unexpected NULL in InfoValue address\n");
2382 iResult = SQL_ERROR;
2384 if (!pSQLGetInfoW) return SQL_ERROR;
2385 iResult = pSQLGetInfoW(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLength);
2386 TRACE("returning %d...\n", iResult);
2391 /*************************************************************************
2392 * SQLGetTypeInfoW [ODBC32.147]
2394 SQLRETURN WINAPI SQLGetTypeInfoW(SQLHSTMT StatementHandle, SQLSMALLINT DataType)
2398 if (!pSQLGetTypeInfoW) return SQL_ERROR;
2399 return pSQLGetTypeInfoW(StatementHandle, DataType);
2402 /*************************************************************************
2403 * SQLSetConnectOptionW [ODBC32.150]
2405 SQLRETURN WINAPI SQLSetConnectOptionW(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLUINTEGER Value)
2409 if (!pSQLSetConnectOptionW) return SQL_ERROR;
2410 return pSQLSetConnectOptionW(ConnectionHandle, Option, Value);
2413 /*************************************************************************
2414 * SQLSpecialColumnsW [ODBC32.152]
2416 SQLRETURN WINAPI SQLSpecialColumnsW(SQLHSTMT StatementHandle,
2417 SQLUSMALLINT IdentifierType, SQLWCHAR *CatalogName,
2418 SQLSMALLINT NameLength1, SQLWCHAR *SchemaName,
2419 SQLSMALLINT NameLength2, SQLWCHAR *TableName,
2420 SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
2421 SQLUSMALLINT Nullable)
2423 if (!pSQLSpecialColumnsW) return SQL_ERROR;
2424 return pSQLSpecialColumnsW(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName,
2425 NameLength2, TableName, NameLength3, Scope, Nullable);
2428 /*************************************************************************
2429 * SQLStatisticsW [ODBC32.153]
2431 SQLRETURN WINAPI SQLStatisticsW(SQLHSTMT StatementHandle,
2432 SQLWCHAR *CatalogName, SQLSMALLINT NameLength1,
2433 SQLWCHAR *SchemaName, SQLSMALLINT NameLength2,
2434 SQLWCHAR *TableName, SQLSMALLINT NameLength3,
2435 SQLUSMALLINT Unique, SQLUSMALLINT Reserved)
2439 if (!pSQLStatisticsW) return SQL_ERROR;
2440 return pSQLStatisticsW(StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2,
2441 TableName, NameLength3, Unique, Reserved);
2444 /*************************************************************************
2445 * SQLTablesW [ODBC32.154]
2447 SQLRETURN WINAPI SQLTablesW(SQLHSTMT StatementHandle,
2448 SQLWCHAR *CatalogName, SQLSMALLINT NameLength1,
2449 SQLWCHAR *SchemaName, SQLSMALLINT NameLength2,
2450 SQLWCHAR *TableName, SQLSMALLINT NameLength3,
2451 SQLWCHAR *TableType, SQLSMALLINT NameLength4)
2455 if (!pSQLTablesW) return SQL_ERROR;
2456 return pSQLTablesW(StatementHandle, CatalogName, NameLength1,
2457 SchemaName, NameLength2, TableName, NameLength3, TableType, NameLength4);
2460 /*************************************************************************
2461 * SQLBrowseConnectW [ODBC32.155]
2463 SQLRETURN WINAPI SQLBrowseConnectW(
2465 SQLWCHAR *szConnStrIn,
2466 SQLSMALLINT cbConnStrIn,
2467 SQLWCHAR *szConnStrOut,
2468 SQLSMALLINT cbConnStrOutMax,
2469 SQLSMALLINT *pcbConnStrOut)
2473 if (!pSQLBrowseConnectW) return SQL_ERROR;
2474 return pSQLBrowseConnectW(hdbc, szConnStrIn, cbConnStrIn, szConnStrOut,
2475 cbConnStrOutMax, pcbConnStrOut);
2478 /*************************************************************************
2479 * SQLColumnPrivilegesW [ODBC32.156]
2481 SQLRETURN WINAPI SQLColumnPrivilegesW(
2483 SQLWCHAR *szCatalogName,
2484 SQLSMALLINT cbCatalogName,
2485 SQLWCHAR *szSchemaName,
2486 SQLSMALLINT cbSchemaName,
2487 SQLWCHAR *szTableName,
2488 SQLSMALLINT cbTableName,
2489 SQLWCHAR *szColumnName,
2490 SQLSMALLINT cbColumnName)
2494 if (!pSQLColumnPrivilegesW) return SQL_ERROR;
2495 return pSQLColumnPrivilegesW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2496 szTableName, cbTableName, szColumnName, cbColumnName);
2499 /*************************************************************************
2500 * SQLDataSourcesW [ODBC32.157]
2502 SQLRETURN WINAPI SQLDataSourcesW(SQLHENV EnvironmentHandle,
2503 SQLUSMALLINT Direction, WCHAR *ServerName,
2504 SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
2505 WCHAR *Description, SQLSMALLINT BufferLength2,
2506 SQLSMALLINT *NameLength2)
2510 TRACE("EnvironmentHandle = %p\n", EnvironmentHandle);
2512 if (!pSQLDataSourcesW) return SQL_ERROR;
2514 ret = pSQLDataSourcesW(EnvironmentHandle, Direction, ServerName,
2515 BufferLength1, NameLength1, Description, BufferLength2, NameLength2);
2519 TRACE("returns: %d \t", ret);
2520 if (*NameLength1 > 0)
2521 TRACE("DataSource = %s,", debugstr_w(ServerName));
2522 if (*NameLength2 > 0)
2523 TRACE(" Description = %s", debugstr_w(Description));
2530 /*************************************************************************
2531 * SQLForeignKeysW [ODBC32.160]
2533 SQLRETURN WINAPI SQLForeignKeysW(
2535 SQLWCHAR *szPkCatalogName,
2536 SQLSMALLINT cbPkCatalogName,
2537 SQLWCHAR *szPkSchemaName,
2538 SQLSMALLINT cbPkSchemaName,
2539 SQLWCHAR *szPkTableName,
2540 SQLSMALLINT cbPkTableName,
2541 SQLWCHAR *szFkCatalogName,
2542 SQLSMALLINT cbFkCatalogName,
2543 SQLWCHAR *szFkSchemaName,
2544 SQLSMALLINT cbFkSchemaName,
2545 SQLWCHAR *szFkTableName,
2546 SQLSMALLINT cbFkTableName)
2550 if (!pSQLForeignKeysW) return SQL_ERROR;
2551 return pSQLForeignKeysW(hstmt, szPkCatalogName, cbPkCatalogName, szPkSchemaName, cbPkSchemaName,
2552 szPkTableName, cbPkTableName, szFkCatalogName, cbFkCatalogName,
2553 szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName);
2556 /*************************************************************************
2557 * SQLNativeSqlW [ODBC32.162]
2559 SQLRETURN WINAPI SQLNativeSqlW(
2561 SQLWCHAR *szSqlStrIn,
2562 SQLINTEGER cbSqlStrIn,
2564 SQLINTEGER cbSqlStrMax,
2565 SQLINTEGER *pcbSqlStr)
2569 if (!pSQLNativeSqlW) return SQL_ERROR;
2570 return pSQLNativeSqlW(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr);
2573 /*************************************************************************
2574 * SQLPrimaryKeysW [ODBC32.165]
2576 SQLRETURN WINAPI SQLPrimaryKeysW(
2578 SQLWCHAR *szCatalogName,
2579 SQLSMALLINT cbCatalogName,
2580 SQLWCHAR *szSchemaName,
2581 SQLSMALLINT cbSchemaName,
2582 SQLWCHAR *szTableName,
2583 SQLSMALLINT cbTableName)
2587 if (!pSQLPrimaryKeysW) return SQL_ERROR;
2588 return pSQLPrimaryKeysW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2589 szTableName, cbTableName);
2592 /*************************************************************************
2593 * SQLProcedureColumnsW [ODBC32.166]
2595 SQLRETURN WINAPI SQLProcedureColumnsW(
2597 SQLWCHAR *szCatalogName,
2598 SQLSMALLINT cbCatalogName,
2599 SQLWCHAR *szSchemaName,
2600 SQLSMALLINT cbSchemaName,
2601 SQLWCHAR *szProcName,
2602 SQLSMALLINT cbProcName,
2603 SQLWCHAR *szColumnName,
2604 SQLSMALLINT cbColumnName)
2608 if (!pSQLProcedureColumnsW) return SQL_ERROR;
2609 return pSQLProcedureColumnsW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2610 szProcName, cbProcName, szColumnName, cbColumnName);
2613 /*************************************************************************
2614 * SQLProceduresW [ODBC32.167]
2616 SQLRETURN WINAPI SQLProceduresW(
2618 SQLWCHAR *szCatalogName,
2619 SQLSMALLINT cbCatalogName,
2620 SQLWCHAR *szSchemaName,
2621 SQLSMALLINT cbSchemaName,
2622 SQLWCHAR *szProcName,
2623 SQLSMALLINT cbProcName)
2627 if (!pSQLProceduresW) return SQL_ERROR;
2628 return pSQLProceduresW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2629 szProcName, cbProcName);
2632 /*************************************************************************
2633 * SQLTablePrivilegesW [ODBC32.170]
2635 SQLRETURN WINAPI SQLTablePrivilegesW(
2637 SQLWCHAR *szCatalogName,
2638 SQLSMALLINT cbCatalogName,
2639 SQLWCHAR *szSchemaName,
2640 SQLSMALLINT cbSchemaName,
2641 SQLWCHAR *szTableName,
2642 SQLSMALLINT cbTableName)
2646 if (!pSQLTablePrivilegesW) return SQL_ERROR;
2647 return pSQLTablePrivilegesW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2648 szTableName, cbTableName);
2651 /*************************************************************************
2652 * SQLDriversW [ODBC32.171]
2654 SQLRETURN WINAPI SQLDriversW(
2656 SQLUSMALLINT fDirection,
2657 SQLWCHAR *szDriverDesc,
2658 SQLSMALLINT cbDriverDescMax,
2659 SQLSMALLINT *pcbDriverDesc,
2660 SQLWCHAR *szDriverAttributes,
2661 SQLSMALLINT cbDriverAttrMax,
2662 SQLSMALLINT *pcbDriverAttr)
2666 if (!pSQLDriversW) return SQL_ERROR;
2667 return pSQLDriversW(henv, fDirection, szDriverDesc, cbDriverDescMax, pcbDriverDesc,
2668 szDriverAttributes, cbDriverAttrMax, pcbDriverAttr);
2671 /*************************************************************************
2672 * SQLSetDescFieldW [ODBC32.173]
2674 SQLRETURN WINAPI SQLSetDescFieldW(SQLHDESC DescriptorHandle,
2675 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
2676 SQLPOINTER Value, SQLINTEGER BufferLength)
2680 if (!pSQLSetDescFieldW) return SQL_ERROR;
2681 return pSQLSetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength);
2684 /*************************************************************************
2685 * SQLSetStmtAttrW [ODBC32.176]
2687 SQLRETURN WINAPI SQLSetStmtAttrW(SQLHSTMT StatementHandle,
2688 SQLINTEGER Attribute, SQLPOINTER Value,
2689 SQLINTEGER StringLength)
2692 TRACE("Attribute = (%02d) Value = %p StringLength = (%d)\n",
2693 Attribute, Value, StringLength);
2695 if (!pSQLSetStmtAttrW) return SQL_ERROR;
2696 iResult = pSQLSetStmtAttrW(StatementHandle, Attribute, Value, StringLength);
2697 if (iResult == SQL_ERROR && (Attribute == SQL_ROWSET_SIZE || Attribute == SQL_ATTR_ROW_ARRAY_SIZE)) {
2698 TRACE("CHEAT: returning SQL_SUCCESS to ADO...\n");
2699 iResult = SQL_SUCCESS;
2701 TRACE("returning %d...\n", iResult);