hhctrl.ocx: Open a specific topic when requested.
[wine/multimedia.git] / dlls / odbc32 / proxyodbc.c
blob50a2f99da4cfccaf2d1345f90727140cd6b6f107
1 /*
2 * Win32 ODBC functions
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
20 * NOTES:
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.
28 #include "config.h"
29 #include "wine/port.h"
31 #include <stdarg.h>
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <assert.h>
37 #include "windef.h"
38 #include "winbase.h"
39 #include "winreg.h"
40 #include "wine/debug.h"
41 #include "wine/library.h"
42 #include "wine/unicode.h"
44 #include "sql.h"
45 #include "sqltypes.h"
46 #include "sqlext.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 (*pSQLDataSourcesW)(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
79 static SQLRETURN (*pSQLDescribeCol)(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLUINTEGER*,SQLSMALLINT*,SQLSMALLINT*);
80 static SQLRETURN (*pSQLDescribeColW)(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*);
81 static SQLRETURN (*pSQLDescribeParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT*,SQLUINTEGER*,SQLSMALLINT*,SQLSMALLINT*);
82 static SQLRETURN (*pSQLDisconnect)(SQLHDBC);
83 static SQLRETURN (*pSQLDriverConnect)(SQLHDBC,SQLHWND,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT);
84 static SQLRETURN (*pSQLDriverConnectW)(SQLHDBC,SQLHWND,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT);
85 static SQLRETURN (*pSQLDrivers)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
86 static SQLRETURN (*pSQLDriversW)(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
87 static SQLRETURN (*pSQLEndTran)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT);
88 static SQLRETURN (*pSQLError)(SQLHENV,SQLHDBC,SQLHSTMT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
89 static SQLRETURN (*pSQLErrorW)(SQLHENV,SQLHDBC,SQLHSTMT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
90 static SQLRETURN (*pSQLExecDirect)(SQLHSTMT,SQLCHAR*,SQLINTEGER);
91 static SQLRETURN (*pSQLExecDirectW)(SQLHSTMT,SQLWCHAR*,SQLINTEGER);
92 static SQLRETURN (*pSQLExecute)(SQLHSTMT);
93 static SQLRETURN (*pSQLExtendedFetch)(SQLHSTMT,SQLUSMALLINT,SQLINTEGER,SQLUINTEGER*,SQLUSMALLINT*);
94 static SQLRETURN (*pSQLFetch)(SQLHSTMT);
95 static SQLRETURN (*pSQLFetchScroll)(SQLHSTMT,SQLSMALLINT,SQLINTEGER);
96 static SQLRETURN (*pSQLForeignKeys)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
97 static SQLRETURN (*pSQLForeignKeysW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
98 static SQLRETURN (*pSQLFreeConnect)(SQLHDBC);
99 static SQLRETURN (*pSQLFreeEnv)(SQLHENV);
100 static SQLRETURN (*pSQLFreeHandle)(SQLSMALLINT,SQLHANDLE);
101 static SQLRETURN (*pSQLFreeStmt)(SQLHSTMT,SQLUSMALLINT);
102 static SQLRETURN (*pSQLGetConnectAttr)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
103 static SQLRETURN (*pSQLGetConnectAttrW)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
104 static SQLRETURN (*pSQLGetConnectOption)(SQLHDBC,SQLUSMALLINT,SQLPOINTER);
105 static SQLRETURN (*pSQLGetConnectOptionW)(SQLHDBC,SQLUSMALLINT,SQLPOINTER);
106 static SQLRETURN (*pSQLGetCursorName)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
107 static SQLRETURN (*pSQLGetCursorNameW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
108 static SQLRETURN (*pSQLGetData)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
109 static SQLRETURN (*pSQLGetDescField)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
110 static SQLRETURN (*pSQLGetDescFieldW)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
111 static SQLRETURN (*pSQLGetDescRec)(SQLHDESC,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLINTEGER*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*);
112 static SQLRETURN (*pSQLGetDescRecW)(SQLHDESC,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLLEN*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*);
113 static SQLRETURN (*pSQLGetDiagField)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
114 static SQLRETURN (*pSQLGetDiagFieldW)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
115 static SQLRETURN (*pSQLGetDiagRec)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
116 static SQLRETURN (*pSQLGetDiagRecW)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
117 static SQLRETURN (*pSQLGetEnvAttr)(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
118 static SQLRETURN (*pSQLGetFunctions)(SQLHDBC,SQLUSMALLINT,SQLUSMALLINT*);
119 static SQLRETURN (*pSQLGetInfo)(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
120 static SQLRETURN (*pSQLGetInfoW)(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
121 static SQLRETURN (*pSQLGetStmtAttr)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
122 static SQLRETURN (*pSQLGetStmtAttrW)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
123 static SQLRETURN (*pSQLGetStmtOption)(SQLHSTMT,SQLUSMALLINT,SQLPOINTER);
124 static SQLRETURN (*pSQLGetTypeInfo)(SQLHSTMT,SQLSMALLINT);
125 static SQLRETURN (*pSQLGetTypeInfoW)(SQLHSTMT,SQLSMALLINT);
126 static SQLRETURN (*pSQLMoreResults)(SQLHSTMT);
127 static SQLRETURN (*pSQLNativeSql)(SQLHDBC,SQLCHAR*,SQLINTEGER,SQLCHAR*,SQLINTEGER,SQLINTEGER*);
128 static SQLRETURN (*pSQLNativeSqlW)(SQLHDBC,SQLWCHAR*,SQLINTEGER,SQLWCHAR*,SQLINTEGER,SQLINTEGER*);
129 static SQLRETURN (*pSQLNumParams)(SQLHSTMT,SQLSMALLINT*);
130 static SQLRETURN (*pSQLNumResultCols)(SQLHSTMT,SQLSMALLINT*);
131 static SQLRETURN (*pSQLParamData)(SQLHSTMT,SQLPOINTER*);
132 static SQLRETURN (*pSQLParamOptions)(SQLHSTMT,SQLUINTEGER,SQLUINTEGER*);
133 static SQLRETURN (*pSQLPrepare)(SQLHSTMT,SQLCHAR*,SQLINTEGER);
134 static SQLRETURN (*pSQLPrepareW)(SQLHSTMT,SQLWCHAR*,SQLINTEGER);
135 static SQLRETURN (*pSQLPrimaryKeys)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
136 static SQLRETURN (*pSQLPrimaryKeysW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
137 static SQLRETURN (*pSQLProcedureColumns)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
138 static SQLRETURN (*pSQLProcedureColumnsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
139 static SQLRETURN (*pSQLProcedures)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
140 static SQLRETURN (*pSQLProceduresW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
141 static SQLRETURN (*pSQLPutData)(SQLHSTMT,SQLPOINTER,SQLINTEGER);
142 static SQLRETURN (*pSQLRowCount)(SQLHSTMT,SQLINTEGER*);
143 static SQLRETURN (*pSQLSetConnectAttr)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER);
144 static SQLRETURN (*pSQLSetConnectAttrW)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER);
145 static SQLRETURN (*pSQLSetConnectOption)(SQLHDBC,SQLUSMALLINT,SQLUINTEGER);
146 static SQLRETURN (*pSQLSetConnectOptionW)(SQLHDBC,SQLUSMALLINT,SQLULEN);
147 static SQLRETURN (*pSQLSetCursorName)(SQLHSTMT,SQLCHAR*,SQLSMALLINT);
148 static SQLRETURN (*pSQLSetCursorNameW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT);
149 static SQLRETURN (*pSQLSetDescField)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER);
150 static SQLRETURN (*pSQLSetDescFieldW)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER);
151 static SQLRETURN (*pSQLSetDescRec)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLINTEGER,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER*,SQLINTEGER*);
152 static SQLRETURN (*pSQLSetEnvAttr)(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER);
153 static SQLRETURN (*pSQLSetParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLUINTEGER,SQLSMALLINT,SQLPOINTER,SQLINTEGER*);
154 static SQLRETURN (*pSQLSetPos)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
155 static SQLRETURN (*pSQLSetScrollOptions)(SQLHSTMT,SQLUSMALLINT,SQLINTEGER,SQLUSMALLINT);
156 static SQLRETURN (*pSQLSetStmtAttr)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER);
157 static SQLRETURN (*pSQLSetStmtAttrW)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER);
158 static SQLRETURN (*pSQLSetStmtOption)(SQLHSTMT,SQLUSMALLINT,SQLUINTEGER);
159 static SQLRETURN (*pSQLSpecialColumns)(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
160 static SQLRETURN (*pSQLSpecialColumnsW)(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
161 static SQLRETURN (*pSQLStatistics)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
162 static SQLRETURN (*pSQLStatisticsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
163 static SQLRETURN (*pSQLTablePrivileges)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
164 static SQLRETURN (*pSQLTablePrivilegesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
165 static SQLRETURN (*pSQLTables)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
166 static SQLRETURN (*pSQLTablesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
167 static SQLRETURN (*pSQLTransact)(SQLHENV,SQLHDBC,SQLUSMALLINT);
169 #define ERROR_FREE 0
170 #define ERROR_SQLERROR 1
171 #define ERROR_LIBRARY_NOT_FOUND 2
173 static void *dmHandle;
174 static int nErrorType;
176 /***********************************************************************
177 * ODBC_ReplicateODBCInstToRegistry
179 * PARAMS
181 * RETURNS
183 * Utility to ODBC_ReplicateToRegistry to replicate the drivers of the
184 * ODBCINST.INI settings
186 * The driver settings are not replicated to the registry. If we were to
187 * replicate them we would need to decide whether to replicate all settings
188 * or to do some translation; whether to remove any entries present only in
189 * the windows registry, etc.
192 static void ODBC_ReplicateODBCInstToRegistry (SQLHENV hEnv)
194 HKEY hODBCInst;
195 LONG reg_ret;
196 int success;
198 success = 0;
199 TRACE ("Driver settings are not currently replicated to the registry\n");
200 if ((reg_ret = RegCreateKeyExA (HKEY_LOCAL_MACHINE,
201 "Software\\ODBC\\ODBCINST.INI", 0, NULL,
202 REG_OPTION_NON_VOLATILE,
203 KEY_ALL_ACCESS /* a couple more than we need */, NULL,
204 &hODBCInst, NULL)) == ERROR_SUCCESS)
206 HKEY hDrivers;
207 if ((reg_ret = RegCreateKeyExA (hODBCInst, "ODBC Drivers", 0,
208 NULL, REG_OPTION_NON_VOLATILE,
209 KEY_ALL_ACCESS /* overkill */, NULL, &hDrivers, NULL))
210 == ERROR_SUCCESS)
212 SQLRETURN sql_ret;
213 SQLUSMALLINT dirn;
214 CHAR desc [256];
215 SQLSMALLINT sizedesc;
217 success = 1;
218 dirn = SQL_FETCH_FIRST;
219 while ((sql_ret = SQLDrivers (hEnv, dirn, (SQLCHAR*)desc, sizeof(desc),
220 &sizedesc, NULL, 0, NULL)) == SQL_SUCCESS ||
221 sql_ret == SQL_SUCCESS_WITH_INFO)
223 /* FIXME Do some proper handling of the SUCCESS_WITH_INFO */
224 dirn = SQL_FETCH_NEXT;
225 if (sizedesc == lstrlenA(desc))
227 HKEY hThis;
228 if ((reg_ret = RegQueryValueExA (hDrivers, desc, NULL,
229 NULL, NULL, NULL)) == ERROR_FILE_NOT_FOUND)
231 if ((reg_ret = RegSetValueExA (hDrivers, desc, 0,
232 REG_SZ, (const BYTE *)"Installed", 10)) != ERROR_SUCCESS)
234 TRACE ("Error %d replicating driver %s\n",
235 reg_ret, desc);
236 success = 0;
239 else if (reg_ret != ERROR_SUCCESS)
241 TRACE ("Error %d checking for %s in drivers\n",
242 reg_ret, desc);
243 success = 0;
245 if ((reg_ret = RegCreateKeyExA (hODBCInst, desc, 0,
246 NULL, REG_OPTION_NON_VOLATILE,
247 KEY_ALL_ACCESS, NULL, &hThis, NULL))
248 == ERROR_SUCCESS)
250 /* FIXME This is where the settings go.
251 * I suggest that if the disposition says it
252 * exists then we leave it alone. Alternatively
253 * include an extra value to flag that it is
254 * a replication of the unixODBC/iODBC/...
256 if ((reg_ret = RegCloseKey (hThis)) !=
257 ERROR_SUCCESS)
258 TRACE ("Error %d closing %s key\n", reg_ret,
259 desc);
261 else
263 TRACE ("Error %d ensuring driver key %s\n",
264 reg_ret, desc);
265 success = 0;
268 else
270 WARN ("Unusually long driver name %s not replicated\n",
271 desc);
272 success = 0;
275 if (sql_ret != SQL_NO_DATA)
277 TRACE ("Error %d enumerating drivers\n", (int)sql_ret);
278 success = 0;
280 if ((reg_ret = RegCloseKey (hDrivers)) != ERROR_SUCCESS)
282 TRACE ("Error %d closing hDrivers\n", reg_ret);
285 else
287 TRACE ("Error %d opening HKLM\\S\\O\\OI\\Drivers\n", reg_ret);
289 if ((reg_ret = RegCloseKey (hODBCInst)) != ERROR_SUCCESS)
291 TRACE ("Error %d closing HKLM\\S\\O\\ODBCINST.INI\n", reg_ret);
294 else
296 TRACE ("Error %d opening HKLM\\S\\O\\ODBCINST.INI\n", reg_ret);
298 if (!success)
300 WARN ("May not have replicated all ODBC drivers to the registry\n");
304 /***********************************************************************
305 * ODBC_ReplicateODBCToRegistry
307 * PARAMS
309 * RETURNS
311 * Utility to ODBC_ReplicateToRegistry to replicate either the USER or
312 * SYSTEM dsns
314 * For now simply place the "Driver description" (as returned by SQLDataSources)
315 * into the registry as the driver. This is enough to satisfy Crystal's
316 * requirement that there be a driver entry. (It doesn't seem to care what
317 * the setting is).
318 * A slightly more accurate setting would be to access the registry to find
319 * the actual driver library for the given description (which appears to map
320 * to one of the HKLM/Software/ODBC/ODBCINST.INI keys). (If you do this note
321 * that this will add a requirement that this function be called after
322 * ODBC_ReplicateODBCInstToRegistry)
324 static void ODBC_ReplicateODBCToRegistry (int is_user, SQLHENV hEnv)
326 HKEY hODBC;
327 LONG reg_ret;
328 SQLRETURN sql_ret;
329 SQLUSMALLINT dirn;
330 CHAR dsn [SQL_MAX_DSN_LENGTH + 1];
331 SQLSMALLINT sizedsn;
332 CHAR desc [256];
333 SQLSMALLINT sizedesc;
334 int success;
335 const char *which = is_user ? "user" : "system";
337 success = 0;
338 if ((reg_ret = RegCreateKeyExA (
339 is_user ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
340 "Software\\ODBC\\ODBC.INI", 0, NULL, REG_OPTION_NON_VOLATILE,
341 KEY_ALL_ACCESS /* a couple more than we need */, NULL, &hODBC,
342 NULL)) == ERROR_SUCCESS)
344 success = 1;
345 dirn = is_user ? SQL_FETCH_FIRST_USER : SQL_FETCH_FIRST_SYSTEM;
346 while ((sql_ret = SQLDataSources (hEnv, dirn,
347 (SQLCHAR*)dsn, sizeof(dsn), &sizedsn,
348 (SQLCHAR*)desc, sizeof(desc), &sizedesc)) == SQL_SUCCESS
349 || sql_ret == SQL_SUCCESS_WITH_INFO)
351 /* FIXME Do some proper handling of the SUCCESS_WITH_INFO */
352 dirn = SQL_FETCH_NEXT;
353 if (sizedsn == lstrlenA(dsn) && sizedesc == lstrlenA(desc))
355 HKEY hDSN;
356 if ((reg_ret = RegCreateKeyExA (hODBC, dsn, 0,
357 NULL, REG_OPTION_NON_VOLATILE,
358 KEY_ALL_ACCESS, NULL, &hDSN, NULL))
359 == ERROR_SUCCESS)
361 static const char DRIVERKEY[] = "Driver";
362 if ((reg_ret = RegQueryValueExA (hDSN, DRIVERKEY,
363 NULL, NULL, NULL, NULL))
364 == ERROR_FILE_NOT_FOUND)
366 if ((reg_ret = RegSetValueExA (hDSN, DRIVERKEY, 0,
367 REG_SZ, (LPBYTE)desc, sizedesc)) != ERROR_SUCCESS)
369 TRACE ("Error %d replicating description of "
370 "%s(%s)\n", reg_ret, dsn, desc);
371 success = 0;
374 else if (reg_ret != ERROR_SUCCESS)
376 TRACE ("Error %d checking for description of %s\n",
377 reg_ret, dsn);
378 success = 0;
380 if ((reg_ret = RegCloseKey (hDSN)) != ERROR_SUCCESS)
382 TRACE ("Error %d closing %s DSN key %s\n",
383 reg_ret, which, dsn);
386 else
388 TRACE ("Error %d opening %s DSN key %s\n",
389 reg_ret, which, dsn);
390 success = 0;
393 else
395 WARN ("Unusually long %s data source name %s (%s) not "
396 "replicated\n", which, dsn, desc);
397 success = 0;
400 if (sql_ret != SQL_NO_DATA)
402 TRACE ("Error %d enumerating %s datasources\n",
403 (int)sql_ret, which);
404 success = 0;
406 if ((reg_ret = RegCloseKey (hODBC)) != ERROR_SUCCESS)
408 TRACE ("Error %d closing %s ODBC.INI registry key\n", reg_ret,
409 which);
412 else
414 TRACE ("Error %d creating/opening %s ODBC.INI registry key\n",
415 reg_ret, which);
417 if (!success)
419 WARN ("May not have replicated all %s ODBC DSNs to the registry\n",
420 which);
424 /***********************************************************************
425 * ODBC_ReplicateToRegistry
427 * PARAMS
429 * RETURNS
431 * Unfortunately some of the functions that Windows documents as being part
432 * of the ODBC API it implements directly during compilation or something
433 * in terms of registry access functions.
434 * e.g. SQLGetInstalledDrivers queries the list at
435 * HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINST.INI\ODBC Drivers
437 * This function is called when the driver manager is loaded and is used
438 * to replicate the appropriate details into the Wine registry
441 static void ODBC_ReplicateToRegistry (void)
443 SQLRETURN sql_ret;
444 SQLHENV hEnv;
446 if ((sql_ret = SQLAllocEnv (&hEnv)) == SQL_SUCCESS)
448 ODBC_ReplicateODBCInstToRegistry (hEnv);
449 ODBC_ReplicateODBCToRegistry (0 /* system dsns */, hEnv);
450 ODBC_ReplicateODBCToRegistry (1 /* user dsns */, hEnv);
452 if ((sql_ret = SQLFreeEnv (hEnv)) != SQL_SUCCESS)
454 TRACE ("Error %d freeing the SQL environment.\n", (int)sql_ret);
457 else
459 TRACE ("Error %d opening an SQL environment.\n", (int)sql_ret);
460 WARN ("The external ODBC settings have not been replicated to the"
461 " Wine registry\n");
465 /***********************************************************************
466 * DllMain [Internal] Initializes the internal 'ODBC32.DLL'.
468 * PARAMS
469 * hinstDLL [I] handle to the DLL's instance
470 * fdwReason [I]
471 * lpvReserved [I] reserved, must be NULL
473 * RETURNS
474 * Success: TRUE
475 * Failure: FALSE
478 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
480 TRACE("Initializing or Finalizing proxy ODBC: %p,%x,%p\n", hinstDLL, fdwReason, lpvReserved);
482 if (fdwReason == DLL_PROCESS_ATTACH)
484 TRACE("Loading ODBC...\n");
485 DisableThreadLibraryCalls(hinstDLL);
486 if (ODBC_LoadDriverManager())
488 ODBC_LoadDMFunctions();
489 ODBC_ReplicateToRegistry();
492 else if (fdwReason == DLL_PROCESS_DETACH)
494 TRACE("Unloading ODBC...\n");
495 if (dmHandle)
497 wine_dlclose(dmHandle,NULL,0);
498 dmHandle = NULL;
502 return TRUE;
505 /***********************************************************************
506 * ODBC_LoadDriverManager [Internal] Load ODBC library.
508 * PARAMS
510 * RETURNS
511 * Success: TRUE
512 * Failure: FALSE
515 static BOOL ODBC_LoadDriverManager(void)
517 const char *s = getenv("LIB_ODBC_DRIVER_MANAGER");
518 char error[256];
520 TRACE("\n");
522 #ifdef SONAME_LIBODBC
523 if (!s || !s[0]) s = SONAME_LIBODBC;
524 #endif
525 if (!s || !s[0]) goto failed;
527 dmHandle = wine_dlopen(s, RTLD_LAZY | RTLD_GLOBAL, error, sizeof(error));
529 if (dmHandle != NULL)
531 nErrorType = ERROR_FREE;
532 return TRUE;
534 failed:
535 WARN("failed to open library %s: %s\n", debugstr_a(s), error);
536 nErrorType = ERROR_LIBRARY_NOT_FOUND;
537 return FALSE;
541 /***********************************************************************
542 * ODBC_LoadDMFunctions [Internal] Populate function table.
544 * PARAMS
546 * RETURNS
547 * Success: TRUE
548 * Failure: FALSE
551 static BOOL ODBC_LoadDMFunctions(void)
553 char error[256];
555 if (dmHandle == NULL)
556 return FALSE;
558 #define LOAD_FUNC(name) \
559 if ((p##name = wine_dlsym( dmHandle, #name, error, sizeof(error) ))); \
560 else WARN( "Failed to load %s: %s\n", #name, error )
562 LOAD_FUNC(SQLAllocConnect);
563 LOAD_FUNC(SQLAllocEnv);
564 LOAD_FUNC(SQLAllocHandle);
565 LOAD_FUNC(SQLAllocHandleStd);
566 LOAD_FUNC(SQLAllocStmt);
567 LOAD_FUNC(SQLBindCol);
568 LOAD_FUNC(SQLBindParam);
569 LOAD_FUNC(SQLBindParameter);
570 LOAD_FUNC(SQLBrowseConnect);
571 LOAD_FUNC(SQLBrowseConnectW);
572 LOAD_FUNC(SQLBulkOperations);
573 LOAD_FUNC(SQLCancel);
574 LOAD_FUNC(SQLCloseCursor);
575 LOAD_FUNC(SQLColAttribute);
576 LOAD_FUNC(SQLColAttributeW);
577 LOAD_FUNC(SQLColAttributes);
578 LOAD_FUNC(SQLColAttributesW);
579 LOAD_FUNC(SQLColumnPrivileges);
580 LOAD_FUNC(SQLColumnPrivilegesW);
581 LOAD_FUNC(SQLColumns);
582 LOAD_FUNC(SQLColumnsW);
583 LOAD_FUNC(SQLConnect);
584 LOAD_FUNC(SQLConnectW);
585 LOAD_FUNC(SQLCopyDesc);
586 LOAD_FUNC(SQLDataSources);
587 LOAD_FUNC(SQLDataSourcesW);
588 LOAD_FUNC(SQLDescribeCol);
589 LOAD_FUNC(SQLDescribeColW);
590 LOAD_FUNC(SQLDescribeParam);
591 LOAD_FUNC(SQLDisconnect);
592 LOAD_FUNC(SQLDriverConnect);
593 LOAD_FUNC(SQLDriverConnectW);
594 LOAD_FUNC(SQLDrivers);
595 LOAD_FUNC(SQLDriversW);
596 LOAD_FUNC(SQLEndTran);
597 LOAD_FUNC(SQLError);
598 LOAD_FUNC(SQLErrorW);
599 LOAD_FUNC(SQLExecDirect);
600 LOAD_FUNC(SQLExecDirectW);
601 LOAD_FUNC(SQLExecute);
602 LOAD_FUNC(SQLExtendedFetch);
603 LOAD_FUNC(SQLFetch);
604 LOAD_FUNC(SQLFetchScroll);
605 LOAD_FUNC(SQLForeignKeys);
606 LOAD_FUNC(SQLForeignKeysW);
607 LOAD_FUNC(SQLFreeConnect);
608 LOAD_FUNC(SQLFreeEnv);
609 LOAD_FUNC(SQLFreeHandle);
610 LOAD_FUNC(SQLFreeStmt);
611 LOAD_FUNC(SQLGetConnectAttr);
612 LOAD_FUNC(SQLGetConnectAttrW);
613 LOAD_FUNC(SQLGetConnectOption);
614 LOAD_FUNC(SQLGetConnectOptionW);
615 LOAD_FUNC(SQLGetCursorName);
616 LOAD_FUNC(SQLGetCursorNameW);
617 LOAD_FUNC(SQLGetData);
618 LOAD_FUNC(SQLGetDescField);
619 LOAD_FUNC(SQLGetDescFieldW);
620 LOAD_FUNC(SQLGetDescRec);
621 LOAD_FUNC(SQLGetDescRecW);
622 LOAD_FUNC(SQLGetDiagField);
623 LOAD_FUNC(SQLGetDiagFieldW);
624 LOAD_FUNC(SQLGetDiagRec);
625 LOAD_FUNC(SQLGetDiagRecW);
626 LOAD_FUNC(SQLGetEnvAttr);
627 LOAD_FUNC(SQLGetFunctions);
628 LOAD_FUNC(SQLGetInfo);
629 LOAD_FUNC(SQLGetInfoW);
630 LOAD_FUNC(SQLGetStmtAttr);
631 LOAD_FUNC(SQLGetStmtAttrW);
632 LOAD_FUNC(SQLGetStmtOption);
633 LOAD_FUNC(SQLGetTypeInfo);
634 LOAD_FUNC(SQLGetTypeInfoW);
635 LOAD_FUNC(SQLMoreResults);
636 LOAD_FUNC(SQLNativeSql);
637 LOAD_FUNC(SQLNativeSqlW);
638 LOAD_FUNC(SQLNumParams);
639 LOAD_FUNC(SQLNumResultCols);
640 LOAD_FUNC(SQLParamData);
641 LOAD_FUNC(SQLParamOptions);
642 LOAD_FUNC(SQLPrepare);
643 LOAD_FUNC(SQLPrepareW);
644 LOAD_FUNC(SQLPrimaryKeys);
645 LOAD_FUNC(SQLPrimaryKeysW);
646 LOAD_FUNC(SQLProcedureColumns);
647 LOAD_FUNC(SQLProcedureColumnsW);
648 LOAD_FUNC(SQLProcedures);
649 LOAD_FUNC(SQLProceduresW);
650 LOAD_FUNC(SQLPutData);
651 LOAD_FUNC(SQLRowCount);
652 LOAD_FUNC(SQLSetConnectAttr);
653 LOAD_FUNC(SQLSetConnectAttrW);
654 LOAD_FUNC(SQLSetConnectOption);
655 LOAD_FUNC(SQLSetConnectOptionW);
656 LOAD_FUNC(SQLSetCursorName);
657 LOAD_FUNC(SQLSetCursorNameW);
658 LOAD_FUNC(SQLSetDescField);
659 LOAD_FUNC(SQLSetDescFieldW);
660 LOAD_FUNC(SQLSetDescRec);
661 LOAD_FUNC(SQLSetEnvAttr);
662 LOAD_FUNC(SQLSetParam);
663 LOAD_FUNC(SQLSetPos);
664 LOAD_FUNC(SQLSetScrollOptions);
665 LOAD_FUNC(SQLSetStmtAttr);
666 LOAD_FUNC(SQLSetStmtAttrW);
667 LOAD_FUNC(SQLSetStmtOption);
668 LOAD_FUNC(SQLSpecialColumns);
669 LOAD_FUNC(SQLSpecialColumnsW);
670 LOAD_FUNC(SQLStatistics);
671 LOAD_FUNC(SQLStatisticsW);
672 LOAD_FUNC(SQLTablePrivileges);
673 LOAD_FUNC(SQLTablePrivilegesW);
674 LOAD_FUNC(SQLTables);
675 LOAD_FUNC(SQLTablesW);
676 LOAD_FUNC(SQLTransact);
677 #undef LOAD_FUNC
679 return TRUE;
683 /*************************************************************************
684 * SQLAllocConnect [ODBC32.001]
686 SQLRETURN WINAPI SQLAllocConnect(SQLHENV EnvironmentHandle, SQLHDBC *ConnectionHandle)
688 SQLRETURN ret;
689 TRACE("Env=%lx\n",EnvironmentHandle);
691 if (!pSQLAllocConnect)
693 *ConnectionHandle = SQL_NULL_HDBC;
694 TRACE("Not ready\n");
695 return SQL_ERROR;
698 ret = pSQLAllocConnect(EnvironmentHandle, ConnectionHandle);
699 TRACE("Returns ret=%d, Handle %lx\n",ret, *ConnectionHandle);
700 return ret;
704 /*************************************************************************
705 * SQLAllocEnv [ODBC32.002]
707 SQLRETURN WINAPI SQLAllocEnv(SQLHENV *EnvironmentHandle)
709 SQLRETURN ret;
710 TRACE("\n");
712 if (!pSQLAllocEnv)
714 *EnvironmentHandle = SQL_NULL_HENV;
715 TRACE("Not ready\n");
716 return SQL_ERROR;
719 ret = pSQLAllocEnv(EnvironmentHandle);
720 TRACE("Returns ret=%d, Env=%lx\n",ret, *EnvironmentHandle);
721 return ret;
725 /*************************************************************************
726 * SQLAllocHandle [ODBC32.024]
728 SQLRETURN WINAPI SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, SQLHANDLE *OutputHandle)
730 SQLRETURN ret;
731 TRACE("(Type=%d, Handle=%lx)\n",HandleType,InputHandle);
733 if (!pSQLAllocHandle)
735 if (nErrorType == ERROR_LIBRARY_NOT_FOUND)
736 WARN("ProxyODBC: Cannot load ODBC driver manager library.\n");
738 if (HandleType == SQL_HANDLE_ENV)
739 *OutputHandle = SQL_NULL_HENV;
740 else if (HandleType == SQL_HANDLE_DBC)
741 *OutputHandle = SQL_NULL_HDBC;
742 else if (HandleType == SQL_HANDLE_STMT)
743 *OutputHandle = SQL_NULL_HSTMT;
744 else if (HandleType == SQL_HANDLE_DESC)
745 *OutputHandle = SQL_NULL_HDESC;
747 TRACE ("Not ready\n");
748 return SQL_ERROR;
751 ret = pSQLAllocHandle(HandleType, InputHandle, OutputHandle);
752 TRACE("Returns ret=%d, Handle=%lx\n",ret, *OutputHandle);
753 return ret;
757 /*************************************************************************
758 * SQLAllocStmt [ODBC32.003]
760 SQLRETURN WINAPI SQLAllocStmt(SQLHDBC ConnectionHandle, SQLHSTMT *StatementHandle)
762 SQLRETURN ret;
764 TRACE("(Connection=%lx)\n",ConnectionHandle);
766 if (!pSQLAllocStmt)
768 *StatementHandle = SQL_NULL_HSTMT;
769 TRACE ("Not ready\n");
770 return SQL_ERROR;
773 ret = pSQLAllocStmt(ConnectionHandle, StatementHandle);
774 TRACE ("Returns ret=%d, Handle=%lx\n", ret, *StatementHandle);
775 return ret;
779 /*************************************************************************
780 * SQLAllocHandleStd [ODBC32.077]
782 SQLRETURN WINAPI SQLAllocHandleStd( SQLSMALLINT HandleType,
783 SQLHANDLE InputHandle, SQLHANDLE *OutputHandle)
785 TRACE("ProxyODBC: SQLAllocHandleStd.\n");
787 if (!pSQLAllocHandleStd)
789 if (nErrorType == ERROR_LIBRARY_NOT_FOUND)
790 WARN("ProxyODBC: Cannot load ODBC driver manager library.\n");
792 if (HandleType == SQL_HANDLE_ENV)
793 *OutputHandle = SQL_NULL_HENV;
794 else if (HandleType == SQL_HANDLE_DBC)
795 *OutputHandle = SQL_NULL_HDBC;
796 else if (HandleType == SQL_HANDLE_STMT)
797 *OutputHandle = SQL_NULL_HSTMT;
798 else if (HandleType == SQL_HANDLE_DESC)
799 *OutputHandle = SQL_NULL_HDESC;
801 return SQL_ERROR;
804 return pSQLAllocHandleStd(HandleType, InputHandle, OutputHandle);
808 /*************************************************************************
809 * SQLBindCol [ODBC32.004]
811 SQLRETURN WINAPI SQLBindCol(SQLHSTMT StatementHandle,
812 SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
813 SQLPOINTER TargetValue, SQLINTEGER BufferLength,
814 SQLINTEGER *StrLen_or_Ind)
816 TRACE("\n");
818 if (!pSQLBindCol)
820 TRACE ("Not ready\n");
821 return SQL_ERROR;
824 return pSQLBindCol(StatementHandle, ColumnNumber, TargetType,
825 TargetValue, BufferLength, StrLen_or_Ind);
829 /*************************************************************************
830 * SQLBindParam [ODBC32.025]
832 SQLRETURN WINAPI SQLBindParam(SQLHSTMT StatementHandle,
833 SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
834 SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision,
835 SQLSMALLINT ParameterScale, SQLPOINTER ParameterValue,
836 SQLINTEGER *StrLen_or_Ind)
838 TRACE("\n");
840 if (!pSQLBindParam) return SQL_ERROR;
841 return pSQLBindParam(StatementHandle, ParameterNumber, ValueType,
842 ParameterType, LengthPrecision, ParameterScale,
843 ParameterValue, StrLen_or_Ind);
847 /*************************************************************************
848 * SQLCancel [ODBC32.005]
850 SQLRETURN WINAPI SQLCancel(SQLHSTMT StatementHandle)
852 TRACE("\n");
854 if (!pSQLCancel) return SQL_ERROR;
855 return pSQLCancel(StatementHandle);
859 /*************************************************************************
860 * SQLCloseCursor [ODBC32.026]
862 SQLRETURN WINAPI SQLCloseCursor(SQLHSTMT StatementHandle)
864 SQLRETURN ret;
865 TRACE("(Handle=%lx)\n",StatementHandle);
867 if (!pSQLCloseCursor) return SQL_ERROR;
869 ret = pSQLCloseCursor(StatementHandle);
870 TRACE("returns %d\n",ret);
871 return ret;
875 /*************************************************************************
876 * SQLColAttribute [ODBC32.027]
878 SQLRETURN WINAPI SQLColAttribute (SQLHSTMT StatementHandle,
879 SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
880 SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength,
881 SQLSMALLINT *StringLength, SQLPOINTER NumericAttribute)
883 TRACE("\n");
885 if (!pSQLColAttribute) return SQL_ERROR;
886 return pSQLColAttribute(StatementHandle, ColumnNumber, FieldIdentifier,
887 CharacterAttribute, BufferLength, StringLength, NumericAttribute);
891 /*************************************************************************
892 * SQLColumns [ODBC32.040]
894 SQLRETURN WINAPI SQLColumns(SQLHSTMT StatementHandle,
895 SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
896 SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
897 SQLCHAR *TableName, SQLSMALLINT NameLength3,
898 SQLCHAR *ColumnName, SQLSMALLINT NameLength4)
900 TRACE("\n");
902 if (!pSQLColumns) return SQL_ERROR;
903 return pSQLColumns(StatementHandle, CatalogName, NameLength1,
904 SchemaName, NameLength2, TableName, NameLength3, ColumnName, NameLength4);
908 /*************************************************************************
909 * SQLConnect [ODBC32.007]
911 SQLRETURN WINAPI SQLConnect(SQLHDBC ConnectionHandle,
912 SQLCHAR *ServerName, SQLSMALLINT NameLength1,
913 SQLCHAR *UserName, SQLSMALLINT NameLength2,
914 SQLCHAR *Authentication, SQLSMALLINT NameLength3)
916 SQLRETURN ret;
917 TRACE("(Server=%.*s)\n",NameLength1, ServerName);
919 if (!pSQLConnect) return SQL_ERROR;
921 ret = pSQLConnect(ConnectionHandle, ServerName, NameLength1,
922 UserName, NameLength2, Authentication, NameLength3);
924 TRACE("returns %d\n",ret);
925 return ret;
929 /*************************************************************************
930 * SQLCopyDesc [ODBC32.028]
932 SQLRETURN WINAPI SQLCopyDesc(SQLHDESC SourceDescHandle, SQLHDESC TargetDescHandle)
934 TRACE("\n");
936 if (!pSQLCopyDesc) return SQL_ERROR;
937 return pSQLCopyDesc(SourceDescHandle, TargetDescHandle);
941 /*************************************************************************
942 * SQLDataSources [ODBC32.057]
944 SQLRETURN WINAPI SQLDataSources(SQLHENV EnvironmentHandle,
945 SQLUSMALLINT Direction, SQLCHAR *ServerName,
946 SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
947 SQLCHAR *Description, SQLSMALLINT BufferLength2,
948 SQLSMALLINT *NameLength2)
950 SQLRETURN ret;
952 TRACE("EnvironmentHandle = %p\n", (LPVOID)EnvironmentHandle);
954 if (!pSQLDataSources) return SQL_ERROR;
956 ret = pSQLDataSources(EnvironmentHandle, Direction, ServerName,
957 BufferLength1, NameLength1, Description, BufferLength2, NameLength2);
959 if (TRACE_ON(odbc))
961 TRACE("returns: %d \t", ret);
962 if (NameLength1 && *NameLength1 > 0)
963 TRACE("DataSource = %s,", ServerName);
964 if (NameLength2 && *NameLength2 > 0)
965 TRACE(" Description = %s", Description);
966 TRACE("\n");
969 return ret;
973 /*************************************************************************
974 * SQLDescribeCol [ODBC32.008]
976 SQLRETURN WINAPI SQLDescribeCol(SQLHSTMT StatementHandle,
977 SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName,
978 SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
979 SQLSMALLINT *DataType, SQLUINTEGER *ColumnSize,
980 SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
982 TRACE("\n");
984 if (!pSQLDescribeCol) return SQL_ERROR;
985 return pSQLDescribeCol(StatementHandle, ColumnNumber, ColumnName,
986 BufferLength, NameLength, DataType, ColumnSize, DecimalDigits, Nullable);
990 /*************************************************************************
991 * SQLDisconnect [ODBC32.009]
993 SQLRETURN WINAPI SQLDisconnect(SQLHDBC ConnectionHandle)
995 SQLRETURN ret;
996 TRACE("(Handle=%lx)\n", ConnectionHandle);
998 if (!pSQLDisconnect) return SQL_ERROR;
1000 ret = pSQLDisconnect(ConnectionHandle);
1001 TRACE("returns %d\n",ret);
1002 return ret;
1006 /*************************************************************************
1007 * SQLEndTran [ODBC32.029]
1009 SQLRETURN WINAPI SQLEndTran(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT CompletionType)
1011 TRACE("\n");
1013 if (!pSQLEndTran) return SQL_ERROR;
1014 return pSQLEndTran(HandleType, Handle, CompletionType);
1018 /*************************************************************************
1019 * SQLError [ODBC32.010]
1021 SQLRETURN WINAPI SQLError(SQLHENV EnvironmentHandle,
1022 SQLHDBC ConnectionHandle, SQLHSTMT StatementHandle,
1023 SQLCHAR *Sqlstate, SQLINTEGER *NativeError,
1024 SQLCHAR *MessageText, SQLSMALLINT BufferLength,
1025 SQLSMALLINT *TextLength)
1027 TRACE("\n");
1029 if (!pSQLError) return SQL_ERROR;
1030 return pSQLError(EnvironmentHandle, ConnectionHandle, StatementHandle,
1031 Sqlstate, NativeError, MessageText, BufferLength, TextLength);
1035 /*************************************************************************
1036 * SQLExecDirect [ODBC32.011]
1038 SQLRETURN WINAPI SQLExecDirect(SQLHSTMT StatementHandle, SQLCHAR *StatementText, SQLINTEGER TextLength)
1040 TRACE("\n");
1042 if (!pSQLExecDirect) return SQL_ERROR;
1043 return pSQLExecDirect(StatementHandle, StatementText, TextLength);
1047 /*************************************************************************
1048 * SQLExecute [ODBC32.012]
1050 SQLRETURN WINAPI SQLExecute(SQLHSTMT StatementHandle)
1052 TRACE("\n");
1054 if (!pSQLExecute) return SQL_ERROR;
1055 return pSQLExecute(StatementHandle);
1059 /*************************************************************************
1060 * SQLFetch [ODBC32.013]
1062 SQLRETURN WINAPI SQLFetch(SQLHSTMT StatementHandle)
1064 TRACE("\n");
1066 if (!pSQLFetch) return SQL_ERROR;
1067 return pSQLFetch(StatementHandle);
1071 /*************************************************************************
1072 * SQLFetchScroll [ODBC32.030]
1074 SQLRETURN WINAPI SQLFetchScroll(SQLHSTMT StatementHandle, SQLSMALLINT FetchOrientation, SQLINTEGER FetchOffset)
1076 TRACE("\n");
1078 if (!pSQLFetchScroll) return SQL_ERROR;
1079 return pSQLFetchScroll(StatementHandle, FetchOrientation, FetchOffset);
1083 /*************************************************************************
1084 * SQLFreeConnect [ODBC32.014]
1086 SQLRETURN WINAPI SQLFreeConnect(SQLHDBC ConnectionHandle)
1088 SQLRETURN ret;
1089 TRACE("(Handle=%lx)\n",ConnectionHandle);
1091 if (!pSQLFreeConnect) return SQL_ERROR;
1093 ret = pSQLFreeConnect(ConnectionHandle);
1094 TRACE("Returns %d\n",ret);
1095 return ret;
1099 /*************************************************************************
1100 * SQLFreeEnv [ODBC32.015]
1102 SQLRETURN WINAPI SQLFreeEnv(SQLHENV EnvironmentHandle)
1104 SQLRETURN ret;
1105 TRACE("(Env=%lx)\n",EnvironmentHandle);
1107 if (!pSQLFreeEnv) return SQL_ERROR;
1109 ret = pSQLFreeEnv(EnvironmentHandle);
1110 TRACE("Returns %d\n",ret);
1111 return ret;
1115 /*************************************************************************
1116 * SQLFreeHandle [ODBC32.031]
1118 SQLRETURN WINAPI SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle)
1120 SQLRETURN ret;
1121 TRACE("(Type=%d, Handle=%lx)\n",HandleType,Handle);
1123 if (!pSQLFreeHandle) return SQL_ERROR;
1125 ret = pSQLFreeHandle(HandleType, Handle);
1126 TRACE ("Returns %d\n",ret);
1127 return ret;
1131 /*************************************************************************
1132 * SQLFreeStmt [ODBC32.016]
1134 SQLRETURN WINAPI SQLFreeStmt(SQLHSTMT StatementHandle, SQLUSMALLINT Option)
1136 SQLRETURN ret;
1137 TRACE("(Handle %lx, Option=%d)\n",StatementHandle, Option);
1139 if (!pSQLFreeStmt) return SQL_ERROR;
1141 ret = pSQLFreeStmt(StatementHandle, Option);
1142 TRACE("Returns %d\n",ret);
1143 return ret;
1147 /*************************************************************************
1148 * SQLGetConnectAttr [ODBC32.032]
1150 SQLRETURN WINAPI SQLGetConnectAttr(SQLHDBC ConnectionHandle,
1151 SQLINTEGER Attribute, SQLPOINTER Value,
1152 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
1154 TRACE("\n");
1156 if (!pSQLGetConnectAttr) return SQL_ERROR;
1157 return pSQLGetConnectAttr(ConnectionHandle, Attribute, Value,
1158 BufferLength, StringLength);
1162 /*************************************************************************
1163 * SQLGetConnectOption [ODBC32.042]
1165 SQLRETURN WINAPI SQLGetConnectOption(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLPOINTER Value)
1167 TRACE("\n");
1169 if (!pSQLGetConnectOption) return SQL_ERROR;
1170 return pSQLGetConnectOption(ConnectionHandle, Option, Value);
1174 /*************************************************************************
1175 * SQLGetCursorName [ODBC32.017]
1177 SQLRETURN WINAPI SQLGetCursorName(SQLHSTMT StatementHandle,
1178 SQLCHAR *CursorName, SQLSMALLINT BufferLength,
1179 SQLSMALLINT *NameLength)
1181 TRACE("\n");
1183 if (!pSQLGetCursorName) return SQL_ERROR;
1184 return pSQLGetCursorName(StatementHandle, CursorName, BufferLength, NameLength);
1188 /*************************************************************************
1189 * SQLGetData [ODBC32.043]
1191 SQLRETURN WINAPI SQLGetData(SQLHSTMT StatementHandle,
1192 SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
1193 SQLPOINTER TargetValue, SQLINTEGER BufferLength,
1194 SQLINTEGER *StrLen_or_Ind)
1196 TRACE("\n");
1198 if (!pSQLGetData) return SQL_ERROR;
1199 return pSQLGetData(StatementHandle, ColumnNumber, TargetType,
1200 TargetValue, BufferLength, StrLen_or_Ind);
1204 /*************************************************************************
1205 * SQLGetDescField [ODBC32.033]
1207 SQLRETURN WINAPI SQLGetDescField(SQLHDESC DescriptorHandle,
1208 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
1209 SQLPOINTER Value, SQLINTEGER BufferLength,
1210 SQLINTEGER *StringLength)
1212 TRACE("\n");
1214 if (!pSQLGetDescField) return SQL_ERROR;
1215 return pSQLGetDescField(DescriptorHandle, RecNumber, FieldIdentifier,
1216 Value, BufferLength, StringLength);
1220 /*************************************************************************
1221 * SQLGetDescRec [ODBC32.034]
1223 SQLRETURN WINAPI SQLGetDescRec(SQLHDESC DescriptorHandle,
1224 SQLSMALLINT RecNumber, SQLCHAR *Name,
1225 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
1226 SQLSMALLINT *Type, SQLSMALLINT *SubType,
1227 SQLINTEGER *Length, SQLSMALLINT *Precision,
1228 SQLSMALLINT *Scale, SQLSMALLINT *Nullable)
1230 TRACE("\n");
1232 if (!pSQLGetDescRec) return SQL_ERROR;
1233 return pSQLGetDescRec(DescriptorHandle, RecNumber, Name, BufferLength,
1234 StringLength, Type, SubType, Length, Precision, Scale, Nullable);
1238 /*************************************************************************
1239 * SQLGetDiagField [ODBC32.035]
1241 SQLRETURN WINAPI SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle,
1242 SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier,
1243 SQLPOINTER DiagInfo, SQLSMALLINT BufferLength,
1244 SQLSMALLINT *StringLength)
1246 TRACE("\n");
1248 if (!pSQLGetDiagField) return SQL_ERROR;
1249 return pSQLGetDiagField(HandleType, Handle, RecNumber, DiagIdentifier,
1250 DiagInfo, BufferLength, StringLength);
1254 /*************************************************************************
1255 * SQLGetDiagRec [ODBC32.036]
1257 SQLRETURN WINAPI SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle,
1258 SQLSMALLINT RecNumber, SQLCHAR *Sqlstate,
1259 SQLINTEGER *NativeError, SQLCHAR *MessageText,
1260 SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
1262 TRACE("\n");
1264 if (!pSQLGetDiagRec) return SQL_ERROR;
1265 return pSQLGetDiagRec(HandleType, Handle, RecNumber, Sqlstate, NativeError,
1266 MessageText, BufferLength, TextLength);
1270 /*************************************************************************
1271 * SQLGetEnvAttr [ODBC32.037]
1273 SQLRETURN WINAPI SQLGetEnvAttr(SQLHENV EnvironmentHandle,
1274 SQLINTEGER Attribute, SQLPOINTER Value,
1275 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
1277 TRACE("\n");
1279 if (!pSQLGetEnvAttr) return SQL_ERROR;
1280 return pSQLGetEnvAttr(EnvironmentHandle, Attribute, Value, BufferLength, StringLength);
1284 /*************************************************************************
1285 * SQLGetFunctions [ODBC32.044]
1287 SQLRETURN WINAPI SQLGetFunctions(SQLHDBC ConnectionHandle, SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported)
1289 TRACE("\n");
1291 if (!pSQLGetFunctions) return SQL_ERROR;
1292 return pSQLGetFunctions(ConnectionHandle, FunctionId, Supported);
1296 /*************************************************************************
1297 * SQLGetInfo [ODBC32.045]
1299 SQLRETURN WINAPI SQLGetInfo(SQLHDBC ConnectionHandle,
1300 SQLUSMALLINT InfoType, SQLPOINTER InfoValue,
1301 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
1303 TRACE("\n");
1305 if (!pSQLGetInfo) return SQL_ERROR;
1306 return pSQLGetInfo(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLength);
1310 /*************************************************************************
1311 * SQLGetStmtAttr [ODBC32.038]
1313 SQLRETURN WINAPI SQLGetStmtAttr(SQLHSTMT StatementHandle,
1314 SQLINTEGER Attribute, SQLPOINTER Value,
1315 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
1317 TRACE("\n");
1319 if (!pSQLGetStmtAttr) return SQL_ERROR;
1320 return pSQLGetStmtAttr(StatementHandle, Attribute, Value, BufferLength, StringLength);
1324 /*************************************************************************
1325 * SQLGetStmtOption [ODBC32.046]
1327 SQLRETURN WINAPI SQLGetStmtOption(SQLHSTMT StatementHandle, SQLUSMALLINT Option, SQLPOINTER Value)
1329 TRACE("\n");
1331 if (!pSQLGetStmtOption) return SQL_ERROR;
1332 return pSQLGetStmtOption(StatementHandle, Option, Value);
1336 /*************************************************************************
1337 * SQLGetTypeInfo [ODBC32.047]
1339 SQLRETURN WINAPI SQLGetTypeInfo(SQLHSTMT StatementHandle, SQLSMALLINT DataType)
1341 TRACE("\n");
1343 if (!pSQLGetTypeInfo) return SQL_ERROR;
1344 return pSQLGetTypeInfo(StatementHandle, DataType);
1348 /*************************************************************************
1349 * SQLNumResultCols [ODBC32.018]
1351 SQLRETURN WINAPI SQLNumResultCols(SQLHSTMT StatementHandle, SQLSMALLINT *ColumnCount)
1353 TRACE("\n");
1355 if (!pSQLNumResultCols) return SQL_ERROR;
1356 return pSQLNumResultCols(StatementHandle, ColumnCount);
1360 /*************************************************************************
1361 * SQLParamData [ODBC32.048]
1363 SQLRETURN WINAPI SQLParamData(SQLHSTMT StatementHandle, SQLPOINTER *Value)
1365 TRACE("\n");
1367 if (!pSQLParamData) return SQL_ERROR;
1368 return pSQLParamData(StatementHandle, Value);
1372 /*************************************************************************
1373 * SQLPrepare [ODBC32.019]
1375 SQLRETURN WINAPI SQLPrepare(SQLHSTMT StatementHandle, SQLCHAR *StatementText, SQLINTEGER TextLength)
1377 TRACE("\n");
1379 if (!pSQLPrepare) return SQL_ERROR;
1380 return pSQLPrepare(StatementHandle, StatementText, TextLength);
1384 /*************************************************************************
1385 * SQLPutData [ODBC32.049]
1387 SQLRETURN WINAPI SQLPutData(SQLHSTMT StatementHandle, SQLPOINTER Data, SQLINTEGER StrLen_or_Ind)
1389 TRACE("\n");
1391 if (!pSQLPutData) return SQL_ERROR;
1392 return pSQLPutData(StatementHandle, Data, StrLen_or_Ind);
1396 /*************************************************************************
1397 * SQLRowCount [ODBC32.020]
1399 SQLRETURN WINAPI SQLRowCount(SQLHSTMT StatementHandle, SQLINTEGER *RowCount)
1401 TRACE("\n");
1403 if (!pSQLRowCount) return SQL_ERROR;
1404 return pSQLRowCount(StatementHandle, RowCount);
1408 /*************************************************************************
1409 * SQLSetConnectAttr [ODBC32.039]
1411 SQLRETURN WINAPI SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribute,
1412 SQLPOINTER Value, SQLINTEGER StringLength)
1414 TRACE("\n");
1416 if (!pSQLSetConnectAttr) return SQL_ERROR;
1417 return pSQLSetConnectAttr(ConnectionHandle, Attribute, Value, StringLength);
1421 /*************************************************************************
1422 * SQLSetConnectOption [ODBC32.050]
1424 SQLRETURN WINAPI SQLSetConnectOption(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLUINTEGER Value)
1426 TRACE("\n");
1428 if (!pSQLSetConnectOption) return SQL_ERROR;
1429 return pSQLSetConnectOption(ConnectionHandle, Option, Value);
1433 /*************************************************************************
1434 * SQLSetCursorName [ODBC32.021]
1436 SQLRETURN WINAPI SQLSetCursorName(SQLHSTMT StatementHandle, SQLCHAR *CursorName, SQLSMALLINT NameLength)
1438 TRACE("\n");
1440 if (!pSQLSetCursorName) return SQL_ERROR;
1441 return pSQLSetCursorName(StatementHandle, CursorName, NameLength);
1445 /*************************************************************************
1446 * SQLSetDescField [ODBC32.073]
1448 SQLRETURN WINAPI SQLSetDescField(SQLHDESC DescriptorHandle,
1449 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
1450 SQLPOINTER Value, SQLINTEGER BufferLength)
1452 TRACE("\n");
1454 if (!pSQLSetDescField) return SQL_ERROR;
1455 return pSQLSetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength);
1459 /*************************************************************************
1460 * SQLSetDescRec [ODBC32.074]
1462 SQLRETURN WINAPI SQLSetDescRec(SQLHDESC DescriptorHandle,
1463 SQLSMALLINT RecNumber, SQLSMALLINT Type,
1464 SQLSMALLINT SubType, SQLINTEGER Length,
1465 SQLSMALLINT Precision, SQLSMALLINT Scale,
1466 SQLPOINTER Data, SQLINTEGER *StringLength,
1467 SQLINTEGER *Indicator)
1469 TRACE("\n");
1471 if (!pSQLSetDescRec) return SQL_ERROR;
1472 return pSQLSetDescRec(DescriptorHandle, RecNumber, Type, SubType, Length,
1473 Precision, Scale, Data, StringLength, Indicator);
1477 /*************************************************************************
1478 * SQLSetEnvAttr [ODBC32.075]
1480 SQLRETURN WINAPI SQLSetEnvAttr(SQLHENV EnvironmentHandle,
1481 SQLINTEGER Attribute, SQLPOINTER Value,
1482 SQLINTEGER StringLength)
1484 TRACE("\n");
1486 if (!pSQLSetEnvAttr) return SQL_ERROR;
1487 return pSQLSetEnvAttr(EnvironmentHandle, Attribute, Value, StringLength);
1491 /*************************************************************************
1492 * SQLSetParam [ODBC32.022]
1494 SQLRETURN WINAPI SQLSetParam(SQLHSTMT StatementHandle,
1495 SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
1496 SQLSMALLINT ParameterType, SQLUINTEGER LengthPrecision,
1497 SQLSMALLINT ParameterScale, SQLPOINTER ParameterValue,
1498 SQLINTEGER *StrLen_or_Ind)
1500 TRACE("\n");
1502 if (!pSQLSetParam) return SQL_ERROR;
1503 return pSQLSetParam(StatementHandle, ParameterNumber, ValueType, ParameterType, LengthPrecision,
1504 ParameterScale, ParameterValue, StrLen_or_Ind);
1508 /*************************************************************************
1509 * SQLSetStmtAttr [ODBC32.076]
1511 SQLRETURN WINAPI SQLSetStmtAttr(SQLHSTMT StatementHandle,
1512 SQLINTEGER Attribute, SQLPOINTER Value,
1513 SQLINTEGER StringLength)
1515 TRACE("\n");
1517 if (!pSQLSetStmtAttr) return SQL_ERROR;
1518 return pSQLSetStmtAttr(StatementHandle, Attribute, Value, StringLength);
1522 /*************************************************************************
1523 * SQLSetStmtOption [ODBC32.051]
1525 SQLRETURN WINAPI SQLSetStmtOption(SQLHSTMT StatementHandle, SQLUSMALLINT Option, SQLUINTEGER Value)
1527 TRACE("\n");
1529 if (!pSQLSetStmtOption) return SQL_ERROR;
1530 return pSQLSetStmtOption(StatementHandle, Option, Value);
1534 /*************************************************************************
1535 * SQLSpecialColumns [ODBC32.052]
1537 SQLRETURN WINAPI SQLSpecialColumns(SQLHSTMT StatementHandle,
1538 SQLUSMALLINT IdentifierType, SQLCHAR *CatalogName,
1539 SQLSMALLINT NameLength1, SQLCHAR *SchemaName,
1540 SQLSMALLINT NameLength2, SQLCHAR *TableName,
1541 SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
1542 SQLUSMALLINT Nullable)
1545 if (!pSQLSpecialColumns) return SQL_ERROR;
1546 return pSQLSpecialColumns(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName,
1547 NameLength2, TableName, NameLength3, Scope, Nullable);
1551 /*************************************************************************
1552 * SQLStatistics [ODBC32.053]
1554 SQLRETURN WINAPI SQLStatistics(SQLHSTMT StatementHandle,
1555 SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
1556 SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
1557 SQLCHAR *TableName, SQLSMALLINT NameLength3,
1558 SQLUSMALLINT Unique, SQLUSMALLINT Reserved)
1560 TRACE("\n");
1562 if (!pSQLStatistics) return SQL_ERROR;
1563 return pSQLStatistics(StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2,
1564 TableName, NameLength3, Unique, Reserved);
1568 /*************************************************************************
1569 * SQLTables [ODBC32.054]
1571 SQLRETURN WINAPI SQLTables(SQLHSTMT StatementHandle,
1572 SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
1573 SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
1574 SQLCHAR *TableName, SQLSMALLINT NameLength3,
1575 SQLCHAR *TableType, SQLSMALLINT NameLength4)
1577 TRACE("\n");
1579 if (!pSQLTables) return SQL_ERROR;
1580 return pSQLTables(StatementHandle, CatalogName, NameLength1,
1581 SchemaName, NameLength2, TableName, NameLength3, TableType, NameLength4);
1585 /*************************************************************************
1586 * SQLTransact [ODBC32.023]
1588 SQLRETURN WINAPI SQLTransact(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle,
1589 SQLUSMALLINT CompletionType)
1591 TRACE("\n");
1593 if (!pSQLTransact) return SQL_ERROR;
1594 return pSQLTransact(EnvironmentHandle, ConnectionHandle, CompletionType);
1598 /*************************************************************************
1599 * SQLBrowseConnect [ODBC32.055]
1601 SQLRETURN WINAPI SQLBrowseConnect(
1602 SQLHDBC hdbc,
1603 SQLCHAR *szConnStrIn,
1604 SQLSMALLINT cbConnStrIn,
1605 SQLCHAR *szConnStrOut,
1606 SQLSMALLINT cbConnStrOutMax,
1607 SQLSMALLINT *pcbConnStrOut)
1609 TRACE("\n");
1611 if (!pSQLBrowseConnect) return SQL_ERROR;
1612 return pSQLBrowseConnect(hdbc, szConnStrIn, cbConnStrIn, szConnStrOut, cbConnStrOutMax, pcbConnStrOut);
1616 /*************************************************************************
1617 * SQLBulkOperations [ODBC32.078]
1619 SQLRETURN WINAPI SQLBulkOperations(
1620 SQLHSTMT StatementHandle,
1621 SQLSMALLINT Operation)
1623 TRACE("\n");
1625 if (!pSQLBulkOperations) return SQL_ERROR;
1626 return pSQLBulkOperations(StatementHandle, Operation);
1630 /*************************************************************************
1631 * SQLColAttributes [ODBC32.006]
1633 SQLRETURN WINAPI SQLColAttributes(
1634 SQLHSTMT hstmt,
1635 SQLUSMALLINT icol,
1636 SQLUSMALLINT fDescType,
1637 SQLPOINTER rgbDesc,
1638 SQLSMALLINT cbDescMax,
1639 SQLSMALLINT *pcbDesc,
1640 SQLINTEGER *pfDesc)
1642 TRACE("\n");
1644 if (!pSQLColAttributes) return SQL_ERROR;
1645 return pSQLColAttributes(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
1649 /*************************************************************************
1650 * SQLColumnPrivileges [ODBC32.056]
1652 SQLRETURN WINAPI SQLColumnPrivileges(
1653 SQLHSTMT hstmt,
1654 SQLCHAR *szCatalogName,
1655 SQLSMALLINT cbCatalogName,
1656 SQLCHAR *szSchemaName,
1657 SQLSMALLINT cbSchemaName,
1658 SQLCHAR *szTableName,
1659 SQLSMALLINT cbTableName,
1660 SQLCHAR *szColumnName,
1661 SQLSMALLINT cbColumnName)
1663 TRACE("\n");
1665 if (!pSQLColumnPrivileges) return SQL_ERROR;
1666 return pSQLColumnPrivileges(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1667 szTableName, cbTableName, szColumnName, cbColumnName);
1671 /*************************************************************************
1672 * SQLDescribeParam [ODBC32.058]
1674 SQLRETURN WINAPI SQLDescribeParam(
1675 SQLHSTMT hstmt,
1676 SQLUSMALLINT ipar,
1677 SQLSMALLINT *pfSqlType,
1678 SQLUINTEGER *pcbParamDef,
1679 SQLSMALLINT *pibScale,
1680 SQLSMALLINT *pfNullable)
1682 TRACE("\n");
1684 if (!pSQLDescribeParam) return SQL_ERROR;
1685 return pSQLDescribeParam(hstmt, ipar, pfSqlType, pcbParamDef, pibScale, pfNullable);
1689 /*************************************************************************
1690 * SQLExtendedFetch [ODBC32.059]
1692 SQLRETURN WINAPI SQLExtendedFetch(
1693 SQLHSTMT hstmt,
1694 SQLUSMALLINT fFetchType,
1695 SQLINTEGER irow,
1696 SQLUINTEGER *pcrow,
1697 SQLUSMALLINT *rgfRowStatus)
1699 TRACE("\n");
1701 if (!pSQLExtendedFetch) return SQL_ERROR;
1702 return pSQLExtendedFetch(hstmt, fFetchType, irow, pcrow, rgfRowStatus);
1706 /*************************************************************************
1707 * SQLForeignKeys [ODBC32.060]
1709 SQLRETURN WINAPI SQLForeignKeys(
1710 SQLHSTMT hstmt,
1711 SQLCHAR *szPkCatalogName,
1712 SQLSMALLINT cbPkCatalogName,
1713 SQLCHAR *szPkSchemaName,
1714 SQLSMALLINT cbPkSchemaName,
1715 SQLCHAR *szPkTableName,
1716 SQLSMALLINT cbPkTableName,
1717 SQLCHAR *szFkCatalogName,
1718 SQLSMALLINT cbFkCatalogName,
1719 SQLCHAR *szFkSchemaName,
1720 SQLSMALLINT cbFkSchemaName,
1721 SQLCHAR *szFkTableName,
1722 SQLSMALLINT cbFkTableName)
1724 TRACE("\n");
1726 if (!pSQLForeignKeys) return SQL_ERROR;
1727 return pSQLForeignKeys(hstmt, szPkCatalogName, cbPkCatalogName, szPkSchemaName, cbPkSchemaName,
1728 szPkTableName, cbPkTableName, szFkCatalogName, cbFkCatalogName,
1729 szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName);
1733 /*************************************************************************
1734 * SQLMoreResults [ODBC32.061]
1736 SQLRETURN WINAPI SQLMoreResults(SQLHSTMT hstmt)
1738 TRACE("\n");
1740 if (!pSQLMoreResults) return SQL_ERROR;
1741 return pSQLMoreResults(hstmt);
1745 /*************************************************************************
1746 * SQLNativeSql [ODBC32.062]
1748 SQLRETURN WINAPI SQLNativeSql(
1749 SQLHDBC hdbc,
1750 SQLCHAR *szSqlStrIn,
1751 SQLINTEGER cbSqlStrIn,
1752 SQLCHAR *szSqlStr,
1753 SQLINTEGER cbSqlStrMax,
1754 SQLINTEGER *pcbSqlStr)
1756 TRACE("\n");
1758 if (!pSQLNativeSql) return SQL_ERROR;
1759 return pSQLNativeSql(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr);
1763 /*************************************************************************
1764 * SQLNumParams [ODBC32.063]
1766 SQLRETURN WINAPI SQLNumParams(
1767 SQLHSTMT hstmt,
1768 SQLSMALLINT *pcpar)
1770 TRACE("\n");
1772 if (!pSQLNumParams) return SQL_ERROR;
1773 return pSQLNumParams(hstmt, pcpar);
1777 /*************************************************************************
1778 * SQLParamOptions [ODBC32.064]
1780 SQLRETURN WINAPI SQLParamOptions(
1781 SQLHSTMT hstmt,
1782 SQLUINTEGER crow,
1783 SQLUINTEGER *pirow)
1785 TRACE("\n");
1787 if (!pSQLParamOptions) return SQL_ERROR;
1788 return pSQLParamOptions(hstmt, crow, pirow);
1792 /*************************************************************************
1793 * SQLPrimaryKeys [ODBC32.065]
1795 SQLRETURN WINAPI SQLPrimaryKeys(
1796 SQLHSTMT hstmt,
1797 SQLCHAR *szCatalogName,
1798 SQLSMALLINT cbCatalogName,
1799 SQLCHAR *szSchemaName,
1800 SQLSMALLINT cbSchemaName,
1801 SQLCHAR *szTableName,
1802 SQLSMALLINT cbTableName)
1804 TRACE("\n");
1806 if (!pSQLPrimaryKeys) return SQL_ERROR;
1807 return pSQLPrimaryKeys(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1808 szTableName, cbTableName);
1812 /*************************************************************************
1813 * SQLProcedureColumns [ODBC32.066]
1815 SQLRETURN WINAPI SQLProcedureColumns(
1816 SQLHSTMT hstmt,
1817 SQLCHAR *szCatalogName,
1818 SQLSMALLINT cbCatalogName,
1819 SQLCHAR *szSchemaName,
1820 SQLSMALLINT cbSchemaName,
1821 SQLCHAR *szProcName,
1822 SQLSMALLINT cbProcName,
1823 SQLCHAR *szColumnName,
1824 SQLSMALLINT cbColumnName)
1826 TRACE("\n");
1828 if (!pSQLProcedureColumns) return SQL_ERROR;
1829 return pSQLProcedureColumns(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1830 szProcName, cbProcName, szColumnName, cbColumnName);
1834 /*************************************************************************
1835 * SQLProcedures [ODBC32.067]
1837 SQLRETURN WINAPI SQLProcedures(
1838 SQLHSTMT hstmt,
1839 SQLCHAR *szCatalogName,
1840 SQLSMALLINT cbCatalogName,
1841 SQLCHAR *szSchemaName,
1842 SQLSMALLINT cbSchemaName,
1843 SQLCHAR *szProcName,
1844 SQLSMALLINT cbProcName)
1846 TRACE("\n");
1848 if (!pSQLProcedures) return SQL_ERROR;
1849 return pSQLProcedures(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1850 szProcName, cbProcName);
1854 /*************************************************************************
1855 * SQLSetPos [ODBC32.068]
1857 SQLRETURN WINAPI SQLSetPos(
1858 SQLHSTMT hstmt,
1859 SQLUSMALLINT irow,
1860 SQLUSMALLINT fOption,
1861 SQLUSMALLINT fLock)
1863 TRACE("\n");
1865 if (!pSQLSetPos) return SQL_ERROR;
1866 return pSQLSetPos(hstmt, irow, fOption, fLock);
1870 /*************************************************************************
1871 * SQLTablePrivileges [ODBC32.070]
1873 SQLRETURN WINAPI SQLTablePrivileges(
1874 SQLHSTMT hstmt,
1875 SQLCHAR *szCatalogName,
1876 SQLSMALLINT cbCatalogName,
1877 SQLCHAR *szSchemaName,
1878 SQLSMALLINT cbSchemaName,
1879 SQLCHAR *szTableName,
1880 SQLSMALLINT cbTableName)
1882 TRACE("\n");
1884 if (!pSQLTablePrivileges) return SQL_ERROR;
1885 return pSQLTablePrivileges(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1886 szTableName, cbTableName);
1890 /*************************************************************************
1891 * SQLDrivers [ODBC32.071]
1893 SQLRETURN WINAPI SQLDrivers(
1894 SQLHENV henv,
1895 SQLUSMALLINT fDirection,
1896 SQLCHAR *szDriverDesc,
1897 SQLSMALLINT cbDriverDescMax,
1898 SQLSMALLINT *pcbDriverDesc,
1899 SQLCHAR *szDriverAttributes,
1900 SQLSMALLINT cbDriverAttrMax,
1901 SQLSMALLINT *pcbDriverAttr)
1903 TRACE("\n");
1905 if (!pSQLDrivers) return SQL_ERROR;
1906 return pSQLDrivers(henv, fDirection, szDriverDesc, cbDriverDescMax, pcbDriverDesc,
1907 szDriverAttributes, cbDriverAttrMax, pcbDriverAttr);
1911 /*************************************************************************
1912 * SQLBindParameter [ODBC32.072]
1914 SQLRETURN WINAPI SQLBindParameter(
1915 SQLHSTMT hstmt,
1916 SQLUSMALLINT ipar,
1917 SQLSMALLINT fParamType,
1918 SQLSMALLINT fCType,
1919 SQLSMALLINT fSqlType,
1920 SQLUINTEGER cbColDef,
1921 SQLSMALLINT ibScale,
1922 SQLPOINTER rgbValue,
1923 SQLINTEGER cbValueMax,
1924 SQLINTEGER *pcbValue)
1926 TRACE("\n");
1928 if (!pSQLBindParameter) return SQL_ERROR;
1929 return pSQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale,
1930 rgbValue, cbValueMax, pcbValue);
1934 /*************************************************************************
1935 * SQLDriverConnect [ODBC32.041]
1937 SQLRETURN WINAPI SQLDriverConnect(
1938 SQLHDBC hdbc,
1939 SQLHWND hwnd,
1940 SQLCHAR *conn_str_in,
1941 SQLSMALLINT len_conn_str_in,
1942 SQLCHAR *conn_str_out,
1943 SQLSMALLINT conn_str_out_max,
1944 SQLSMALLINT *ptr_conn_str_out,
1945 SQLUSMALLINT driver_completion )
1947 TRACE("\n");
1949 if (!pSQLDriverConnect) return SQL_ERROR;
1950 return pSQLDriverConnect(hdbc, hwnd, conn_str_in, len_conn_str_in, conn_str_out,
1951 conn_str_out_max, ptr_conn_str_out, driver_completion);
1955 /*************************************************************************
1956 * SQLSetScrollOptions [ODBC32.069]
1958 SQLRETURN WINAPI SQLSetScrollOptions(
1959 SQLHSTMT statement_handle,
1960 SQLUSMALLINT f_concurrency,
1961 SQLINTEGER crow_keyset,
1962 SQLUSMALLINT crow_rowset )
1964 TRACE("\n");
1966 if (!pSQLSetScrollOptions) return SQL_ERROR;
1967 return pSQLSetScrollOptions(statement_handle, f_concurrency, crow_keyset, crow_rowset);
1970 static int SQLColAttributes_KnownStringAttribute(SQLUSMALLINT fDescType)
1972 static const SQLUSMALLINT attrList[] =
1974 SQL_COLUMN_OWNER_NAME,
1975 SQL_COLUMN_QUALIFIER_NAME,
1976 SQL_COLUMN_LABEL,
1977 SQL_COLUMN_NAME,
1978 SQL_COLUMN_TABLE_NAME,
1979 SQL_COLUMN_TYPE_NAME,
1980 SQL_DESC_BASE_COLUMN_NAME,
1981 SQL_DESC_BASE_TABLE_NAME,
1982 SQL_DESC_CATALOG_NAME,
1983 SQL_DESC_LABEL,
1984 SQL_DESC_LITERAL_PREFIX,
1985 SQL_DESC_LITERAL_SUFFIX,
1986 SQL_DESC_LOCAL_TYPE_NAME,
1987 SQL_DESC_NAME,
1988 SQL_DESC_SCHEMA_NAME,
1989 SQL_DESC_TABLE_NAME,
1990 SQL_DESC_TYPE_NAME,
1992 unsigned int i;
1994 for (i = 0; i < sizeof(attrList) / sizeof(SQLUSMALLINT); i++) {
1995 if (attrList[i] == fDescType) return 1;
1997 return 0;
2000 /*************************************************************************
2001 * SQLColAttributesW [ODBC32.106]
2003 SQLRETURN WINAPI SQLColAttributesW(
2004 SQLHSTMT hstmt,
2005 SQLUSMALLINT icol,
2006 SQLUSMALLINT fDescType,
2007 SQLPOINTER rgbDesc,
2008 SQLSMALLINT cbDescMax,
2009 SQLSMALLINT *pcbDesc,
2010 SQLINTEGER *pfDesc)
2012 SQLRETURN iResult;
2014 TRACE("hstmt=0x%08lx icol=%d fDescType=%d rgbDesc=%p cbDescMax=%d pcbDesc=%p pfDesc=%p\n",
2015 hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
2017 if (!pSQLColAttributesW) return SQL_ERROR;
2019 iResult = pSQLColAttributesW(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
2020 if (iResult == SQL_SUCCESS && rgbDesc != NULL && SQLColAttributes_KnownStringAttribute(fDescType)) {
2022 TRACE("Dumping values fetched via SQLColAttributesW:\n");
2023 TRACE(" Attribute name : %s\n", debugstr_w(rgbDesc));
2024 TRACE(" Declared length: %d\n", *pcbDesc);
2026 if (*pcbDesc != lstrlenW(rgbDesc) * 2) {
2027 TRACE("CHEAT: resetting name length for ADO\n");
2028 *pcbDesc = lstrlenW(rgbDesc) * 2;
2031 return iResult;
2034 /*************************************************************************
2035 * SQLConnectW [ODBC32.107]
2037 SQLRETURN WINAPI SQLConnectW(SQLHDBC ConnectionHandle,
2038 WCHAR *ServerName, SQLSMALLINT NameLength1,
2039 WCHAR *UserName, SQLSMALLINT NameLength2,
2040 WCHAR *Authentication, SQLSMALLINT NameLength3)
2042 SQLRETURN ret;
2043 TRACE("(Server=%.*s)\n",NameLength1+3, debugstr_w(ServerName));
2045 if (!pSQLConnectW) return SQL_ERROR;
2047 ret = pSQLConnectW(ConnectionHandle, ServerName, NameLength1,
2048 UserName, NameLength2, Authentication, NameLength3);
2050 TRACE("returns %d\n",ret);
2051 return ret;
2054 /*************************************************************************
2055 * SQLDescribeColW [ODBC32.108]
2057 SQLRETURN WINAPI SQLDescribeColW(SQLHSTMT StatementHandle,
2058 SQLUSMALLINT ColumnNumber, WCHAR *ColumnName,
2059 SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
2060 SQLSMALLINT *DataType, SQLUINTEGER *ColumnSize,
2061 SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
2063 SQLRETURN iResult;
2064 TRACE("\n");
2066 if (!pSQLDescribeColW) return SQL_ERROR;
2068 iResult = pSQLDescribeColW(StatementHandle, ColumnNumber, ColumnName,
2069 BufferLength, NameLength, DataType, ColumnSize,
2070 DecimalDigits, Nullable);
2071 if (iResult >= 0) {
2072 TRACE("Successfully recovered the following column information:\n");
2073 TRACE("\tRequested column index: %d\n", ColumnNumber);
2074 TRACE("\tAvailable length for column name: %d\n", BufferLength);
2075 if (NameLength != NULL)
2076 TRACE("\tActual length for column name: %d\n", *NameLength);
2077 else TRACE("\tActual length for column name: (null)\n");
2078 TRACE("\tReturned column name: %s\n", debugstr_w(ColumnName));
2080 return iResult;
2083 /*************************************************************************
2084 * SQLErrorW [ODBC32.110]
2086 SQLRETURN WINAPI SQLErrorW(SQLHENV EnvironmentHandle,
2087 SQLHDBC ConnectionHandle, SQLHSTMT StatementHandle,
2088 WCHAR *Sqlstate, SQLINTEGER *NativeError,
2089 WCHAR *MessageText, SQLSMALLINT BufferLength,
2090 SQLSMALLINT *TextLength)
2092 TRACE("\n");
2094 if (!pSQLErrorW) return SQL_ERROR;
2095 return pSQLErrorW(EnvironmentHandle, ConnectionHandle, StatementHandle,
2096 Sqlstate, NativeError, MessageText, BufferLength, TextLength);
2099 /*************************************************************************
2100 * SQLExecDirectW [ODBC32.111]
2102 SQLRETURN WINAPI SQLExecDirectW(SQLHSTMT StatementHandle,
2103 WCHAR *StatementText, SQLINTEGER TextLength)
2105 TRACE("\n");
2107 if (!pSQLExecDirectW) return SQL_ERROR;
2108 return pSQLExecDirectW(StatementHandle, StatementText, TextLength);
2111 /*************************************************************************
2112 * SQLGetCursorNameW [ODBC32.117]
2114 SQLRETURN WINAPI SQLGetCursorNameW(SQLHSTMT StatementHandle,
2115 WCHAR *CursorName, SQLSMALLINT BufferLength,
2116 SQLSMALLINT *NameLength)
2118 TRACE("\n");
2120 if (!pSQLGetCursorNameW) return SQL_ERROR;
2121 return pSQLGetCursorNameW(StatementHandle, CursorName, BufferLength, NameLength);
2124 /*************************************************************************
2125 * SQLPrepareW [ODBC32.119]
2127 SQLRETURN WINAPI SQLPrepareW(SQLHSTMT StatementHandle,
2128 WCHAR *StatementText, SQLINTEGER TextLength)
2130 TRACE("\n");
2132 if (!pSQLPrepareW) return SQL_ERROR;
2133 return pSQLPrepareW(StatementHandle, StatementText, TextLength);
2136 /*************************************************************************
2137 * SQLSetCursorNameW [ODBC32.121]
2139 SQLRETURN WINAPI SQLSetCursorNameW(SQLHSTMT StatementHandle, WCHAR *CursorName, SQLSMALLINT NameLength)
2141 TRACE("\n");
2143 if (!pSQLSetCursorNameW) return SQL_ERROR;
2144 return pSQLSetCursorNameW(StatementHandle, CursorName, NameLength);
2147 /*************************************************************************
2148 * SQLColAttributeW [ODBC32.127]
2150 SQLRETURN WINAPI SQLColAttributeW (SQLHSTMT StatementHandle,
2151 SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
2152 SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength,
2153 SQLSMALLINT *StringLength, SQLPOINTER NumericAttribute)
2155 SQLRETURN iResult;
2157 TRACE("StatementHandle=0x%08lx ColumnNumber=%d FieldIdentifier=%d CharacterAttribute=%p BufferLength=%d StringLength=%p NumericAttribute=%p\n",
2158 StatementHandle, ColumnNumber, FieldIdentifier,
2159 CharacterAttribute, BufferLength, StringLength, NumericAttribute);
2161 if (!pSQLColAttributeW) return SQL_ERROR;
2163 iResult = pSQLColAttributeW(StatementHandle, ColumnNumber, FieldIdentifier,
2164 CharacterAttribute, BufferLength, StringLength, NumericAttribute);
2165 if (iResult == SQL_SUCCESS && CharacterAttribute != NULL && SQLColAttributes_KnownStringAttribute(FieldIdentifier)) {
2167 TRACE("Dumping values fetched via SQLColAttributeW:\n");
2168 TRACE(" Attribute name : %s\n", debugstr_w(rgbDesc));
2169 TRACE(" Declared length: %d\n", *pcbDesc);
2171 if (*StringLength != lstrlenW(CharacterAttribute) * 2) {
2172 TRACE("CHEAT: resetting name length for ADO\n");
2173 *StringLength = lstrlenW(CharacterAttribute) * 2;
2176 return iResult;
2179 /*************************************************************************
2180 * SQLGetConnectAttrW [ODBC32.132]
2182 SQLRETURN WINAPI SQLGetConnectAttrW(SQLHDBC ConnectionHandle,
2183 SQLINTEGER Attribute, SQLPOINTER Value,
2184 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
2186 TRACE("\n");
2188 if (!pSQLGetConnectAttrW) return SQL_ERROR;
2189 return pSQLGetConnectAttrW(ConnectionHandle, Attribute, Value,
2190 BufferLength, StringLength);
2193 /*************************************************************************
2194 * SQLGetDescFieldW [ODBC32.133]
2196 SQLRETURN WINAPI SQLGetDescFieldW(SQLHDESC DescriptorHandle,
2197 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
2198 SQLPOINTER Value, SQLINTEGER BufferLength,
2199 SQLINTEGER *StringLength)
2201 TRACE("\n");
2203 if (!pSQLGetDescFieldW) return SQL_ERROR;
2204 return pSQLGetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier,
2205 Value, BufferLength, StringLength);
2208 /*************************************************************************
2209 * SQLGetDescRecW [ODBC32.134]
2211 SQLRETURN WINAPI SQLGetDescRecW(SQLHDESC DescriptorHandle,
2212 SQLSMALLINT RecNumber, WCHAR *Name,
2213 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
2214 SQLSMALLINT *Type, SQLSMALLINT *SubType,
2215 SQLINTEGER *Length, SQLSMALLINT *Precision,
2216 SQLSMALLINT *Scale, SQLSMALLINT *Nullable)
2218 TRACE("\n");
2220 if (!pSQLGetDescRecW) return SQL_ERROR;
2221 return pSQLGetDescRecW(DescriptorHandle, RecNumber, Name, BufferLength,
2222 StringLength, Type, SubType, Length, Precision, Scale, Nullable);
2225 /*************************************************************************
2226 * SQLGetDiagFieldW [ODBC32.135]
2228 SQLRETURN WINAPI SQLGetDiagFieldW(SQLSMALLINT HandleType, SQLHANDLE Handle,
2229 SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier,
2230 SQLPOINTER DiagInfo, SQLSMALLINT BufferLength,
2231 SQLSMALLINT *StringLength)
2233 TRACE("\n");
2235 if (!pSQLGetDiagFieldW) return SQL_ERROR;
2236 return pSQLGetDiagFieldW(HandleType, Handle, RecNumber, DiagIdentifier,
2237 DiagInfo, BufferLength, StringLength);
2240 /*************************************************************************
2241 * SQLGetDiagRecW [ODBC32.136]
2243 SQLRETURN WINAPI SQLGetDiagRecW(SQLSMALLINT HandleType, SQLHANDLE Handle,
2244 SQLSMALLINT RecNumber, WCHAR *Sqlstate,
2245 SQLINTEGER *NativeError, WCHAR *MessageText,
2246 SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
2248 TRACE("\n");
2250 if (!pSQLGetDiagRecW) return SQL_ERROR;
2251 return pSQLGetDiagRecW(HandleType, Handle, RecNumber, Sqlstate, NativeError,
2252 MessageText, BufferLength, TextLength);
2255 /*************************************************************************
2256 * SQLGetStmtAttrW [ODBC32.138]
2258 SQLRETURN WINAPI SQLGetStmtAttrW(SQLHSTMT StatementHandle,
2259 SQLINTEGER Attribute, SQLPOINTER Value,
2260 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
2262 SQLRETURN iResult;
2264 TRACE("Attribute = (%02ld) Value = %p BufferLength = (%ld) StringLength = %p\n",
2265 Attribute, Value, BufferLength, StringLength);
2267 if (Value == NULL) {
2268 WARN("Unexpected NULL in Value return address\n");
2269 iResult = SQL_ERROR;
2271 } else if (StringLength == NULL) {
2272 WARN("Unexpected NULL in StringLength return address\n");
2273 iResult = SQL_ERROR;
2275 } else {
2276 if (!pSQLGetStmtAttrW) return SQL_ERROR;
2277 iResult = pSQLGetStmtAttrW(StatementHandle, Attribute, Value, BufferLength, StringLength);
2278 TRACE("returning %d...\n", iResult);
2280 return iResult;
2283 /*************************************************************************
2284 * SQLSetConnectAttrW [ODBC32.139]
2286 SQLRETURN WINAPI SQLSetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribute,
2287 SQLPOINTER Value, SQLINTEGER StringLength)
2289 TRACE("\n");
2291 if (!pSQLSetConnectAttrW) return SQL_ERROR;
2292 return pSQLSetConnectAttrW(ConnectionHandle, Attribute, Value, StringLength);
2295 /*************************************************************************
2296 * SQLColumnsW [ODBC32.140]
2298 SQLRETURN WINAPI SQLColumnsW(SQLHSTMT StatementHandle,
2299 WCHAR *CatalogName, SQLSMALLINT NameLength1,
2300 WCHAR *SchemaName, SQLSMALLINT NameLength2,
2301 WCHAR *TableName, SQLSMALLINT NameLength3,
2302 WCHAR *ColumnName, SQLSMALLINT NameLength4)
2304 TRACE("\n");
2306 if (!pSQLColumnsW) return SQL_ERROR;
2307 return pSQLColumnsW(StatementHandle, CatalogName, NameLength1,
2308 SchemaName, NameLength2, TableName, NameLength3, ColumnName, NameLength4);
2311 /*************************************************************************
2312 * SQLDriverConnectW [ODBC32.141]
2314 SQLRETURN WINAPI SQLDriverConnectW(
2315 SQLHDBC hdbc,
2316 SQLHWND hwnd,
2317 WCHAR *conn_str_in,
2318 SQLSMALLINT len_conn_str_in,
2319 WCHAR *conn_str_out,
2320 SQLSMALLINT conn_str_out_max,
2321 SQLSMALLINT *ptr_conn_str_out,
2322 SQLUSMALLINT driver_completion )
2324 TRACE("ConnStrIn (%d bytes) --> %s\n", len_conn_str_in, debugstr_w(conn_str_in));
2326 if (!pSQLDriverConnectW) return SQL_ERROR;
2327 return pSQLDriverConnectW(hdbc, hwnd, conn_str_in, len_conn_str_in, conn_str_out,
2328 conn_str_out_max, ptr_conn_str_out, driver_completion);
2331 /*************************************************************************
2332 * SQLGetConnectOptionW [ODBC32.142]
2334 SQLRETURN WINAPI SQLGetConnectOptionW(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLPOINTER Value)
2336 TRACE("\n");
2338 if (!pSQLGetConnectOptionW) return SQL_ERROR;
2339 return pSQLGetConnectOptionW(ConnectionHandle, Option, Value);
2342 /*************************************************************************
2343 * SQLGetInfoW [ODBC32.145]
2345 SQLRETURN WINAPI SQLGetInfoW(SQLHDBC ConnectionHandle,
2346 SQLUSMALLINT InfoType, SQLPOINTER InfoValue,
2347 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
2349 SQLRETURN iResult;
2351 TRACE("InfoType = (%02u), InfoValue = %p, BufferLength = %d bytes\n", InfoType, InfoValue, BufferLength);
2352 if (InfoValue == NULL) {
2353 WARN("Unexpected NULL in InfoValue address\n");
2354 iResult = SQL_ERROR;
2355 } else {
2356 if (!pSQLGetInfoW) return SQL_ERROR;
2357 iResult = pSQLGetInfoW(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLength);
2358 TRACE("returning %d...\n", iResult);
2360 return iResult;
2363 /*************************************************************************
2364 * SQLGetTypeInfoW [ODBC32.147]
2366 SQLRETURN WINAPI SQLGetTypeInfoW(SQLHSTMT StatementHandle, SQLSMALLINT DataType)
2368 TRACE("\n");
2370 if (!pSQLGetTypeInfoW) return SQL_ERROR;
2371 return pSQLGetTypeInfoW(StatementHandle, DataType);
2374 /*************************************************************************
2375 * SQLSetConnectOptionW [ODBC32.150]
2377 SQLRETURN WINAPI SQLSetConnectOptionW(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLUINTEGER Value)
2379 TRACE("\n");
2381 if (!pSQLSetConnectOptionW) return SQL_ERROR;
2382 return pSQLSetConnectOptionW(ConnectionHandle, Option, Value);
2385 /*************************************************************************
2386 * SQLSpecialColumnsW [ODBC32.152]
2388 SQLRETURN WINAPI SQLSpecialColumnsW(SQLHSTMT StatementHandle,
2389 SQLUSMALLINT IdentifierType, SQLWCHAR *CatalogName,
2390 SQLSMALLINT NameLength1, SQLWCHAR *SchemaName,
2391 SQLSMALLINT NameLength2, SQLWCHAR *TableName,
2392 SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
2393 SQLUSMALLINT Nullable)
2395 if (!pSQLSpecialColumnsW) return SQL_ERROR;
2396 return pSQLSpecialColumnsW(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName,
2397 NameLength2, TableName, NameLength3, Scope, Nullable);
2400 /*************************************************************************
2401 * SQLStatisticsW [ODBC32.153]
2403 SQLRETURN WINAPI SQLStatisticsW(SQLHSTMT StatementHandle,
2404 SQLWCHAR *CatalogName, SQLSMALLINT NameLength1,
2405 SQLWCHAR *SchemaName, SQLSMALLINT NameLength2,
2406 SQLWCHAR *TableName, SQLSMALLINT NameLength3,
2407 SQLUSMALLINT Unique, SQLUSMALLINT Reserved)
2409 TRACE("\n");
2411 if (!pSQLStatisticsW) return SQL_ERROR;
2412 return pSQLStatisticsW(StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2,
2413 TableName, NameLength3, Unique, Reserved);
2416 /*************************************************************************
2417 * SQLTablesW [ODBC32.154]
2419 SQLRETURN WINAPI SQLTablesW(SQLHSTMT StatementHandle,
2420 SQLWCHAR *CatalogName, SQLSMALLINT NameLength1,
2421 SQLWCHAR *SchemaName, SQLSMALLINT NameLength2,
2422 SQLWCHAR *TableName, SQLSMALLINT NameLength3,
2423 SQLWCHAR *TableType, SQLSMALLINT NameLength4)
2425 TRACE("\n");
2427 if (!pSQLTablesW) return SQL_ERROR;
2428 return pSQLTablesW(StatementHandle, CatalogName, NameLength1,
2429 SchemaName, NameLength2, TableName, NameLength3, TableType, NameLength4);
2432 /*************************************************************************
2433 * SQLBrowseConnectW [ODBC32.155]
2435 SQLRETURN WINAPI SQLBrowseConnectW(
2436 SQLHDBC hdbc,
2437 SQLWCHAR *szConnStrIn,
2438 SQLSMALLINT cbConnStrIn,
2439 SQLWCHAR *szConnStrOut,
2440 SQLSMALLINT cbConnStrOutMax,
2441 SQLSMALLINT *pcbConnStrOut)
2443 TRACE("\n");
2445 if (!pSQLBrowseConnectW) return SQL_ERROR;
2446 return pSQLBrowseConnectW(hdbc, szConnStrIn, cbConnStrIn, szConnStrOut,
2447 cbConnStrOutMax, pcbConnStrOut);
2450 /*************************************************************************
2451 * SQLColumnPrivilegesW [ODBC32.156]
2453 SQLRETURN WINAPI SQLColumnPrivilegesW(
2454 SQLHSTMT hstmt,
2455 SQLWCHAR *szCatalogName,
2456 SQLSMALLINT cbCatalogName,
2457 SQLWCHAR *szSchemaName,
2458 SQLSMALLINT cbSchemaName,
2459 SQLWCHAR *szTableName,
2460 SQLSMALLINT cbTableName,
2461 SQLWCHAR *szColumnName,
2462 SQLSMALLINT cbColumnName)
2464 TRACE("\n");
2466 if (!pSQLColumnPrivilegesW) return SQL_ERROR;
2467 return pSQLColumnPrivilegesW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2468 szTableName, cbTableName, szColumnName, cbColumnName);
2471 /*************************************************************************
2472 * SQLDataSourcesW [ODBC32.157]
2474 SQLRETURN WINAPI SQLDataSourcesW(SQLHENV EnvironmentHandle,
2475 SQLUSMALLINT Direction, WCHAR *ServerName,
2476 SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
2477 WCHAR *Description, SQLSMALLINT BufferLength2,
2478 SQLSMALLINT *NameLength2)
2480 SQLRETURN ret;
2482 TRACE("EnvironmentHandle = %p\n", (LPVOID)EnvironmentHandle);
2484 if (!pSQLDataSourcesW) return SQL_ERROR;
2486 ret = pSQLDataSourcesW(EnvironmentHandle, Direction, ServerName,
2487 BufferLength1, NameLength1, Description, BufferLength2, NameLength2);
2489 if (TRACE_ON(odbc))
2491 TRACE("returns: %d \t", ret);
2492 if (*NameLength1 > 0)
2493 TRACE("DataSource = %s,", debugstr_w(ServerName));
2494 if (*NameLength2 > 0)
2495 TRACE(" Description = %s", debugstr_w(Description));
2496 TRACE("\n");
2499 return ret;
2502 /*************************************************************************
2503 * SQLForeignKeysW [ODBC32.160]
2505 SQLRETURN WINAPI SQLForeignKeysW(
2506 SQLHSTMT hstmt,
2507 SQLWCHAR *szPkCatalogName,
2508 SQLSMALLINT cbPkCatalogName,
2509 SQLWCHAR *szPkSchemaName,
2510 SQLSMALLINT cbPkSchemaName,
2511 SQLWCHAR *szPkTableName,
2512 SQLSMALLINT cbPkTableName,
2513 SQLWCHAR *szFkCatalogName,
2514 SQLSMALLINT cbFkCatalogName,
2515 SQLWCHAR *szFkSchemaName,
2516 SQLSMALLINT cbFkSchemaName,
2517 SQLWCHAR *szFkTableName,
2518 SQLSMALLINT cbFkTableName)
2520 TRACE("\n");
2522 if (!pSQLForeignKeysW) return SQL_ERROR;
2523 return pSQLForeignKeysW(hstmt, szPkCatalogName, cbPkCatalogName, szPkSchemaName, cbPkSchemaName,
2524 szPkTableName, cbPkTableName, szFkCatalogName, cbFkCatalogName,
2525 szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName);
2528 /*************************************************************************
2529 * SQLNativeSqlW [ODBC32.162]
2531 SQLRETURN WINAPI SQLNativeSqlW(
2532 SQLHDBC hdbc,
2533 SQLWCHAR *szSqlStrIn,
2534 SQLINTEGER cbSqlStrIn,
2535 SQLWCHAR *szSqlStr,
2536 SQLINTEGER cbSqlStrMax,
2537 SQLINTEGER *pcbSqlStr)
2539 TRACE("\n");
2541 if (!pSQLNativeSqlW) return SQL_ERROR;
2542 return pSQLNativeSqlW(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr);
2545 /*************************************************************************
2546 * SQLPrimaryKeysW [ODBC32.165]
2548 SQLRETURN WINAPI SQLPrimaryKeysW(
2549 SQLHSTMT hstmt,
2550 SQLWCHAR *szCatalogName,
2551 SQLSMALLINT cbCatalogName,
2552 SQLWCHAR *szSchemaName,
2553 SQLSMALLINT cbSchemaName,
2554 SQLWCHAR *szTableName,
2555 SQLSMALLINT cbTableName)
2557 TRACE("\n");
2559 if (!pSQLPrimaryKeysW) return SQL_ERROR;
2560 return pSQLPrimaryKeysW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2561 szTableName, cbTableName);
2564 /*************************************************************************
2565 * SQLProcedureColumnsW [ODBC32.166]
2567 SQLRETURN WINAPI SQLProcedureColumnsW(
2568 SQLHSTMT hstmt,
2569 SQLWCHAR *szCatalogName,
2570 SQLSMALLINT cbCatalogName,
2571 SQLWCHAR *szSchemaName,
2572 SQLSMALLINT cbSchemaName,
2573 SQLWCHAR *szProcName,
2574 SQLSMALLINT cbProcName,
2575 SQLWCHAR *szColumnName,
2576 SQLSMALLINT cbColumnName)
2578 TRACE("\n");
2580 if (!pSQLProcedureColumnsW) return SQL_ERROR;
2581 return pSQLProcedureColumnsW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2582 szProcName, cbProcName, szColumnName, cbColumnName);
2585 /*************************************************************************
2586 * SQLProceduresW [ODBC32.167]
2588 SQLRETURN WINAPI SQLProceduresW(
2589 SQLHSTMT hstmt,
2590 SQLWCHAR *szCatalogName,
2591 SQLSMALLINT cbCatalogName,
2592 SQLWCHAR *szSchemaName,
2593 SQLSMALLINT cbSchemaName,
2594 SQLWCHAR *szProcName,
2595 SQLSMALLINT cbProcName)
2597 TRACE("\n");
2599 if (!pSQLProceduresW) return SQL_ERROR;
2600 return pSQLProceduresW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2601 szProcName, cbProcName);
2604 /*************************************************************************
2605 * SQLTablePrivilegesW [ODBC32.170]
2607 SQLRETURN WINAPI SQLTablePrivilegesW(
2608 SQLHSTMT hstmt,
2609 SQLWCHAR *szCatalogName,
2610 SQLSMALLINT cbCatalogName,
2611 SQLWCHAR *szSchemaName,
2612 SQLSMALLINT cbSchemaName,
2613 SQLWCHAR *szTableName,
2614 SQLSMALLINT cbTableName)
2616 TRACE("\n");
2618 if (!pSQLTablePrivilegesW) return SQL_ERROR;
2619 return pSQLTablePrivilegesW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2620 szTableName, cbTableName);
2623 /*************************************************************************
2624 * SQLDriversW [ODBC32.171]
2626 SQLRETURN WINAPI SQLDriversW(
2627 SQLHENV henv,
2628 SQLUSMALLINT fDirection,
2629 SQLWCHAR *szDriverDesc,
2630 SQLSMALLINT cbDriverDescMax,
2631 SQLSMALLINT *pcbDriverDesc,
2632 SQLWCHAR *szDriverAttributes,
2633 SQLSMALLINT cbDriverAttrMax,
2634 SQLSMALLINT *pcbDriverAttr)
2636 TRACE("\n");
2638 if (!pSQLDriversW) return SQL_ERROR;
2639 return pSQLDriversW(henv, fDirection, szDriverDesc, cbDriverDescMax, pcbDriverDesc,
2640 szDriverAttributes, cbDriverAttrMax, pcbDriverAttr);
2643 /*************************************************************************
2644 * SQLSetDescFieldW [ODBC32.173]
2646 SQLRETURN WINAPI SQLSetDescFieldW(SQLHDESC DescriptorHandle,
2647 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
2648 SQLPOINTER Value, SQLINTEGER BufferLength)
2650 TRACE("\n");
2652 if (!pSQLSetDescFieldW) return SQL_ERROR;
2653 return pSQLSetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength);
2656 /*************************************************************************
2657 * SQLSetStmtAttrW [ODBC32.176]
2659 SQLRETURN WINAPI SQLSetStmtAttrW(SQLHSTMT StatementHandle,
2660 SQLINTEGER Attribute, SQLPOINTER Value,
2661 SQLINTEGER StringLength)
2663 SQLRETURN iResult;
2664 TRACE("Attribute = (%02ld) Value = %p StringLength = (%ld)\n",
2665 Attribute, Value, StringLength);
2667 if (!pSQLSetStmtAttrW) return SQL_ERROR;
2668 iResult = pSQLSetStmtAttrW(StatementHandle, Attribute, Value, StringLength);
2669 if (iResult == SQL_ERROR && (Attribute == SQL_ROWSET_SIZE || Attribute == SQL_ATTR_ROW_ARRAY_SIZE)) {
2670 TRACE("CHEAT: returning SQL_SUCCESS to ADO...\n");
2671 iResult = SQL_SUCCESS;
2672 } else {
2673 TRACE("returning %d...\n", iResult);
2675 return iResult;
2679 /* End of file */