d2d1: Implement d2d_radial_gradient_brush_SetCenter().
[wine.git] / dlls / odbc32 / proxyodbc.c
blob7e434cba087ed962fb579838ab6e93f77efac5b2
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);
52 WINE_DECLARE_DEBUG_CHANNEL(winediag);
54 static SQLRETURN (*pSQLAllocConnect)(SQLHENV,SQLHDBC*);
55 static SQLRETURN (*pSQLAllocEnv)(SQLHENV*);
56 static SQLRETURN (*pSQLAllocHandle)(SQLSMALLINT,SQLHANDLE,SQLHANDLE*);
57 static SQLRETURN (*pSQLAllocHandleStd)(SQLSMALLINT,SQLHANDLE,SQLHANDLE*);
58 static SQLRETURN (*pSQLAllocStmt)(SQLHDBC,SQLHSTMT*);
59 static SQLRETURN (*pSQLBindCol)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLLEN,SQLLEN*);
60 static SQLRETURN (*pSQLBindParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLULEN,SQLSMALLINT,SQLPOINTER,SQLLEN*);
61 static SQLRETURN (*pSQLBindParameter)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLULEN,SQLSMALLINT,SQLPOINTER,SQLLEN,SQLLEN*);
62 static SQLRETURN (*pSQLBrowseConnect)(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
63 static SQLRETURN (*pSQLBrowseConnectW)(SQLHDBC,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
64 static SQLRETURN (*pSQLBulkOperations)(SQLHSTMT,SQLSMALLINT);
65 static SQLRETURN (*pSQLCancel)(SQLHSTMT);
66 static SQLRETURN (*pSQLCloseCursor)(SQLHSTMT);
67 static SQLRETURN (*pSQLColAttribute)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLLEN*);
68 static SQLRETURN (*pSQLColAttributeW)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLLEN*);
69 static SQLRETURN (*pSQLColAttributes)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLLEN*);
70 static SQLRETURN (*pSQLColAttributesW)(SQLHSTMT,SQLUSMALLINT,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*,SQLLEN*);
71 static SQLRETURN (*pSQLColumnPrivileges)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
72 static SQLRETURN (*pSQLColumnPrivilegesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
73 static SQLRETURN (*pSQLColumns)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
74 static SQLRETURN (*pSQLColumnsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
75 static SQLRETURN (*pSQLConnect)(SQLHDBC,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
76 static SQLRETURN (*pSQLConnectW)(SQLHDBC,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
77 static SQLRETURN (*pSQLCopyDesc)(SQLHDESC,SQLHDESC);
78 static SQLRETURN (*pSQLDataSources)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
79 static SQLRETURN (*pSQLDataSourcesA)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
80 static SQLRETURN (*pSQLDataSourcesW)(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
81 static SQLRETURN (*pSQLDescribeCol)(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*);
82 static SQLRETURN (*pSQLDescribeColW)(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*);
83 static SQLRETURN (*pSQLDescribeParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT*,SQLULEN*,SQLSMALLINT*,SQLSMALLINT*);
84 static SQLRETURN (*pSQLDisconnect)(SQLHDBC);
85 static SQLRETURN (*pSQLDriverConnect)(SQLHDBC,SQLHWND,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT);
86 static SQLRETURN (*pSQLDriverConnectW)(SQLHDBC,SQLHWND,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLUSMALLINT);
87 static SQLRETURN (*pSQLDrivers)(SQLHENV,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
88 static SQLRETURN (*pSQLDriversW)(SQLHENV,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
89 static SQLRETURN (*pSQLEndTran)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT);
90 static SQLRETURN (*pSQLError)(SQLHENV,SQLHDBC,SQLHSTMT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
91 static SQLRETURN (*pSQLErrorW)(SQLHENV,SQLHDBC,SQLHSTMT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
92 static SQLRETURN (*pSQLExecDirect)(SQLHSTMT,SQLCHAR*,SQLINTEGER);
93 static SQLRETURN (*pSQLExecDirectW)(SQLHSTMT,SQLWCHAR*,SQLINTEGER);
94 static SQLRETURN (*pSQLExecute)(SQLHSTMT);
95 static SQLRETURN (*pSQLExtendedFetch)(SQLHSTMT,SQLUSMALLINT,SQLLEN,SQLULEN*,SQLUSMALLINT*);
96 static SQLRETURN (*pSQLFetch)(SQLHSTMT);
97 static SQLRETURN (*pSQLFetchScroll)(SQLHSTMT,SQLSMALLINT,SQLLEN);
98 static SQLRETURN (*pSQLForeignKeys)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
99 static SQLRETURN (*pSQLForeignKeysW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
100 static SQLRETURN (*pSQLFreeConnect)(SQLHDBC);
101 static SQLRETURN (*pSQLFreeEnv)(SQLHENV);
102 static SQLRETURN (*pSQLFreeHandle)(SQLSMALLINT,SQLHANDLE);
103 static SQLRETURN (*pSQLFreeStmt)(SQLHSTMT,SQLUSMALLINT);
104 static SQLRETURN (*pSQLGetConnectAttr)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
105 static SQLRETURN (*pSQLGetConnectAttrW)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
106 static SQLRETURN (*pSQLGetConnectOption)(SQLHDBC,SQLUSMALLINT,SQLPOINTER);
107 static SQLRETURN (*pSQLGetConnectOptionW)(SQLHDBC,SQLUSMALLINT,SQLPOINTER);
108 static SQLRETURN (*pSQLGetCursorName)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
109 static SQLRETURN (*pSQLGetCursorNameW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
110 static SQLRETURN (*pSQLGetData)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER,SQLLEN,SQLLEN*);
111 static SQLRETURN (*pSQLGetDescField)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
112 static SQLRETURN (*pSQLGetDescFieldW)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
113 static SQLRETURN (*pSQLGetDescRec)(SQLHDESC,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLLEN*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*);
114 static SQLRETURN (*pSQLGetDescRecW)(SQLHDESC,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*,SQLLEN*,SQLSMALLINT*,SQLSMALLINT*,SQLSMALLINT*);
115 static SQLRETURN (*pSQLGetDiagField)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
116 static SQLRETURN (*pSQLGetDiagFieldW)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
117 static SQLRETURN (*pSQLGetDiagRec)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLCHAR*,SQLINTEGER*,SQLCHAR*,SQLSMALLINT,SQLSMALLINT*);
118 static SQLRETURN (*pSQLGetDiagRecW)(SQLSMALLINT,SQLHANDLE,SQLSMALLINT,SQLWCHAR*,SQLINTEGER*,SQLWCHAR*,SQLSMALLINT,SQLSMALLINT*);
119 static SQLRETURN (*pSQLGetEnvAttr)(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
120 static SQLRETURN (*pSQLGetFunctions)(SQLHDBC,SQLUSMALLINT,SQLUSMALLINT*);
121 static SQLRETURN (*pSQLGetInfo)(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
122 static SQLRETURN (*pSQLGetInfoW)(SQLHDBC,SQLUSMALLINT,SQLPOINTER,SQLSMALLINT,SQLSMALLINT*);
123 static SQLRETURN (*pSQLGetStmtAttr)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
124 static SQLRETURN (*pSQLGetStmtAttrW)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER,SQLINTEGER*);
125 static SQLRETURN (*pSQLGetStmtOption)(SQLHSTMT,SQLUSMALLINT,SQLPOINTER);
126 static SQLRETURN (*pSQLGetTypeInfo)(SQLHSTMT,SQLSMALLINT);
127 static SQLRETURN (*pSQLGetTypeInfoW)(SQLHSTMT,SQLSMALLINT);
128 static SQLRETURN (*pSQLMoreResults)(SQLHSTMT);
129 static SQLRETURN (*pSQLNativeSql)(SQLHDBC,SQLCHAR*,SQLINTEGER,SQLCHAR*,SQLINTEGER,SQLINTEGER*);
130 static SQLRETURN (*pSQLNativeSqlW)(SQLHDBC,SQLWCHAR*,SQLINTEGER,SQLWCHAR*,SQLINTEGER,SQLINTEGER*);
131 static SQLRETURN (*pSQLNumParams)(SQLHSTMT,SQLSMALLINT*);
132 static SQLRETURN (*pSQLNumResultCols)(SQLHSTMT,SQLSMALLINT*);
133 static SQLRETURN (*pSQLParamData)(SQLHSTMT,SQLPOINTER*);
134 static SQLRETURN (*pSQLParamOptions)(SQLHSTMT,SQLULEN,SQLULEN*);
135 static SQLRETURN (*pSQLPrepare)(SQLHSTMT,SQLCHAR*,SQLINTEGER);
136 static SQLRETURN (*pSQLPrepareW)(SQLHSTMT,SQLWCHAR*,SQLINTEGER);
137 static SQLRETURN (*pSQLPrimaryKeys)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
138 static SQLRETURN (*pSQLPrimaryKeysW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
139 static SQLRETURN (*pSQLProcedureColumns)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
140 static SQLRETURN (*pSQLProcedureColumnsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
141 static SQLRETURN (*pSQLProcedures)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
142 static SQLRETURN (*pSQLProceduresW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
143 static SQLRETURN (*pSQLPutData)(SQLHSTMT,SQLPOINTER,SQLLEN);
144 static SQLRETURN (*pSQLRowCount)(SQLHSTMT,SQLLEN*);
145 static SQLRETURN (*pSQLSetConnectAttr)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER);
146 static SQLRETURN (*pSQLSetConnectAttrW)(SQLHDBC,SQLINTEGER,SQLPOINTER,SQLINTEGER);
147 static SQLRETURN (*pSQLSetConnectOption)(SQLHDBC,SQLUSMALLINT,SQLULEN);
148 static SQLRETURN (*pSQLSetConnectOptionW)(SQLHDBC,SQLUSMALLINT,SQLULEN);
149 static SQLRETURN (*pSQLSetCursorName)(SQLHSTMT,SQLCHAR*,SQLSMALLINT);
150 static SQLRETURN (*pSQLSetCursorNameW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT);
151 static SQLRETURN (*pSQLSetDescField)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER);
152 static SQLRETURN (*pSQLSetDescFieldW)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLINTEGER);
153 static SQLRETURN (*pSQLSetDescRec)(SQLHDESC,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLLEN,SQLSMALLINT,SQLSMALLINT,SQLPOINTER,SQLLEN*,SQLLEN*);
154 static SQLRETURN (*pSQLSetEnvAttr)(SQLHENV,SQLINTEGER,SQLPOINTER,SQLINTEGER);
155 static SQLRETURN (*pSQLSetParam)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLULEN,SQLSMALLINT,SQLPOINTER,SQLLEN*);
156 static SQLRETURN (*pSQLSetPos)(SQLHSTMT,SQLSETPOSIROW,SQLUSMALLINT,SQLUSMALLINT);
157 static SQLRETURN (*pSQLSetScrollOptions)(SQLHSTMT,SQLUSMALLINT,SQLLEN,SQLUSMALLINT);
158 static SQLRETURN (*pSQLSetStmtAttr)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER);
159 static SQLRETURN (*pSQLSetStmtAttrW)(SQLHSTMT,SQLINTEGER,SQLPOINTER,SQLINTEGER);
160 static SQLRETURN (*pSQLSetStmtOption)(SQLHSTMT,SQLUSMALLINT,SQLULEN);
161 static SQLRETURN (*pSQLSpecialColumns)(SQLHSTMT,SQLUSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
162 static SQLRETURN (*pSQLSpecialColumnsW)(SQLHSTMT,SQLUSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
163 static SQLRETURN (*pSQLStatistics)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
164 static SQLRETURN (*pSQLStatisticsW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLUSMALLINT,SQLUSMALLINT);
165 static SQLRETURN (*pSQLTablePrivileges)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
166 static SQLRETURN (*pSQLTablePrivilegesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
167 static SQLRETURN (*pSQLTables)(SQLHSTMT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT,SQLCHAR*,SQLSMALLINT);
168 static SQLRETURN (*pSQLTablesW)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT);
169 static SQLRETURN (*pSQLTransact)(SQLHENV,SQLHDBC,SQLUSMALLINT);
171 #define ERROR_FREE 0
172 #define ERROR_SQLERROR 1
173 #define ERROR_LIBRARY_NOT_FOUND 2
175 static void *dmHandle;
176 static int nErrorType;
178 /***********************************************************************
179 * ODBC_ReplicateODBCInstToRegistry
181 * PARAMS
183 * RETURNS
185 * Utility to ODBC_ReplicateToRegistry to replicate the drivers of the
186 * ODBCINST.INI settings
188 * The driver settings are not replicated to the registry. If we were to
189 * replicate them we would need to decide whether to replicate all settings
190 * or to do some translation; whether to remove any entries present only in
191 * the windows registry, etc.
194 static void ODBC_ReplicateODBCInstToRegistry (SQLHENV hEnv)
196 HKEY hODBCInst;
197 LONG reg_ret;
198 BOOL success;
200 success = FALSE;
201 TRACE ("Driver settings are not currently replicated to the registry\n");
202 if ((reg_ret = RegCreateKeyExA (HKEY_LOCAL_MACHINE,
203 "Software\\ODBC\\ODBCINST.INI", 0, NULL,
204 REG_OPTION_NON_VOLATILE,
205 KEY_ALL_ACCESS /* a couple more than we need */, NULL,
206 &hODBCInst, NULL)) == ERROR_SUCCESS)
208 HKEY hDrivers;
209 if ((reg_ret = RegCreateKeyExA (hODBCInst, "ODBC Drivers", 0,
210 NULL, REG_OPTION_NON_VOLATILE,
211 KEY_ALL_ACCESS /* overkill */, NULL, &hDrivers, NULL))
212 == ERROR_SUCCESS)
214 SQLRETURN sql_ret;
215 SQLUSMALLINT dirn;
216 CHAR desc [256];
217 SQLSMALLINT sizedesc;
219 success = TRUE;
220 dirn = SQL_FETCH_FIRST;
221 while ((sql_ret = SQLDrivers (hEnv, dirn, (SQLCHAR*)desc, sizeof(desc),
222 &sizedesc, NULL, 0, NULL)) == SQL_SUCCESS ||
223 sql_ret == SQL_SUCCESS_WITH_INFO)
225 /* FIXME Do some proper handling of the SUCCESS_WITH_INFO */
226 dirn = SQL_FETCH_NEXT;
227 if (sizedesc == lstrlenA(desc))
229 HKEY hThis;
230 if ((reg_ret = RegQueryValueExA (hDrivers, desc, NULL,
231 NULL, NULL, NULL)) == ERROR_FILE_NOT_FOUND)
233 if ((reg_ret = RegSetValueExA (hDrivers, desc, 0,
234 REG_SZ, (const BYTE *)"Installed", 10)) != ERROR_SUCCESS)
236 TRACE ("Error %d replicating driver %s\n",
237 reg_ret, desc);
238 success = FALSE;
241 else if (reg_ret != ERROR_SUCCESS)
243 TRACE ("Error %d checking for %s in drivers\n",
244 reg_ret, desc);
245 success = FALSE;
247 if ((reg_ret = RegCreateKeyExA (hODBCInst, desc, 0,
248 NULL, REG_OPTION_NON_VOLATILE,
249 KEY_ALL_ACCESS, NULL, &hThis, NULL))
250 == ERROR_SUCCESS)
252 /* FIXME This is where the settings go.
253 * I suggest that if the disposition says it
254 * exists then we leave it alone. Alternatively
255 * include an extra value to flag that it is
256 * a replication of the unixODBC/iODBC/...
258 if ((reg_ret = RegCloseKey (hThis)) !=
259 ERROR_SUCCESS)
260 TRACE ("Error %d closing %s key\n", reg_ret,
261 desc);
263 else
265 TRACE ("Error %d ensuring driver key %s\n",
266 reg_ret, desc);
267 success = FALSE;
270 else
272 WARN ("Unusually long driver name %s not replicated\n",
273 desc);
274 success = FALSE;
277 if (sql_ret != SQL_NO_DATA)
279 TRACE ("Error %d enumerating drivers\n", (int)sql_ret);
280 success = FALSE;
282 if ((reg_ret = RegCloseKey (hDrivers)) != ERROR_SUCCESS)
284 TRACE ("Error %d closing hDrivers\n", reg_ret);
287 else
289 TRACE ("Error %d opening HKLM\\S\\O\\OI\\Drivers\n", reg_ret);
291 if ((reg_ret = RegCloseKey (hODBCInst)) != ERROR_SUCCESS)
293 TRACE ("Error %d closing HKLM\\S\\O\\ODBCINST.INI\n", reg_ret);
296 else
298 TRACE ("Error %d opening HKLM\\S\\O\\ODBCINST.INI\n", reg_ret);
300 if (!success)
302 WARN ("May not have replicated all ODBC drivers to the registry\n");
306 /***********************************************************************
307 * ODBC_ReplicateODBCToRegistry
309 * PARAMS
311 * RETURNS
313 * Utility to ODBC_ReplicateToRegistry to replicate either the USER or
314 * SYSTEM dsns
316 * For now simply place the "Driver description" (as returned by SQLDataSources)
317 * into the registry as the driver. This is enough to satisfy Crystal's
318 * requirement that there be a driver entry. (It doesn't seem to care what
319 * the setting is).
320 * A slightly more accurate setting would be to access the registry to find
321 * the actual driver library for the given description (which appears to map
322 * to one of the HKLM/Software/ODBC/ODBCINST.INI keys). (If you do this note
323 * that this will add a requirement that this function be called after
324 * ODBC_ReplicateODBCInstToRegistry)
326 static void ODBC_ReplicateODBCToRegistry (BOOL is_user, SQLHENV hEnv)
328 HKEY hODBC;
329 LONG reg_ret;
330 SQLRETURN sql_ret;
331 SQLUSMALLINT dirn;
332 CHAR dsn [SQL_MAX_DSN_LENGTH + 1];
333 SQLSMALLINT sizedsn;
334 CHAR desc [256];
335 SQLSMALLINT sizedesc;
336 BOOL success;
337 const char *which = is_user ? "user" : "system";
339 success = FALSE;
340 if ((reg_ret = RegCreateKeyExA (
341 is_user ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
342 "Software\\ODBC\\ODBC.INI", 0, NULL, REG_OPTION_NON_VOLATILE,
343 KEY_ALL_ACCESS /* a couple more than we need */, NULL, &hODBC,
344 NULL)) == ERROR_SUCCESS)
346 success = TRUE;
347 dirn = is_user ? SQL_FETCH_FIRST_USER : SQL_FETCH_FIRST_SYSTEM;
348 while ((sql_ret = SQLDataSources (hEnv, dirn,
349 (SQLCHAR*)dsn, sizeof(dsn), &sizedsn,
350 (SQLCHAR*)desc, sizeof(desc), &sizedesc)) == SQL_SUCCESS
351 || sql_ret == SQL_SUCCESS_WITH_INFO)
353 /* FIXME Do some proper handling of the SUCCESS_WITH_INFO */
354 dirn = SQL_FETCH_NEXT;
355 if (sizedsn == lstrlenA(dsn) && sizedesc == lstrlenA(desc))
357 HKEY hDSN;
358 if ((reg_ret = RegCreateKeyExA (hODBC, dsn, 0,
359 NULL, REG_OPTION_NON_VOLATILE,
360 KEY_ALL_ACCESS, NULL, &hDSN, NULL))
361 == ERROR_SUCCESS)
363 static const char DRIVERKEY[] = "Driver";
364 if ((reg_ret = RegQueryValueExA (hDSN, DRIVERKEY,
365 NULL, NULL, NULL, NULL))
366 == ERROR_FILE_NOT_FOUND)
368 if ((reg_ret = RegSetValueExA (hDSN, DRIVERKEY, 0,
369 REG_SZ, (LPBYTE)desc, sizedesc)) != ERROR_SUCCESS)
371 TRACE ("Error %d replicating description of "
372 "%s(%s)\n", reg_ret, dsn, desc);
373 success = FALSE;
376 else if (reg_ret != ERROR_SUCCESS)
378 TRACE ("Error %d checking for description of %s\n",
379 reg_ret, dsn);
380 success = FALSE;
382 if ((reg_ret = RegCloseKey (hDSN)) != ERROR_SUCCESS)
384 TRACE ("Error %d closing %s DSN key %s\n",
385 reg_ret, which, dsn);
388 else
390 TRACE ("Error %d opening %s DSN key %s\n",
391 reg_ret, which, dsn);
392 success = FALSE;
395 else
397 WARN ("Unusually long %s data source name %s (%s) not "
398 "replicated\n", which, dsn, desc);
399 success = FALSE;
402 if (sql_ret != SQL_NO_DATA)
404 TRACE ("Error %d enumerating %s datasources\n",
405 (int)sql_ret, which);
406 success = FALSE;
408 if ((reg_ret = RegCloseKey (hODBC)) != ERROR_SUCCESS)
410 TRACE ("Error %d closing %s ODBC.INI registry key\n", reg_ret,
411 which);
414 else
416 TRACE ("Error %d creating/opening %s ODBC.INI registry key\n",
417 reg_ret, which);
419 if (!success)
421 WARN ("May not have replicated all %s ODBC DSNs to the registry\n",
422 which);
426 /***********************************************************************
427 * ODBC_ReplicateToRegistry
429 * PARAMS
431 * RETURNS
433 * Unfortunately some of the functions that Windows documents as being part
434 * of the ODBC API it implements directly during compilation or something
435 * in terms of registry access functions.
436 * e.g. SQLGetInstalledDrivers queries the list at
437 * HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINST.INI\ODBC Drivers
439 * This function is called when the driver manager is loaded and is used
440 * to replicate the appropriate details into the Wine registry
443 static void ODBC_ReplicateToRegistry (void)
445 SQLRETURN sql_ret;
446 SQLHENV hEnv;
448 if ((sql_ret = SQLAllocEnv (&hEnv)) == SQL_SUCCESS)
450 ODBC_ReplicateODBCInstToRegistry (hEnv);
451 ODBC_ReplicateODBCToRegistry (FALSE /* system dsns */, hEnv);
452 ODBC_ReplicateODBCToRegistry (TRUE /* user dsns */, hEnv);
454 if ((sql_ret = SQLFreeEnv (hEnv)) != SQL_SUCCESS)
456 TRACE ("Error %d freeing the SQL environment.\n", (int)sql_ret);
459 else
461 TRACE ("Error %d opening an SQL environment.\n", (int)sql_ret);
462 WARN ("The external ODBC settings have not been replicated to the"
463 " Wine registry\n");
467 /***********************************************************************
468 * DllMain [Internal] Initializes the internal 'ODBC32.DLL'.
470 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, LPVOID reserved)
472 TRACE("proxy ODBC: %p,%x,%p\n", hinstDLL, reason, reserved);
474 switch (reason)
476 case DLL_PROCESS_ATTACH:
477 DisableThreadLibraryCalls(hinstDLL);
478 if (ODBC_LoadDriverManager())
480 ODBC_LoadDMFunctions();
481 ODBC_ReplicateToRegistry();
483 break;
485 case DLL_PROCESS_DETACH:
486 if (reserved) break;
487 if (dmHandle) wine_dlclose(dmHandle,NULL,0);
490 return TRUE;
493 /***********************************************************************
494 * ODBC_LoadDriverManager [Internal] Load ODBC library.
496 * PARAMS
498 * RETURNS
499 * Success: TRUE
500 * Failure: FALSE
503 static BOOL ODBC_LoadDriverManager(void)
505 const char *s = getenv("LIB_ODBC_DRIVER_MANAGER");
506 char error[256];
508 #ifdef SONAME_LIBODBC
509 if (!s || !s[0]) s = SONAME_LIBODBC;
510 #endif
511 if (!s || !s[0]) goto failed;
513 dmHandle = wine_dlopen(s, RTLD_LAZY | RTLD_GLOBAL, error, sizeof(error));
515 if (dmHandle != NULL)
517 TRACE("Opened library %s\n", s);
518 nErrorType = ERROR_FREE;
519 return TRUE;
521 failed:
522 ERR_(winediag)("failed to open library %s: %s\n", debugstr_a(s), error);
523 nErrorType = ERROR_LIBRARY_NOT_FOUND;
524 return FALSE;
528 /***********************************************************************
529 * ODBC_LoadDMFunctions [Internal] Populate function table.
531 * PARAMS
533 * RETURNS
534 * Success: TRUE
535 * Failure: FALSE
538 static BOOL ODBC_LoadDMFunctions(void)
540 char error[256];
542 if (dmHandle == NULL)
543 return FALSE;
545 #define LOAD_FUNC(name) \
546 if ((p##name = wine_dlsym( dmHandle, #name, error, sizeof(error) ))); \
547 else WARN( "Failed to load %s: %s\n", #name, error )
549 LOAD_FUNC(SQLAllocConnect);
550 LOAD_FUNC(SQLAllocEnv);
551 LOAD_FUNC(SQLAllocHandle);
552 LOAD_FUNC(SQLAllocHandleStd);
553 LOAD_FUNC(SQLAllocStmt);
554 LOAD_FUNC(SQLBindCol);
555 LOAD_FUNC(SQLBindParam);
556 LOAD_FUNC(SQLBindParameter);
557 LOAD_FUNC(SQLBrowseConnect);
558 LOAD_FUNC(SQLBrowseConnectW);
559 LOAD_FUNC(SQLBulkOperations);
560 LOAD_FUNC(SQLCancel);
561 LOAD_FUNC(SQLCloseCursor);
562 LOAD_FUNC(SQLColAttribute);
563 LOAD_FUNC(SQLColAttributeW);
564 LOAD_FUNC(SQLColAttributes);
565 LOAD_FUNC(SQLColAttributesW);
566 LOAD_FUNC(SQLColumnPrivileges);
567 LOAD_FUNC(SQLColumnPrivilegesW);
568 LOAD_FUNC(SQLColumns);
569 LOAD_FUNC(SQLColumnsW);
570 LOAD_FUNC(SQLConnect);
571 LOAD_FUNC(SQLConnectW);
572 LOAD_FUNC(SQLCopyDesc);
573 LOAD_FUNC(SQLDataSources);
574 LOAD_FUNC(SQLDataSourcesA);
575 LOAD_FUNC(SQLDataSourcesW);
576 LOAD_FUNC(SQLDescribeCol);
577 LOAD_FUNC(SQLDescribeColW);
578 LOAD_FUNC(SQLDescribeParam);
579 LOAD_FUNC(SQLDisconnect);
580 LOAD_FUNC(SQLDriverConnect);
581 LOAD_FUNC(SQLDriverConnectW);
582 LOAD_FUNC(SQLDrivers);
583 LOAD_FUNC(SQLDriversW);
584 LOAD_FUNC(SQLEndTran);
585 LOAD_FUNC(SQLError);
586 LOAD_FUNC(SQLErrorW);
587 LOAD_FUNC(SQLExecDirect);
588 LOAD_FUNC(SQLExecDirectW);
589 LOAD_FUNC(SQLExecute);
590 LOAD_FUNC(SQLExtendedFetch);
591 LOAD_FUNC(SQLFetch);
592 LOAD_FUNC(SQLFetchScroll);
593 LOAD_FUNC(SQLForeignKeys);
594 LOAD_FUNC(SQLForeignKeysW);
595 LOAD_FUNC(SQLFreeConnect);
596 LOAD_FUNC(SQLFreeEnv);
597 LOAD_FUNC(SQLFreeHandle);
598 LOAD_FUNC(SQLFreeStmt);
599 LOAD_FUNC(SQLGetConnectAttr);
600 LOAD_FUNC(SQLGetConnectAttrW);
601 LOAD_FUNC(SQLGetConnectOption);
602 LOAD_FUNC(SQLGetConnectOptionW);
603 LOAD_FUNC(SQLGetCursorName);
604 LOAD_FUNC(SQLGetCursorNameW);
605 LOAD_FUNC(SQLGetData);
606 LOAD_FUNC(SQLGetDescField);
607 LOAD_FUNC(SQLGetDescFieldW);
608 LOAD_FUNC(SQLGetDescRec);
609 LOAD_FUNC(SQLGetDescRecW);
610 LOAD_FUNC(SQLGetDiagField);
611 LOAD_FUNC(SQLGetDiagFieldW);
612 LOAD_FUNC(SQLGetDiagRec);
613 LOAD_FUNC(SQLGetDiagRecW);
614 LOAD_FUNC(SQLGetEnvAttr);
615 LOAD_FUNC(SQLGetFunctions);
616 LOAD_FUNC(SQLGetInfo);
617 LOAD_FUNC(SQLGetInfoW);
618 LOAD_FUNC(SQLGetStmtAttr);
619 LOAD_FUNC(SQLGetStmtAttrW);
620 LOAD_FUNC(SQLGetStmtOption);
621 LOAD_FUNC(SQLGetTypeInfo);
622 LOAD_FUNC(SQLGetTypeInfoW);
623 LOAD_FUNC(SQLMoreResults);
624 LOAD_FUNC(SQLNativeSql);
625 LOAD_FUNC(SQLNativeSqlW);
626 LOAD_FUNC(SQLNumParams);
627 LOAD_FUNC(SQLNumResultCols);
628 LOAD_FUNC(SQLParamData);
629 LOAD_FUNC(SQLParamOptions);
630 LOAD_FUNC(SQLPrepare);
631 LOAD_FUNC(SQLPrepareW);
632 LOAD_FUNC(SQLPrimaryKeys);
633 LOAD_FUNC(SQLPrimaryKeysW);
634 LOAD_FUNC(SQLProcedureColumns);
635 LOAD_FUNC(SQLProcedureColumnsW);
636 LOAD_FUNC(SQLProcedures);
637 LOAD_FUNC(SQLProceduresW);
638 LOAD_FUNC(SQLPutData);
639 LOAD_FUNC(SQLRowCount);
640 LOAD_FUNC(SQLSetConnectAttr);
641 LOAD_FUNC(SQLSetConnectAttrW);
642 LOAD_FUNC(SQLSetConnectOption);
643 LOAD_FUNC(SQLSetConnectOptionW);
644 LOAD_FUNC(SQLSetCursorName);
645 LOAD_FUNC(SQLSetCursorNameW);
646 LOAD_FUNC(SQLSetDescField);
647 LOAD_FUNC(SQLSetDescFieldW);
648 LOAD_FUNC(SQLSetDescRec);
649 LOAD_FUNC(SQLSetEnvAttr);
650 LOAD_FUNC(SQLSetParam);
651 LOAD_FUNC(SQLSetPos);
652 LOAD_FUNC(SQLSetScrollOptions);
653 LOAD_FUNC(SQLSetStmtAttr);
654 LOAD_FUNC(SQLSetStmtAttrW);
655 LOAD_FUNC(SQLSetStmtOption);
656 LOAD_FUNC(SQLSpecialColumns);
657 LOAD_FUNC(SQLSpecialColumnsW);
658 LOAD_FUNC(SQLStatistics);
659 LOAD_FUNC(SQLStatisticsW);
660 LOAD_FUNC(SQLTablePrivileges);
661 LOAD_FUNC(SQLTablePrivilegesW);
662 LOAD_FUNC(SQLTables);
663 LOAD_FUNC(SQLTablesW);
664 LOAD_FUNC(SQLTransact);
665 #undef LOAD_FUNC
667 return TRUE;
671 /*************************************************************************
672 * SQLAllocConnect [ODBC32.001]
674 SQLRETURN WINAPI SQLAllocConnect(SQLHENV EnvironmentHandle, SQLHDBC *ConnectionHandle)
676 SQLRETURN ret;
677 TRACE("(EnvironmentHandle %p)\n",EnvironmentHandle);
679 if (!pSQLAllocConnect)
681 *ConnectionHandle = SQL_NULL_HDBC;
682 TRACE("Not ready\n");
683 return SQL_ERROR;
686 ret = pSQLAllocConnect(EnvironmentHandle, ConnectionHandle);
687 TRACE("Returns %d, Handle %p\n", ret, *ConnectionHandle);
688 return ret;
692 /*************************************************************************
693 * SQLAllocEnv [ODBC32.002]
695 SQLRETURN WINAPI SQLAllocEnv(SQLHENV *EnvironmentHandle)
697 SQLRETURN ret;
698 TRACE("\n");
700 if (!pSQLAllocEnv)
702 *EnvironmentHandle = SQL_NULL_HENV;
703 TRACE("Not ready\n");
704 return SQL_ERROR;
707 ret = pSQLAllocEnv(EnvironmentHandle);
708 TRACE("Returns %d, EnvironmentHandle %p\n", ret, *EnvironmentHandle);
709 return ret;
713 /*************************************************************************
714 * SQLAllocHandle [ODBC32.024]
716 SQLRETURN WINAPI SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, SQLHANDLE *OutputHandle)
718 SQLRETURN ret;
719 TRACE("(Type %d, Handle %p)\n", HandleType, InputHandle);
721 if (!pSQLAllocHandle)
723 if (nErrorType == ERROR_LIBRARY_NOT_FOUND)
724 WARN("ProxyODBC: Cannot load ODBC driver manager library.\n");
726 if (HandleType == SQL_HANDLE_ENV)
727 *OutputHandle = SQL_NULL_HENV;
728 else if (HandleType == SQL_HANDLE_DBC)
729 *OutputHandle = SQL_NULL_HDBC;
730 else if (HandleType == SQL_HANDLE_STMT)
731 *OutputHandle = SQL_NULL_HSTMT;
732 else if (HandleType == SQL_HANDLE_DESC)
733 *OutputHandle = SQL_NULL_HDESC;
735 TRACE ("Not ready\n");
736 return SQL_ERROR;
739 ret = pSQLAllocHandle(HandleType, InputHandle, OutputHandle);
740 TRACE("Returns %d, Handle %p\n", ret, *OutputHandle);
741 return ret;
745 /*************************************************************************
746 * SQLAllocStmt [ODBC32.003]
748 SQLRETURN WINAPI SQLAllocStmt(SQLHDBC ConnectionHandle, SQLHSTMT *StatementHandle)
750 SQLRETURN ret;
752 TRACE("(Connection %p)\n", ConnectionHandle);
754 if (!pSQLAllocStmt)
756 *StatementHandle = SQL_NULL_HSTMT;
757 TRACE ("Not ready\n");
758 return SQL_ERROR;
761 ret = pSQLAllocStmt(ConnectionHandle, StatementHandle);
762 TRACE ("Returns %d, Handle %p\n", ret, *StatementHandle);
763 return ret;
767 /*************************************************************************
768 * SQLAllocHandleStd [ODBC32.077]
770 SQLRETURN WINAPI SQLAllocHandleStd( SQLSMALLINT HandleType,
771 SQLHANDLE InputHandle, SQLHANDLE *OutputHandle)
773 TRACE("ProxyODBC: SQLAllocHandleStd.\n");
775 if (!pSQLAllocHandleStd)
777 if (nErrorType == ERROR_LIBRARY_NOT_FOUND)
778 WARN("ProxyODBC: Cannot load ODBC driver manager library.\n");
780 if (HandleType == SQL_HANDLE_ENV)
781 *OutputHandle = SQL_NULL_HENV;
782 else if (HandleType == SQL_HANDLE_DBC)
783 *OutputHandle = SQL_NULL_HDBC;
784 else if (HandleType == SQL_HANDLE_STMT)
785 *OutputHandle = SQL_NULL_HSTMT;
786 else if (HandleType == SQL_HANDLE_DESC)
787 *OutputHandle = SQL_NULL_HDESC;
789 return SQL_ERROR;
792 return pSQLAllocHandleStd(HandleType, InputHandle, OutputHandle);
796 /*************************************************************************
797 * SQLBindCol [ODBC32.004]
799 SQLRETURN WINAPI SQLBindCol(SQLHSTMT StatementHandle,
800 SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
801 SQLPOINTER TargetValue, SQLLEN BufferLength,
802 SQLLEN *StrLen_or_Ind)
804 TRACE("\n");
806 if (!pSQLBindCol)
808 TRACE ("Not ready\n");
809 return SQL_ERROR;
812 return pSQLBindCol(StatementHandle, ColumnNumber, TargetType,
813 TargetValue, BufferLength, StrLen_or_Ind);
817 /*************************************************************************
818 * SQLBindParam [ODBC32.025]
820 SQLRETURN WINAPI SQLBindParam(SQLHSTMT StatementHandle,
821 SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
822 SQLSMALLINT ParameterType, SQLULEN LengthPrecision,
823 SQLSMALLINT ParameterScale, SQLPOINTER ParameterValue,
824 SQLLEN *StrLen_or_Ind)
826 TRACE("\n");
828 if (!pSQLBindParam) return SQL_ERROR;
829 return pSQLBindParam(StatementHandle, ParameterNumber, ValueType,
830 ParameterType, LengthPrecision, ParameterScale,
831 ParameterValue, StrLen_or_Ind);
835 /*************************************************************************
836 * SQLCancel [ODBC32.005]
838 SQLRETURN WINAPI SQLCancel(SQLHSTMT StatementHandle)
840 TRACE("\n");
842 if (!pSQLCancel) return SQL_ERROR;
843 return pSQLCancel(StatementHandle);
847 /*************************************************************************
848 * SQLCloseCursor [ODBC32.026]
850 SQLRETURN WINAPI SQLCloseCursor(SQLHSTMT StatementHandle)
852 SQLRETURN ret;
853 TRACE("(Handle %p)\n", StatementHandle);
855 if (!pSQLCloseCursor) return SQL_ERROR;
857 ret = pSQLCloseCursor(StatementHandle);
858 TRACE("Returns %d\n", ret);
859 return ret;
863 /*************************************************************************
864 * SQLColAttribute [ODBC32.027]
866 SQLRETURN WINAPI SQLColAttribute (SQLHSTMT StatementHandle,
867 SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
868 SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength,
869 SQLSMALLINT *StringLength, SQLLEN *NumericAttribute)
871 TRACE("\n");
873 if (!pSQLColAttribute) return SQL_ERROR;
874 return pSQLColAttribute(StatementHandle, ColumnNumber, FieldIdentifier,
875 CharacterAttribute, BufferLength, StringLength, NumericAttribute);
879 /*************************************************************************
880 * SQLColumns [ODBC32.040]
882 SQLRETURN WINAPI SQLColumns(SQLHSTMT StatementHandle,
883 SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
884 SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
885 SQLCHAR *TableName, SQLSMALLINT NameLength3,
886 SQLCHAR *ColumnName, SQLSMALLINT NameLength4)
888 TRACE("\n");
890 if (!pSQLColumns) return SQL_ERROR;
891 return pSQLColumns(StatementHandle, CatalogName, NameLength1,
892 SchemaName, NameLength2, TableName, NameLength3, ColumnName, NameLength4);
896 /*************************************************************************
897 * SQLConnect [ODBC32.007]
899 SQLRETURN WINAPI SQLConnect(SQLHDBC ConnectionHandle,
900 SQLCHAR *ServerName, SQLSMALLINT NameLength1,
901 SQLCHAR *UserName, SQLSMALLINT NameLength2,
902 SQLCHAR *Authentication, SQLSMALLINT NameLength3)
904 SQLRETURN ret;
905 TRACE("(Server=%.*s)\n",NameLength1, ServerName);
907 if (!pSQLConnect) return SQL_ERROR;
909 ret = pSQLConnect(ConnectionHandle, ServerName, NameLength1,
910 UserName, NameLength2, Authentication, NameLength3);
912 TRACE("Returns %d\n", ret);
913 return ret;
917 /*************************************************************************
918 * SQLCopyDesc [ODBC32.028]
920 SQLRETURN WINAPI SQLCopyDesc(SQLHDESC SourceDescHandle, SQLHDESC TargetDescHandle)
922 TRACE("\n");
924 if (!pSQLCopyDesc) return SQL_ERROR;
925 return pSQLCopyDesc(SourceDescHandle, TargetDescHandle);
929 /*************************************************************************
930 * SQLDataSources [ODBC32.057]
932 SQLRETURN WINAPI SQLDataSources(SQLHENV EnvironmentHandle,
933 SQLUSMALLINT Direction, SQLCHAR *ServerName,
934 SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
935 SQLCHAR *Description, SQLSMALLINT BufferLength2,
936 SQLSMALLINT *NameLength2)
938 SQLRETURN ret;
940 TRACE("(EnvironmentHandle %p)\n", EnvironmentHandle);
942 if (!pSQLDataSources) return SQL_ERROR;
944 ret = pSQLDataSources(EnvironmentHandle, Direction, ServerName,
945 BufferLength1, NameLength1, Description, BufferLength2, NameLength2);
947 if (TRACE_ON(odbc))
949 TRACE("Returns %d \t", ret);
950 if (NameLength1 && *NameLength1 > 0)
951 TRACE("DataSource = %s,", ServerName);
952 if (NameLength2 && *NameLength2 > 0)
953 TRACE(" Description = %s", Description);
954 TRACE("\n");
957 return ret;
960 SQLRETURN WINAPI SQLDataSourcesA(SQLHENV EnvironmentHandle,
961 SQLUSMALLINT Direction, SQLCHAR *ServerName,
962 SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
963 SQLCHAR *Description, SQLSMALLINT BufferLength2,
964 SQLSMALLINT *NameLength2)
966 SQLRETURN ret;
968 TRACE("EnvironmentHandle = %p\n", EnvironmentHandle);
970 if (!pSQLDataSourcesA) return SQL_ERROR;
972 ret = pSQLDataSourcesA(EnvironmentHandle, Direction, ServerName,
973 BufferLength1, NameLength1, Description, BufferLength2, NameLength2);
974 if (TRACE_ON(odbc))
976 TRACE("Returns %d \t", ret);
977 if (NameLength1 && *NameLength1 > 0)
978 TRACE("DataSource = %s,", ServerName);
979 if (NameLength2 && *NameLength2 > 0)
980 TRACE(" Description = %s", Description);
981 TRACE("\n");
984 return ret;
987 /*************************************************************************
988 * SQLDescribeCol [ODBC32.008]
990 SQLRETURN WINAPI SQLDescribeCol(SQLHSTMT StatementHandle,
991 SQLUSMALLINT ColumnNumber, SQLCHAR *ColumnName,
992 SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
993 SQLSMALLINT *DataType, SQLULEN *ColumnSize,
994 SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
996 TRACE("\n");
998 if (!pSQLDescribeCol) return SQL_ERROR;
999 return pSQLDescribeCol(StatementHandle, ColumnNumber, ColumnName,
1000 BufferLength, NameLength, DataType, ColumnSize, DecimalDigits, Nullable);
1004 /*************************************************************************
1005 * SQLDisconnect [ODBC32.009]
1007 SQLRETURN WINAPI SQLDisconnect(SQLHDBC ConnectionHandle)
1009 SQLRETURN ret;
1010 TRACE("(Handle %p)\n", ConnectionHandle);
1012 if (!pSQLDisconnect) return SQL_ERROR;
1014 ret = pSQLDisconnect(ConnectionHandle);
1015 TRACE("Returns %d\n", ret);
1016 return ret;
1020 /*************************************************************************
1021 * SQLEndTran [ODBC32.029]
1023 SQLRETURN WINAPI SQLEndTran(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT CompletionType)
1025 TRACE("\n");
1027 if (!pSQLEndTran) return SQL_ERROR;
1028 return pSQLEndTran(HandleType, Handle, CompletionType);
1032 /*************************************************************************
1033 * SQLError [ODBC32.010]
1035 SQLRETURN WINAPI SQLError(SQLHENV EnvironmentHandle,
1036 SQLHDBC ConnectionHandle, SQLHSTMT StatementHandle,
1037 SQLCHAR *Sqlstate, SQLINTEGER *NativeError,
1038 SQLCHAR *MessageText, SQLSMALLINT BufferLength,
1039 SQLSMALLINT *TextLength)
1041 SQLRETURN ret;
1043 TRACE("(EnvironmentHandle %p, ConnectionHandle %p, StatementHandle %p, BufferLength %d)\n",
1044 EnvironmentHandle, ConnectionHandle, StatementHandle, BufferLength);
1046 if (!pSQLError) return SQL_ERROR;
1047 ret = pSQLError(EnvironmentHandle, ConnectionHandle, StatementHandle,
1048 Sqlstate, NativeError, MessageText, BufferLength, TextLength);
1049 if (ret == SQL_SUCCESS)
1050 TRACE("SQLState %s, Error %d, Text %s, Textlen %d\n",
1051 debugstr_an((char *)Sqlstate, 5), *NativeError,
1052 debugstr_an((char *)MessageText, *TextLength), *TextLength);
1053 else
1054 TRACE("Returns %d\n", ret);
1055 return ret;
1059 /*************************************************************************
1060 * SQLExecDirect [ODBC32.011]
1062 SQLRETURN WINAPI SQLExecDirect(SQLHSTMT StatementHandle, SQLCHAR *StatementText, SQLINTEGER TextLength)
1064 TRACE("\n");
1066 if (!pSQLExecDirect) return SQL_ERROR;
1067 return pSQLExecDirect(StatementHandle, StatementText, TextLength);
1071 /*************************************************************************
1072 * SQLExecute [ODBC32.012]
1074 SQLRETURN WINAPI SQLExecute(SQLHSTMT StatementHandle)
1076 TRACE("\n");
1078 if (!pSQLExecute) return SQL_ERROR;
1079 return pSQLExecute(StatementHandle);
1083 /*************************************************************************
1084 * SQLFetch [ODBC32.013]
1086 SQLRETURN WINAPI SQLFetch(SQLHSTMT StatementHandle)
1088 TRACE("\n");
1090 if (!pSQLFetch) return SQL_ERROR;
1091 return pSQLFetch(StatementHandle);
1095 /*************************************************************************
1096 * SQLFetchScroll [ODBC32.030]
1098 SQLRETURN WINAPI SQLFetchScroll(SQLHSTMT StatementHandle, SQLSMALLINT FetchOrientation, SQLLEN FetchOffset)
1100 TRACE("\n");
1102 if (!pSQLFetchScroll) return SQL_ERROR;
1103 return pSQLFetchScroll(StatementHandle, FetchOrientation, FetchOffset);
1107 /*************************************************************************
1108 * SQLFreeConnect [ODBC32.014]
1110 SQLRETURN WINAPI SQLFreeConnect(SQLHDBC ConnectionHandle)
1112 SQLRETURN ret;
1113 TRACE("(Handle %p)\n", ConnectionHandle);
1115 if (!pSQLFreeConnect) return SQL_ERROR;
1117 ret = pSQLFreeConnect(ConnectionHandle);
1118 TRACE("Returns %d\n", ret);
1119 return ret;
1123 /*************************************************************************
1124 * SQLFreeEnv [ODBC32.015]
1126 SQLRETURN WINAPI SQLFreeEnv(SQLHENV EnvironmentHandle)
1128 SQLRETURN ret;
1129 TRACE("(EnvironmentHandle %p)\n",EnvironmentHandle);
1131 if (!pSQLFreeEnv) return SQL_ERROR;
1133 ret = pSQLFreeEnv(EnvironmentHandle);
1134 TRACE("Returns %d\n", ret);
1135 return ret;
1139 /*************************************************************************
1140 * SQLFreeHandle [ODBC32.031]
1142 SQLRETURN WINAPI SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle)
1144 SQLRETURN ret;
1145 TRACE("(Type %d, Handle %p)\n", HandleType, Handle);
1147 if (!pSQLFreeHandle) return SQL_ERROR;
1149 ret = pSQLFreeHandle(HandleType, Handle);
1150 TRACE ("Returns %d\n", ret);
1151 return ret;
1155 /*************************************************************************
1156 * SQLFreeStmt [ODBC32.016]
1158 SQLRETURN WINAPI SQLFreeStmt(SQLHSTMT StatementHandle, SQLUSMALLINT Option)
1160 SQLRETURN ret;
1161 TRACE("(Handle %p, Option %d)\n", StatementHandle, Option);
1163 if (!pSQLFreeStmt) return SQL_ERROR;
1165 ret = pSQLFreeStmt(StatementHandle, Option);
1166 TRACE("Returns %d\n", ret);
1167 return ret;
1171 /*************************************************************************
1172 * SQLGetConnectAttr [ODBC32.032]
1174 SQLRETURN WINAPI SQLGetConnectAttr(SQLHDBC ConnectionHandle,
1175 SQLINTEGER Attribute, SQLPOINTER Value,
1176 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
1178 TRACE("\n");
1180 if (!pSQLGetConnectAttr) return SQL_ERROR;
1181 return pSQLGetConnectAttr(ConnectionHandle, Attribute, Value,
1182 BufferLength, StringLength);
1186 /*************************************************************************
1187 * SQLGetConnectOption [ODBC32.042]
1189 SQLRETURN WINAPI SQLGetConnectOption(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLPOINTER Value)
1191 TRACE("\n");
1193 if (!pSQLGetConnectOption) return SQL_ERROR;
1194 return pSQLGetConnectOption(ConnectionHandle, Option, Value);
1198 /*************************************************************************
1199 * SQLGetCursorName [ODBC32.017]
1201 SQLRETURN WINAPI SQLGetCursorName(SQLHSTMT StatementHandle,
1202 SQLCHAR *CursorName, SQLSMALLINT BufferLength,
1203 SQLSMALLINT *NameLength)
1205 TRACE("\n");
1207 if (!pSQLGetCursorName) return SQL_ERROR;
1208 return pSQLGetCursorName(StatementHandle, CursorName, BufferLength, NameLength);
1212 /*************************************************************************
1213 * SQLGetData [ODBC32.043]
1215 SQLRETURN WINAPI SQLGetData(SQLHSTMT StatementHandle,
1216 SQLUSMALLINT ColumnNumber, SQLSMALLINT TargetType,
1217 SQLPOINTER TargetValue, SQLLEN BufferLength,
1218 SQLLEN *StrLen_or_Ind)
1220 TRACE("\n");
1222 if (!pSQLGetData) return SQL_ERROR;
1223 return pSQLGetData(StatementHandle, ColumnNumber, TargetType,
1224 TargetValue, BufferLength, StrLen_or_Ind);
1228 /*************************************************************************
1229 * SQLGetDescField [ODBC32.033]
1231 SQLRETURN WINAPI SQLGetDescField(SQLHDESC DescriptorHandle,
1232 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
1233 SQLPOINTER Value, SQLINTEGER BufferLength,
1234 SQLINTEGER *StringLength)
1236 TRACE("\n");
1238 if (!pSQLGetDescField) return SQL_ERROR;
1239 return pSQLGetDescField(DescriptorHandle, RecNumber, FieldIdentifier,
1240 Value, BufferLength, StringLength);
1244 /*************************************************************************
1245 * SQLGetDescRec [ODBC32.034]
1247 SQLRETURN WINAPI SQLGetDescRec(SQLHDESC DescriptorHandle,
1248 SQLSMALLINT RecNumber, SQLCHAR *Name,
1249 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
1250 SQLSMALLINT *Type, SQLSMALLINT *SubType,
1251 SQLLEN *Length, SQLSMALLINT *Precision,
1252 SQLSMALLINT *Scale, SQLSMALLINT *Nullable)
1254 TRACE("\n");
1256 if (!pSQLGetDescRec) return SQL_ERROR;
1257 return pSQLGetDescRec(DescriptorHandle, RecNumber, Name, BufferLength,
1258 StringLength, Type, SubType, Length, Precision, Scale, Nullable);
1262 /*************************************************************************
1263 * SQLGetDiagField [ODBC32.035]
1265 SQLRETURN WINAPI SQLGetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle,
1266 SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier,
1267 SQLPOINTER DiagInfo, SQLSMALLINT BufferLength,
1268 SQLSMALLINT *StringLength)
1270 TRACE("\n");
1272 if (!pSQLGetDiagField) return SQL_ERROR;
1273 return pSQLGetDiagField(HandleType, Handle, RecNumber, DiagIdentifier,
1274 DiagInfo, BufferLength, StringLength);
1278 /*************************************************************************
1279 * SQLGetDiagRec [ODBC32.036]
1281 SQLRETURN WINAPI SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle,
1282 SQLSMALLINT RecNumber, SQLCHAR *Sqlstate,
1283 SQLINTEGER *NativeError, SQLCHAR *MessageText,
1284 SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
1286 TRACE("\n");
1288 if (!pSQLGetDiagRec) return SQL_ERROR;
1289 return pSQLGetDiagRec(HandleType, Handle, RecNumber, Sqlstate, NativeError,
1290 MessageText, BufferLength, TextLength);
1294 /*************************************************************************
1295 * SQLGetEnvAttr [ODBC32.037]
1297 SQLRETURN WINAPI SQLGetEnvAttr(SQLHENV EnvironmentHandle,
1298 SQLINTEGER Attribute, SQLPOINTER Value,
1299 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
1301 TRACE("\n");
1303 if (!pSQLGetEnvAttr) return SQL_ERROR;
1304 return pSQLGetEnvAttr(EnvironmentHandle, Attribute, Value, BufferLength, StringLength);
1308 /*************************************************************************
1309 * SQLGetFunctions [ODBC32.044]
1311 SQLRETURN WINAPI SQLGetFunctions(SQLHDBC ConnectionHandle, SQLUSMALLINT FunctionId, SQLUSMALLINT *Supported)
1313 TRACE("\n");
1315 if (!pSQLGetFunctions) return SQL_ERROR;
1316 return pSQLGetFunctions(ConnectionHandle, FunctionId, Supported);
1320 /*************************************************************************
1321 * SQLGetInfo [ODBC32.045]
1323 SQLRETURN WINAPI SQLGetInfo(SQLHDBC ConnectionHandle,
1324 SQLUSMALLINT InfoType, SQLPOINTER InfoValue,
1325 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
1327 TRACE("\n");
1329 if (!pSQLGetInfo) return SQL_ERROR;
1330 return pSQLGetInfo(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLength);
1334 /*************************************************************************
1335 * SQLGetStmtAttr [ODBC32.038]
1337 SQLRETURN WINAPI SQLGetStmtAttr(SQLHSTMT StatementHandle,
1338 SQLINTEGER Attribute, SQLPOINTER Value,
1339 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
1341 TRACE("\n");
1343 if (!pSQLGetStmtAttr) return SQL_ERROR;
1344 return pSQLGetStmtAttr(StatementHandle, Attribute, Value, BufferLength, StringLength);
1348 /*************************************************************************
1349 * SQLGetStmtOption [ODBC32.046]
1351 SQLRETURN WINAPI SQLGetStmtOption(SQLHSTMT StatementHandle, SQLUSMALLINT Option, SQLPOINTER Value)
1353 TRACE("\n");
1355 if (!pSQLGetStmtOption) return SQL_ERROR;
1356 return pSQLGetStmtOption(StatementHandle, Option, Value);
1360 /*************************************************************************
1361 * SQLGetTypeInfo [ODBC32.047]
1363 SQLRETURN WINAPI SQLGetTypeInfo(SQLHSTMT StatementHandle, SQLSMALLINT DataType)
1365 TRACE("\n");
1367 if (!pSQLGetTypeInfo) return SQL_ERROR;
1368 return pSQLGetTypeInfo(StatementHandle, DataType);
1372 /*************************************************************************
1373 * SQLNumResultCols [ODBC32.018]
1375 SQLRETURN WINAPI SQLNumResultCols(SQLHSTMT StatementHandle, SQLSMALLINT *ColumnCount)
1377 TRACE("\n");
1379 if (!pSQLNumResultCols) return SQL_ERROR;
1380 return pSQLNumResultCols(StatementHandle, ColumnCount);
1384 /*************************************************************************
1385 * SQLParamData [ODBC32.048]
1387 SQLRETURN WINAPI SQLParamData(SQLHSTMT StatementHandle, SQLPOINTER *Value)
1389 TRACE("\n");
1391 if (!pSQLParamData) return SQL_ERROR;
1392 return pSQLParamData(StatementHandle, Value);
1396 /*************************************************************************
1397 * SQLPrepare [ODBC32.019]
1399 SQLRETURN WINAPI SQLPrepare(SQLHSTMT StatementHandle, SQLCHAR *StatementText, SQLINTEGER TextLength)
1401 TRACE("\n");
1403 if (!pSQLPrepare) return SQL_ERROR;
1404 return pSQLPrepare(StatementHandle, StatementText, TextLength);
1408 /*************************************************************************
1409 * SQLPutData [ODBC32.049]
1411 SQLRETURN WINAPI SQLPutData(SQLHSTMT StatementHandle, SQLPOINTER Data, SQLLEN StrLen_or_Ind)
1413 TRACE("\n");
1415 if (!pSQLPutData) return SQL_ERROR;
1416 return pSQLPutData(StatementHandle, Data, StrLen_or_Ind);
1420 /*************************************************************************
1421 * SQLRowCount [ODBC32.020]
1423 SQLRETURN WINAPI SQLRowCount(SQLHSTMT StatementHandle, SQLLEN *RowCount)
1425 TRACE("\n");
1427 if (!pSQLRowCount) return SQL_ERROR;
1428 return pSQLRowCount(StatementHandle, RowCount);
1432 /*************************************************************************
1433 * SQLSetConnectAttr [ODBC32.039]
1435 SQLRETURN WINAPI SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribute,
1436 SQLPOINTER Value, SQLINTEGER StringLength)
1438 TRACE("\n");
1440 if (!pSQLSetConnectAttr) return SQL_ERROR;
1441 return pSQLSetConnectAttr(ConnectionHandle, Attribute, Value, StringLength);
1445 /*************************************************************************
1446 * SQLSetConnectOption [ODBC32.050]
1448 SQLRETURN WINAPI SQLSetConnectOption(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLULEN Value)
1450 TRACE("\n");
1452 if (!pSQLSetConnectOption) return SQL_ERROR;
1453 return pSQLSetConnectOption(ConnectionHandle, Option, Value);
1457 /*************************************************************************
1458 * SQLSetCursorName [ODBC32.021]
1460 SQLRETURN WINAPI SQLSetCursorName(SQLHSTMT StatementHandle, SQLCHAR *CursorName, SQLSMALLINT NameLength)
1462 TRACE("\n");
1464 if (!pSQLSetCursorName) return SQL_ERROR;
1465 return pSQLSetCursorName(StatementHandle, CursorName, NameLength);
1469 /*************************************************************************
1470 * SQLSetDescField [ODBC32.073]
1472 SQLRETURN WINAPI SQLSetDescField(SQLHDESC DescriptorHandle,
1473 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
1474 SQLPOINTER Value, SQLINTEGER BufferLength)
1476 TRACE("\n");
1478 if (!pSQLSetDescField) return SQL_ERROR;
1479 return pSQLSetDescField(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength);
1483 /*************************************************************************
1484 * SQLSetDescRec [ODBC32.074]
1486 SQLRETURN WINAPI SQLSetDescRec(SQLHDESC DescriptorHandle,
1487 SQLSMALLINT RecNumber, SQLSMALLINT Type,
1488 SQLSMALLINT SubType, SQLLEN Length,
1489 SQLSMALLINT Precision, SQLSMALLINT Scale,
1490 SQLPOINTER Data, SQLLEN *StringLength,
1491 SQLLEN *Indicator)
1493 TRACE("\n");
1495 if (!pSQLSetDescRec) return SQL_ERROR;
1496 return pSQLSetDescRec(DescriptorHandle, RecNumber, Type, SubType, Length,
1497 Precision, Scale, Data, StringLength, Indicator);
1501 /*************************************************************************
1502 * SQLSetEnvAttr [ODBC32.075]
1504 SQLRETURN WINAPI SQLSetEnvAttr(SQLHENV EnvironmentHandle,
1505 SQLINTEGER Attribute, SQLPOINTER Value,
1506 SQLINTEGER StringLength)
1508 TRACE("\n");
1510 if (!pSQLSetEnvAttr) return SQL_ERROR;
1511 return pSQLSetEnvAttr(EnvironmentHandle, Attribute, Value, StringLength);
1515 /*************************************************************************
1516 * SQLSetParam [ODBC32.022]
1518 SQLRETURN WINAPI SQLSetParam(SQLHSTMT StatementHandle,
1519 SQLUSMALLINT ParameterNumber, SQLSMALLINT ValueType,
1520 SQLSMALLINT ParameterType, SQLULEN LengthPrecision,
1521 SQLSMALLINT ParameterScale, SQLPOINTER ParameterValue,
1522 SQLLEN *StrLen_or_Ind)
1524 TRACE("\n");
1526 if (!pSQLSetParam) return SQL_ERROR;
1527 return pSQLSetParam(StatementHandle, ParameterNumber, ValueType, ParameterType, LengthPrecision,
1528 ParameterScale, ParameterValue, StrLen_or_Ind);
1532 /*************************************************************************
1533 * SQLSetStmtAttr [ODBC32.076]
1535 SQLRETURN WINAPI SQLSetStmtAttr(SQLHSTMT StatementHandle,
1536 SQLINTEGER Attribute, SQLPOINTER Value,
1537 SQLINTEGER StringLength)
1539 TRACE("\n");
1541 if (!pSQLSetStmtAttr) return SQL_ERROR;
1542 return pSQLSetStmtAttr(StatementHandle, Attribute, Value, StringLength);
1546 /*************************************************************************
1547 * SQLSetStmtOption [ODBC32.051]
1549 SQLRETURN WINAPI SQLSetStmtOption(SQLHSTMT StatementHandle, SQLUSMALLINT Option, SQLULEN Value)
1551 TRACE("\n");
1553 if (!pSQLSetStmtOption) return SQL_ERROR;
1554 return pSQLSetStmtOption(StatementHandle, Option, Value);
1558 /*************************************************************************
1559 * SQLSpecialColumns [ODBC32.052]
1561 SQLRETURN WINAPI SQLSpecialColumns(SQLHSTMT StatementHandle,
1562 SQLUSMALLINT IdentifierType, SQLCHAR *CatalogName,
1563 SQLSMALLINT NameLength1, SQLCHAR *SchemaName,
1564 SQLSMALLINT NameLength2, SQLCHAR *TableName,
1565 SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
1566 SQLUSMALLINT Nullable)
1569 if (!pSQLSpecialColumns) return SQL_ERROR;
1570 return pSQLSpecialColumns(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName,
1571 NameLength2, TableName, NameLength3, Scope, Nullable);
1575 /*************************************************************************
1576 * SQLStatistics [ODBC32.053]
1578 SQLRETURN WINAPI SQLStatistics(SQLHSTMT StatementHandle,
1579 SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
1580 SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
1581 SQLCHAR *TableName, SQLSMALLINT NameLength3,
1582 SQLUSMALLINT Unique, SQLUSMALLINT Reserved)
1584 TRACE("\n");
1586 if (!pSQLStatistics) return SQL_ERROR;
1587 return pSQLStatistics(StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2,
1588 TableName, NameLength3, Unique, Reserved);
1592 /*************************************************************************
1593 * SQLTables [ODBC32.054]
1595 SQLRETURN WINAPI SQLTables(SQLHSTMT StatementHandle,
1596 SQLCHAR *CatalogName, SQLSMALLINT NameLength1,
1597 SQLCHAR *SchemaName, SQLSMALLINT NameLength2,
1598 SQLCHAR *TableName, SQLSMALLINT NameLength3,
1599 SQLCHAR *TableType, SQLSMALLINT NameLength4)
1601 TRACE("\n");
1603 if (!pSQLTables) return SQL_ERROR;
1604 return pSQLTables(StatementHandle, CatalogName, NameLength1,
1605 SchemaName, NameLength2, TableName, NameLength3, TableType, NameLength4);
1609 /*************************************************************************
1610 * SQLTransact [ODBC32.023]
1612 SQLRETURN WINAPI SQLTransact(SQLHENV EnvironmentHandle, SQLHDBC ConnectionHandle,
1613 SQLUSMALLINT CompletionType)
1615 TRACE("\n");
1617 if (!pSQLTransact) return SQL_ERROR;
1618 return pSQLTransact(EnvironmentHandle, ConnectionHandle, CompletionType);
1622 /*************************************************************************
1623 * SQLBrowseConnect [ODBC32.055]
1625 SQLRETURN WINAPI SQLBrowseConnect(
1626 SQLHDBC hdbc,
1627 SQLCHAR *szConnStrIn,
1628 SQLSMALLINT cbConnStrIn,
1629 SQLCHAR *szConnStrOut,
1630 SQLSMALLINT cbConnStrOutMax,
1631 SQLSMALLINT *pcbConnStrOut)
1633 TRACE("\n");
1635 if (!pSQLBrowseConnect) return SQL_ERROR;
1636 return pSQLBrowseConnect(hdbc, szConnStrIn, cbConnStrIn, szConnStrOut, cbConnStrOutMax, pcbConnStrOut);
1640 /*************************************************************************
1641 * SQLBulkOperations [ODBC32.078]
1643 SQLRETURN WINAPI SQLBulkOperations(
1644 SQLHSTMT StatementHandle,
1645 SQLSMALLINT Operation)
1647 TRACE("\n");
1649 if (!pSQLBulkOperations) return SQL_ERROR;
1650 return pSQLBulkOperations(StatementHandle, Operation);
1654 /*************************************************************************
1655 * SQLColAttributes [ODBC32.006]
1657 SQLRETURN WINAPI SQLColAttributes(
1658 SQLHSTMT hstmt,
1659 SQLUSMALLINT icol,
1660 SQLUSMALLINT fDescType,
1661 SQLPOINTER rgbDesc,
1662 SQLSMALLINT cbDescMax,
1663 SQLSMALLINT *pcbDesc,
1664 SQLLEN *pfDesc)
1666 TRACE("\n");
1668 if (!pSQLColAttributes) return SQL_ERROR;
1669 return pSQLColAttributes(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
1673 /*************************************************************************
1674 * SQLColumnPrivileges [ODBC32.056]
1676 SQLRETURN WINAPI SQLColumnPrivileges(
1677 SQLHSTMT hstmt,
1678 SQLCHAR *szCatalogName,
1679 SQLSMALLINT cbCatalogName,
1680 SQLCHAR *szSchemaName,
1681 SQLSMALLINT cbSchemaName,
1682 SQLCHAR *szTableName,
1683 SQLSMALLINT cbTableName,
1684 SQLCHAR *szColumnName,
1685 SQLSMALLINT cbColumnName)
1687 TRACE("\n");
1689 if (!pSQLColumnPrivileges) return SQL_ERROR;
1690 return pSQLColumnPrivileges(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1691 szTableName, cbTableName, szColumnName, cbColumnName);
1695 /*************************************************************************
1696 * SQLDescribeParam [ODBC32.058]
1698 SQLRETURN WINAPI SQLDescribeParam(
1699 SQLHSTMT hstmt,
1700 SQLUSMALLINT ipar,
1701 SQLSMALLINT *pfSqlType,
1702 SQLULEN *pcbParamDef,
1703 SQLSMALLINT *pibScale,
1704 SQLSMALLINT *pfNullable)
1706 TRACE("\n");
1708 if (!pSQLDescribeParam) return SQL_ERROR;
1709 return pSQLDescribeParam(hstmt, ipar, pfSqlType, pcbParamDef, pibScale, pfNullable);
1713 /*************************************************************************
1714 * SQLExtendedFetch [ODBC32.059]
1716 SQLRETURN WINAPI SQLExtendedFetch(
1717 SQLHSTMT hstmt,
1718 SQLUSMALLINT fFetchType,
1719 SQLLEN irow,
1720 SQLULEN *pcrow,
1721 SQLUSMALLINT *rgfRowStatus)
1723 TRACE("\n");
1725 if (!pSQLExtendedFetch) return SQL_ERROR;
1726 return pSQLExtendedFetch(hstmt, fFetchType, irow, pcrow, rgfRowStatus);
1730 /*************************************************************************
1731 * SQLForeignKeys [ODBC32.060]
1733 SQLRETURN WINAPI SQLForeignKeys(
1734 SQLHSTMT hstmt,
1735 SQLCHAR *szPkCatalogName,
1736 SQLSMALLINT cbPkCatalogName,
1737 SQLCHAR *szPkSchemaName,
1738 SQLSMALLINT cbPkSchemaName,
1739 SQLCHAR *szPkTableName,
1740 SQLSMALLINT cbPkTableName,
1741 SQLCHAR *szFkCatalogName,
1742 SQLSMALLINT cbFkCatalogName,
1743 SQLCHAR *szFkSchemaName,
1744 SQLSMALLINT cbFkSchemaName,
1745 SQLCHAR *szFkTableName,
1746 SQLSMALLINT cbFkTableName)
1748 TRACE("\n");
1750 if (!pSQLForeignKeys) return SQL_ERROR;
1751 return pSQLForeignKeys(hstmt, szPkCatalogName, cbPkCatalogName, szPkSchemaName, cbPkSchemaName,
1752 szPkTableName, cbPkTableName, szFkCatalogName, cbFkCatalogName,
1753 szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName);
1757 /*************************************************************************
1758 * SQLMoreResults [ODBC32.061]
1760 SQLRETURN WINAPI SQLMoreResults(SQLHSTMT hstmt)
1762 TRACE("\n");
1764 if (!pSQLMoreResults) return SQL_ERROR;
1765 return pSQLMoreResults(hstmt);
1769 /*************************************************************************
1770 * SQLNativeSql [ODBC32.062]
1772 SQLRETURN WINAPI SQLNativeSql(
1773 SQLHDBC hdbc,
1774 SQLCHAR *szSqlStrIn,
1775 SQLINTEGER cbSqlStrIn,
1776 SQLCHAR *szSqlStr,
1777 SQLINTEGER cbSqlStrMax,
1778 SQLINTEGER *pcbSqlStr)
1780 TRACE("\n");
1782 if (!pSQLNativeSql) return SQL_ERROR;
1783 return pSQLNativeSql(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr);
1787 /*************************************************************************
1788 * SQLNumParams [ODBC32.063]
1790 SQLRETURN WINAPI SQLNumParams(
1791 SQLHSTMT hstmt,
1792 SQLSMALLINT *pcpar)
1794 TRACE("\n");
1796 if (!pSQLNumParams) return SQL_ERROR;
1797 return pSQLNumParams(hstmt, pcpar);
1801 /*************************************************************************
1802 * SQLParamOptions [ODBC32.064]
1804 SQLRETURN WINAPI SQLParamOptions(
1805 SQLHSTMT hstmt,
1806 SQLULEN crow,
1807 SQLULEN *pirow)
1809 TRACE("\n");
1811 if (!pSQLParamOptions) return SQL_ERROR;
1812 return pSQLParamOptions(hstmt, crow, pirow);
1816 /*************************************************************************
1817 * SQLPrimaryKeys [ODBC32.065]
1819 SQLRETURN WINAPI SQLPrimaryKeys(
1820 SQLHSTMT hstmt,
1821 SQLCHAR *szCatalogName,
1822 SQLSMALLINT cbCatalogName,
1823 SQLCHAR *szSchemaName,
1824 SQLSMALLINT cbSchemaName,
1825 SQLCHAR *szTableName,
1826 SQLSMALLINT cbTableName)
1828 TRACE("\n");
1830 if (!pSQLPrimaryKeys) return SQL_ERROR;
1831 return pSQLPrimaryKeys(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1832 szTableName, cbTableName);
1836 /*************************************************************************
1837 * SQLProcedureColumns [ODBC32.066]
1839 SQLRETURN WINAPI SQLProcedureColumns(
1840 SQLHSTMT hstmt,
1841 SQLCHAR *szCatalogName,
1842 SQLSMALLINT cbCatalogName,
1843 SQLCHAR *szSchemaName,
1844 SQLSMALLINT cbSchemaName,
1845 SQLCHAR *szProcName,
1846 SQLSMALLINT cbProcName,
1847 SQLCHAR *szColumnName,
1848 SQLSMALLINT cbColumnName)
1850 TRACE("\n");
1852 if (!pSQLProcedureColumns) return SQL_ERROR;
1853 return pSQLProcedureColumns(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1854 szProcName, cbProcName, szColumnName, cbColumnName);
1858 /*************************************************************************
1859 * SQLProcedures [ODBC32.067]
1861 SQLRETURN WINAPI SQLProcedures(
1862 SQLHSTMT hstmt,
1863 SQLCHAR *szCatalogName,
1864 SQLSMALLINT cbCatalogName,
1865 SQLCHAR *szSchemaName,
1866 SQLSMALLINT cbSchemaName,
1867 SQLCHAR *szProcName,
1868 SQLSMALLINT cbProcName)
1870 TRACE("\n");
1872 if (!pSQLProcedures) return SQL_ERROR;
1873 return pSQLProcedures(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1874 szProcName, cbProcName);
1878 /*************************************************************************
1879 * SQLSetPos [ODBC32.068]
1881 SQLRETURN WINAPI SQLSetPos(
1882 SQLHSTMT hstmt,
1883 SQLSETPOSIROW irow,
1884 SQLUSMALLINT fOption,
1885 SQLUSMALLINT fLock)
1887 TRACE("\n");
1889 if (!pSQLSetPos) return SQL_ERROR;
1890 return pSQLSetPos(hstmt, irow, fOption, fLock);
1894 /*************************************************************************
1895 * SQLTablePrivileges [ODBC32.070]
1897 SQLRETURN WINAPI SQLTablePrivileges(
1898 SQLHSTMT hstmt,
1899 SQLCHAR *szCatalogName,
1900 SQLSMALLINT cbCatalogName,
1901 SQLCHAR *szSchemaName,
1902 SQLSMALLINT cbSchemaName,
1903 SQLCHAR *szTableName,
1904 SQLSMALLINT cbTableName)
1906 TRACE("\n");
1908 if (!pSQLTablePrivileges) return SQL_ERROR;
1909 return pSQLTablePrivileges(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
1910 szTableName, cbTableName);
1914 /*************************************************************************
1915 * SQLDrivers [ODBC32.071]
1917 SQLRETURN WINAPI SQLDrivers(
1918 SQLHENV henv,
1919 SQLUSMALLINT fDirection,
1920 SQLCHAR *szDriverDesc,
1921 SQLSMALLINT cbDriverDescMax,
1922 SQLSMALLINT *pcbDriverDesc,
1923 SQLCHAR *szDriverAttributes,
1924 SQLSMALLINT cbDriverAttrMax,
1925 SQLSMALLINT *pcbDriverAttr)
1927 SQLRETURN ret;
1929 TRACE("(Direction %d)\n", fDirection);
1931 if (!pSQLDrivers) return SQL_ERROR;
1932 ret = pSQLDrivers(henv, fDirection, szDriverDesc, cbDriverDescMax, pcbDriverDesc,
1933 szDriverAttributes, cbDriverAttrMax, pcbDriverAttr);
1935 if (ret == SQL_NO_DATA && fDirection == SQL_FETCH_FIRST)
1936 ERR_(winediag)("No ODBC drivers could be found. "
1937 "Check the settings for your libodbc provider.\n");
1939 return ret;
1943 /*************************************************************************
1944 * SQLBindParameter [ODBC32.072]
1946 SQLRETURN WINAPI SQLBindParameter(
1947 SQLHSTMT hstmt,
1948 SQLUSMALLINT ipar,
1949 SQLSMALLINT fParamType,
1950 SQLSMALLINT fCType,
1951 SQLSMALLINT fSqlType,
1952 SQLULEN cbColDef,
1953 SQLSMALLINT ibScale,
1954 SQLPOINTER rgbValue,
1955 SQLLEN cbValueMax,
1956 SQLLEN *pcbValue)
1958 TRACE("\n");
1960 if (!pSQLBindParameter) return SQL_ERROR;
1961 return pSQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale,
1962 rgbValue, cbValueMax, pcbValue);
1966 /*************************************************************************
1967 * SQLDriverConnect [ODBC32.041]
1969 SQLRETURN WINAPI SQLDriverConnect(
1970 SQLHDBC hdbc,
1971 SQLHWND hwnd,
1972 SQLCHAR *conn_str_in,
1973 SQLSMALLINT len_conn_str_in,
1974 SQLCHAR *conn_str_out,
1975 SQLSMALLINT conn_str_out_max,
1976 SQLSMALLINT *ptr_conn_str_out,
1977 SQLUSMALLINT driver_completion )
1979 SQLRETURN ret;
1981 TRACE("(ConnectionString %s, Length %d)\n",
1982 debugstr_a((char *)conn_str_in), len_conn_str_in);
1984 if (!pSQLDriverConnect) return SQL_ERROR;
1985 ret = pSQLDriverConnect(hdbc, hwnd, conn_str_in, len_conn_str_in, conn_str_out,
1986 conn_str_out_max, ptr_conn_str_out, driver_completion);
1987 TRACE("Returns %d\n", ret);
1988 return ret;
1992 /*************************************************************************
1993 * SQLSetScrollOptions [ODBC32.069]
1995 SQLRETURN WINAPI SQLSetScrollOptions(
1996 SQLHSTMT statement_handle,
1997 SQLUSMALLINT f_concurrency,
1998 SQLLEN crow_keyset,
1999 SQLUSMALLINT crow_rowset )
2001 TRACE("\n");
2003 if (!pSQLSetScrollOptions) return SQL_ERROR;
2004 return pSQLSetScrollOptions(statement_handle, f_concurrency, crow_keyset, crow_rowset);
2007 static BOOL SQLColAttributes_KnownStringAttribute(SQLUSMALLINT fDescType)
2009 static const SQLUSMALLINT attrList[] =
2011 SQL_COLUMN_OWNER_NAME,
2012 SQL_COLUMN_QUALIFIER_NAME,
2013 SQL_COLUMN_LABEL,
2014 SQL_COLUMN_NAME,
2015 SQL_COLUMN_TABLE_NAME,
2016 SQL_COLUMN_TYPE_NAME,
2017 SQL_DESC_BASE_COLUMN_NAME,
2018 SQL_DESC_BASE_TABLE_NAME,
2019 SQL_DESC_CATALOG_NAME,
2020 SQL_DESC_LABEL,
2021 SQL_DESC_LITERAL_PREFIX,
2022 SQL_DESC_LITERAL_SUFFIX,
2023 SQL_DESC_LOCAL_TYPE_NAME,
2024 SQL_DESC_NAME,
2025 SQL_DESC_SCHEMA_NAME,
2026 SQL_DESC_TABLE_NAME,
2027 SQL_DESC_TYPE_NAME,
2029 unsigned int i;
2031 for (i = 0; i < sizeof(attrList) / sizeof(SQLUSMALLINT); i++) {
2032 if (attrList[i] == fDescType) return TRUE;
2034 return FALSE;
2037 /*************************************************************************
2038 * SQLColAttributesW [ODBC32.106]
2040 SQLRETURN WINAPI SQLColAttributesW(
2041 SQLHSTMT hstmt,
2042 SQLUSMALLINT icol,
2043 SQLUSMALLINT fDescType,
2044 SQLPOINTER rgbDesc,
2045 SQLSMALLINT cbDescMax,
2046 SQLSMALLINT *pcbDesc,
2047 SQLLEN *pfDesc)
2049 SQLRETURN iResult;
2051 TRACE("hstmt=%p icol=%d fDescType=%d rgbDesc=%p cbDescMax=%d pcbDesc=%p pfDesc=%p\n",
2052 hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
2054 if (!pSQLColAttributesW) return SQL_ERROR;
2056 iResult = pSQLColAttributesW(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc);
2057 if (iResult == SQL_SUCCESS && rgbDesc != NULL && SQLColAttributes_KnownStringAttribute(fDescType)) {
2059 TRACE("Dumping values fetched via SQLColAttributesW:\n");
2060 TRACE(" Attribute name : %s\n", debugstr_w(rgbDesc));
2061 TRACE(" Declared length: %d\n", *pcbDesc);
2063 if (*pcbDesc != lstrlenW(rgbDesc) * 2) {
2064 TRACE("CHEAT: resetting name length for ADO\n");
2065 *pcbDesc = lstrlenW(rgbDesc) * 2;
2068 return iResult;
2071 /*************************************************************************
2072 * SQLConnectW [ODBC32.107]
2074 SQLRETURN WINAPI SQLConnectW(SQLHDBC ConnectionHandle,
2075 WCHAR *ServerName, SQLSMALLINT NameLength1,
2076 WCHAR *UserName, SQLSMALLINT NameLength2,
2077 WCHAR *Authentication, SQLSMALLINT NameLength3)
2079 SQLRETURN ret;
2080 TRACE("(Server=%.*s)\n",NameLength1+3, debugstr_w(ServerName));
2082 if (!pSQLConnectW) return SQL_ERROR;
2084 ret = pSQLConnectW(ConnectionHandle, ServerName, NameLength1,
2085 UserName, NameLength2, Authentication, NameLength3);
2087 TRACE("Returns %d\n", ret);
2088 return ret;
2091 /*************************************************************************
2092 * SQLDescribeColW [ODBC32.108]
2094 SQLRETURN WINAPI SQLDescribeColW(SQLHSTMT StatementHandle,
2095 SQLUSMALLINT ColumnNumber, WCHAR *ColumnName,
2096 SQLSMALLINT BufferLength, SQLSMALLINT *NameLength,
2097 SQLSMALLINT *DataType, SQLULEN *ColumnSize,
2098 SQLSMALLINT *DecimalDigits, SQLSMALLINT *Nullable)
2100 SQLRETURN iResult;
2101 TRACE("\n");
2103 if (!pSQLDescribeColW) return SQL_ERROR;
2105 iResult = pSQLDescribeColW(StatementHandle, ColumnNumber, ColumnName,
2106 BufferLength, NameLength, DataType, ColumnSize,
2107 DecimalDigits, Nullable);
2108 if (iResult >= 0) {
2109 TRACE("Successfully recovered the following column information:\n");
2110 TRACE("\tRequested column index: %d\n", ColumnNumber);
2111 TRACE("\tAvailable length for column name: %d\n", BufferLength);
2112 if (NameLength != NULL)
2113 TRACE("\tActual length for column name: %d\n", *NameLength);
2114 else TRACE("\tActual length for column name: (null)\n");
2115 TRACE("\tReturned column name: %s\n", debugstr_w(ColumnName));
2117 return iResult;
2120 /*************************************************************************
2121 * SQLErrorW [ODBC32.110]
2123 SQLRETURN WINAPI SQLErrorW(SQLHENV EnvironmentHandle,
2124 SQLHDBC ConnectionHandle, SQLHSTMT StatementHandle,
2125 WCHAR *Sqlstate, SQLINTEGER *NativeError,
2126 WCHAR *MessageText, SQLSMALLINT BufferLength,
2127 SQLSMALLINT *TextLength)
2129 TRACE("\n");
2131 if (!pSQLErrorW) return SQL_ERROR;
2132 return pSQLErrorW(EnvironmentHandle, ConnectionHandle, StatementHandle,
2133 Sqlstate, NativeError, MessageText, BufferLength, TextLength);
2136 /*************************************************************************
2137 * SQLExecDirectW [ODBC32.111]
2139 SQLRETURN WINAPI SQLExecDirectW(SQLHSTMT StatementHandle,
2140 WCHAR *StatementText, SQLINTEGER TextLength)
2142 TRACE("\n");
2144 if (!pSQLExecDirectW) return SQL_ERROR;
2145 return pSQLExecDirectW(StatementHandle, StatementText, TextLength);
2148 /*************************************************************************
2149 * SQLGetCursorNameW [ODBC32.117]
2151 SQLRETURN WINAPI SQLGetCursorNameW(SQLHSTMT StatementHandle,
2152 WCHAR *CursorName, SQLSMALLINT BufferLength,
2153 SQLSMALLINT *NameLength)
2155 TRACE("\n");
2157 if (!pSQLGetCursorNameW) return SQL_ERROR;
2158 return pSQLGetCursorNameW(StatementHandle, CursorName, BufferLength, NameLength);
2161 /*************************************************************************
2162 * SQLPrepareW [ODBC32.119]
2164 SQLRETURN WINAPI SQLPrepareW(SQLHSTMT StatementHandle,
2165 WCHAR *StatementText, SQLINTEGER TextLength)
2167 TRACE("\n");
2169 if (!pSQLPrepareW) return SQL_ERROR;
2170 return pSQLPrepareW(StatementHandle, StatementText, TextLength);
2173 /*************************************************************************
2174 * SQLSetCursorNameW [ODBC32.121]
2176 SQLRETURN WINAPI SQLSetCursorNameW(SQLHSTMT StatementHandle, WCHAR *CursorName, SQLSMALLINT NameLength)
2178 TRACE("\n");
2180 if (!pSQLSetCursorNameW) return SQL_ERROR;
2181 return pSQLSetCursorNameW(StatementHandle, CursorName, NameLength);
2184 /*************************************************************************
2185 * SQLColAttributeW [ODBC32.127]
2187 SQLRETURN WINAPI SQLColAttributeW (SQLHSTMT StatementHandle,
2188 SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier,
2189 SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength,
2190 SQLSMALLINT *StringLength, SQLLEN *NumericAttribute)
2192 SQLRETURN iResult;
2194 TRACE("StatementHandle=%p ColumnNumber=%d FieldIdentifier=%d CharacterAttribute=%p BufferLength=%d StringLength=%p NumericAttribute=%p\n",
2195 StatementHandle, ColumnNumber, FieldIdentifier,
2196 CharacterAttribute, BufferLength, StringLength, NumericAttribute);
2198 if (!pSQLColAttributeW) return SQL_ERROR;
2200 iResult = pSQLColAttributeW(StatementHandle, ColumnNumber, FieldIdentifier,
2201 CharacterAttribute, BufferLength, StringLength, NumericAttribute);
2202 if (iResult == SQL_SUCCESS && CharacterAttribute != NULL && SQLColAttributes_KnownStringAttribute(FieldIdentifier)) {
2204 TRACE("Dumping values fetched via SQLColAttributeW:\n");
2205 TRACE(" Attribute name : %s\n", debugstr_w(rgbDesc));
2206 TRACE(" Declared length: %d\n", *pcbDesc);
2208 if (*StringLength != lstrlenW(CharacterAttribute) * 2) {
2209 TRACE("CHEAT: resetting name length for ADO\n");
2210 *StringLength = lstrlenW(CharacterAttribute) * 2;
2213 return iResult;
2216 /*************************************************************************
2217 * SQLGetConnectAttrW [ODBC32.132]
2219 SQLRETURN WINAPI SQLGetConnectAttrW(SQLHDBC ConnectionHandle,
2220 SQLINTEGER Attribute, SQLPOINTER Value,
2221 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
2223 TRACE("\n");
2225 if (!pSQLGetConnectAttrW) return SQL_ERROR;
2226 return pSQLGetConnectAttrW(ConnectionHandle, Attribute, Value,
2227 BufferLength, StringLength);
2230 /*************************************************************************
2231 * SQLGetDescFieldW [ODBC32.133]
2233 SQLRETURN WINAPI SQLGetDescFieldW(SQLHDESC DescriptorHandle,
2234 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
2235 SQLPOINTER Value, SQLINTEGER BufferLength,
2236 SQLINTEGER *StringLength)
2238 TRACE("\n");
2240 if (!pSQLGetDescFieldW) return SQL_ERROR;
2241 return pSQLGetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier,
2242 Value, BufferLength, StringLength);
2245 /*************************************************************************
2246 * SQLGetDescRecW [ODBC32.134]
2248 SQLRETURN WINAPI SQLGetDescRecW(SQLHDESC DescriptorHandle,
2249 SQLSMALLINT RecNumber, WCHAR *Name,
2250 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength,
2251 SQLSMALLINT *Type, SQLSMALLINT *SubType,
2252 SQLLEN *Length, SQLSMALLINT *Precision,
2253 SQLSMALLINT *Scale, SQLSMALLINT *Nullable)
2255 TRACE("\n");
2257 if (!pSQLGetDescRecW) return SQL_ERROR;
2258 return pSQLGetDescRecW(DescriptorHandle, RecNumber, Name, BufferLength,
2259 StringLength, Type, SubType, Length, Precision, Scale, Nullable);
2262 /*************************************************************************
2263 * SQLGetDiagFieldW [ODBC32.135]
2265 SQLRETURN WINAPI SQLGetDiagFieldW(SQLSMALLINT HandleType, SQLHANDLE Handle,
2266 SQLSMALLINT RecNumber, SQLSMALLINT DiagIdentifier,
2267 SQLPOINTER DiagInfo, SQLSMALLINT BufferLength,
2268 SQLSMALLINT *StringLength)
2270 TRACE("\n");
2272 if (!pSQLGetDiagFieldW) return SQL_ERROR;
2273 return pSQLGetDiagFieldW(HandleType, Handle, RecNumber, DiagIdentifier,
2274 DiagInfo, BufferLength, StringLength);
2277 /*************************************************************************
2278 * SQLGetDiagRecW [ODBC32.136]
2280 SQLRETURN WINAPI SQLGetDiagRecW(SQLSMALLINT HandleType, SQLHANDLE Handle,
2281 SQLSMALLINT RecNumber, WCHAR *Sqlstate,
2282 SQLINTEGER *NativeError, WCHAR *MessageText,
2283 SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
2285 TRACE("\n");
2287 if (!pSQLGetDiagRecW) return SQL_ERROR;
2288 return pSQLGetDiagRecW(HandleType, Handle, RecNumber, Sqlstate, NativeError,
2289 MessageText, BufferLength, TextLength);
2292 /*************************************************************************
2293 * SQLGetStmtAttrW [ODBC32.138]
2295 SQLRETURN WINAPI SQLGetStmtAttrW(SQLHSTMT StatementHandle,
2296 SQLINTEGER Attribute, SQLPOINTER Value,
2297 SQLINTEGER BufferLength, SQLINTEGER *StringLength)
2299 SQLRETURN iResult;
2301 TRACE("Attribute = (%02d) Value = %p BufferLength = (%d) StringLength = %p\n",
2302 Attribute, Value, BufferLength, StringLength);
2304 if (Value == NULL) {
2305 WARN("Unexpected NULL in Value return address\n");
2306 iResult = SQL_ERROR;
2308 } else if (StringLength == NULL) {
2309 WARN("Unexpected NULL in StringLength return address\n");
2310 iResult = SQL_ERROR;
2312 } else {
2313 if (!pSQLGetStmtAttrW) return SQL_ERROR;
2314 iResult = pSQLGetStmtAttrW(StatementHandle, Attribute, Value, BufferLength, StringLength);
2315 TRACE("returning %d...\n", iResult);
2317 return iResult;
2320 /*************************************************************************
2321 * SQLSetConnectAttrW [ODBC32.139]
2323 SQLRETURN WINAPI SQLSetConnectAttrW(SQLHDBC ConnectionHandle, SQLINTEGER Attribute,
2324 SQLPOINTER Value, SQLINTEGER StringLength)
2326 TRACE("\n");
2328 if (!pSQLSetConnectAttrW) return SQL_ERROR;
2329 return pSQLSetConnectAttrW(ConnectionHandle, Attribute, Value, StringLength);
2332 /*************************************************************************
2333 * SQLColumnsW [ODBC32.140]
2335 SQLRETURN WINAPI SQLColumnsW(SQLHSTMT StatementHandle,
2336 WCHAR *CatalogName, SQLSMALLINT NameLength1,
2337 WCHAR *SchemaName, SQLSMALLINT NameLength2,
2338 WCHAR *TableName, SQLSMALLINT NameLength3,
2339 WCHAR *ColumnName, SQLSMALLINT NameLength4)
2341 TRACE("\n");
2343 if (!pSQLColumnsW) return SQL_ERROR;
2344 return pSQLColumnsW(StatementHandle, CatalogName, NameLength1,
2345 SchemaName, NameLength2, TableName, NameLength3, ColumnName, NameLength4);
2348 /*************************************************************************
2349 * SQLDriverConnectW [ODBC32.141]
2351 SQLRETURN WINAPI SQLDriverConnectW(
2352 SQLHDBC hdbc,
2353 SQLHWND hwnd,
2354 WCHAR *conn_str_in,
2355 SQLSMALLINT len_conn_str_in,
2356 WCHAR *conn_str_out,
2357 SQLSMALLINT conn_str_out_max,
2358 SQLSMALLINT *ptr_conn_str_out,
2359 SQLUSMALLINT driver_completion )
2361 TRACE("(ConnectionString %s, Length %d)\n",
2362 debugstr_w(conn_str_in), len_conn_str_in);
2364 if (!pSQLDriverConnectW) return SQL_ERROR;
2365 return pSQLDriverConnectW(hdbc, hwnd, conn_str_in, len_conn_str_in, conn_str_out,
2366 conn_str_out_max, ptr_conn_str_out, driver_completion);
2369 /*************************************************************************
2370 * SQLGetConnectOptionW [ODBC32.142]
2372 SQLRETURN WINAPI SQLGetConnectOptionW(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLPOINTER Value)
2374 TRACE("\n");
2376 if (!pSQLGetConnectOptionW) return SQL_ERROR;
2377 return pSQLGetConnectOptionW(ConnectionHandle, Option, Value);
2380 /*************************************************************************
2381 * SQLGetInfoW [ODBC32.145]
2383 SQLRETURN WINAPI SQLGetInfoW(SQLHDBC ConnectionHandle,
2384 SQLUSMALLINT InfoType, SQLPOINTER InfoValue,
2385 SQLSMALLINT BufferLength, SQLSMALLINT *StringLength)
2387 SQLRETURN iResult;
2389 TRACE("InfoType = (%02u), InfoValue = %p, BufferLength = %d bytes\n", InfoType, InfoValue, BufferLength);
2390 if (InfoValue == NULL) {
2391 WARN("Unexpected NULL in InfoValue address\n");
2392 iResult = SQL_ERROR;
2393 } else {
2394 if (!pSQLGetInfoW) return SQL_ERROR;
2395 iResult = pSQLGetInfoW(ConnectionHandle, InfoType, InfoValue, BufferLength, StringLength);
2396 TRACE("returning %d...\n", iResult);
2398 return iResult;
2401 /*************************************************************************
2402 * SQLGetTypeInfoW [ODBC32.147]
2404 SQLRETURN WINAPI SQLGetTypeInfoW(SQLHSTMT StatementHandle, SQLSMALLINT DataType)
2406 TRACE("\n");
2408 if (!pSQLGetTypeInfoW) return SQL_ERROR;
2409 return pSQLGetTypeInfoW(StatementHandle, DataType);
2412 /*************************************************************************
2413 * SQLSetConnectOptionW [ODBC32.150]
2415 SQLRETURN WINAPI SQLSetConnectOptionW(SQLHDBC ConnectionHandle, SQLUSMALLINT Option, SQLLEN Value)
2417 TRACE("\n");
2419 if (!pSQLSetConnectOptionW) return SQL_ERROR;
2420 return pSQLSetConnectOptionW(ConnectionHandle, Option, Value);
2423 /*************************************************************************
2424 * SQLSpecialColumnsW [ODBC32.152]
2426 SQLRETURN WINAPI SQLSpecialColumnsW(SQLHSTMT StatementHandle,
2427 SQLUSMALLINT IdentifierType, SQLWCHAR *CatalogName,
2428 SQLSMALLINT NameLength1, SQLWCHAR *SchemaName,
2429 SQLSMALLINT NameLength2, SQLWCHAR *TableName,
2430 SQLSMALLINT NameLength3, SQLUSMALLINT Scope,
2431 SQLUSMALLINT Nullable)
2433 if (!pSQLSpecialColumnsW) return SQL_ERROR;
2434 return pSQLSpecialColumnsW(StatementHandle, IdentifierType, CatalogName, NameLength1, SchemaName,
2435 NameLength2, TableName, NameLength3, Scope, Nullable);
2438 /*************************************************************************
2439 * SQLStatisticsW [ODBC32.153]
2441 SQLRETURN WINAPI SQLStatisticsW(SQLHSTMT StatementHandle,
2442 SQLWCHAR *CatalogName, SQLSMALLINT NameLength1,
2443 SQLWCHAR *SchemaName, SQLSMALLINT NameLength2,
2444 SQLWCHAR *TableName, SQLSMALLINT NameLength3,
2445 SQLUSMALLINT Unique, SQLUSMALLINT Reserved)
2447 TRACE("\n");
2449 if (!pSQLStatisticsW) return SQL_ERROR;
2450 return pSQLStatisticsW(StatementHandle, CatalogName, NameLength1, SchemaName, NameLength2,
2451 TableName, NameLength3, Unique, Reserved);
2454 /*************************************************************************
2455 * SQLTablesW [ODBC32.154]
2457 SQLRETURN WINAPI SQLTablesW(SQLHSTMT StatementHandle,
2458 SQLWCHAR *CatalogName, SQLSMALLINT NameLength1,
2459 SQLWCHAR *SchemaName, SQLSMALLINT NameLength2,
2460 SQLWCHAR *TableName, SQLSMALLINT NameLength3,
2461 SQLWCHAR *TableType, SQLSMALLINT NameLength4)
2463 TRACE("\n");
2465 if (!pSQLTablesW) return SQL_ERROR;
2466 return pSQLTablesW(StatementHandle, CatalogName, NameLength1,
2467 SchemaName, NameLength2, TableName, NameLength3, TableType, NameLength4);
2470 /*************************************************************************
2471 * SQLBrowseConnectW [ODBC32.155]
2473 SQLRETURN WINAPI SQLBrowseConnectW(
2474 SQLHDBC hdbc,
2475 SQLWCHAR *szConnStrIn,
2476 SQLSMALLINT cbConnStrIn,
2477 SQLWCHAR *szConnStrOut,
2478 SQLSMALLINT cbConnStrOutMax,
2479 SQLSMALLINT *pcbConnStrOut)
2481 TRACE("\n");
2483 if (!pSQLBrowseConnectW) return SQL_ERROR;
2484 return pSQLBrowseConnectW(hdbc, szConnStrIn, cbConnStrIn, szConnStrOut,
2485 cbConnStrOutMax, pcbConnStrOut);
2488 /*************************************************************************
2489 * SQLColumnPrivilegesW [ODBC32.156]
2491 SQLRETURN WINAPI SQLColumnPrivilegesW(
2492 SQLHSTMT hstmt,
2493 SQLWCHAR *szCatalogName,
2494 SQLSMALLINT cbCatalogName,
2495 SQLWCHAR *szSchemaName,
2496 SQLSMALLINT cbSchemaName,
2497 SQLWCHAR *szTableName,
2498 SQLSMALLINT cbTableName,
2499 SQLWCHAR *szColumnName,
2500 SQLSMALLINT cbColumnName)
2502 TRACE("\n");
2504 if (!pSQLColumnPrivilegesW) return SQL_ERROR;
2505 return pSQLColumnPrivilegesW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2506 szTableName, cbTableName, szColumnName, cbColumnName);
2509 /*************************************************************************
2510 * SQLDataSourcesW [ODBC32.157]
2512 SQLRETURN WINAPI SQLDataSourcesW(SQLHENV EnvironmentHandle,
2513 SQLUSMALLINT Direction, WCHAR *ServerName,
2514 SQLSMALLINT BufferLength1, SQLSMALLINT *NameLength1,
2515 WCHAR *Description, SQLSMALLINT BufferLength2,
2516 SQLSMALLINT *NameLength2)
2518 SQLRETURN ret;
2520 TRACE("EnvironmentHandle = %p\n", EnvironmentHandle);
2522 if (!pSQLDataSourcesW) return SQL_ERROR;
2524 ret = pSQLDataSourcesW(EnvironmentHandle, Direction, ServerName,
2525 BufferLength1, NameLength1, Description, BufferLength2, NameLength2);
2527 if (TRACE_ON(odbc))
2529 TRACE("Returns %d \t", ret);
2530 if (*NameLength1 > 0)
2531 TRACE("DataSource = %s,", debugstr_w(ServerName));
2532 if (*NameLength2 > 0)
2533 TRACE(" Description = %s", debugstr_w(Description));
2534 TRACE("\n");
2537 return ret;
2540 /*************************************************************************
2541 * SQLForeignKeysW [ODBC32.160]
2543 SQLRETURN WINAPI SQLForeignKeysW(
2544 SQLHSTMT hstmt,
2545 SQLWCHAR *szPkCatalogName,
2546 SQLSMALLINT cbPkCatalogName,
2547 SQLWCHAR *szPkSchemaName,
2548 SQLSMALLINT cbPkSchemaName,
2549 SQLWCHAR *szPkTableName,
2550 SQLSMALLINT cbPkTableName,
2551 SQLWCHAR *szFkCatalogName,
2552 SQLSMALLINT cbFkCatalogName,
2553 SQLWCHAR *szFkSchemaName,
2554 SQLSMALLINT cbFkSchemaName,
2555 SQLWCHAR *szFkTableName,
2556 SQLSMALLINT cbFkTableName)
2558 TRACE("\n");
2560 if (!pSQLForeignKeysW) return SQL_ERROR;
2561 return pSQLForeignKeysW(hstmt, szPkCatalogName, cbPkCatalogName, szPkSchemaName, cbPkSchemaName,
2562 szPkTableName, cbPkTableName, szFkCatalogName, cbFkCatalogName,
2563 szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName);
2566 /*************************************************************************
2567 * SQLNativeSqlW [ODBC32.162]
2569 SQLRETURN WINAPI SQLNativeSqlW(
2570 SQLHDBC hdbc,
2571 SQLWCHAR *szSqlStrIn,
2572 SQLINTEGER cbSqlStrIn,
2573 SQLWCHAR *szSqlStr,
2574 SQLINTEGER cbSqlStrMax,
2575 SQLINTEGER *pcbSqlStr)
2577 TRACE("\n");
2579 if (!pSQLNativeSqlW) return SQL_ERROR;
2580 return pSQLNativeSqlW(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr);
2583 /*************************************************************************
2584 * SQLPrimaryKeysW [ODBC32.165]
2586 SQLRETURN WINAPI SQLPrimaryKeysW(
2587 SQLHSTMT hstmt,
2588 SQLWCHAR *szCatalogName,
2589 SQLSMALLINT cbCatalogName,
2590 SQLWCHAR *szSchemaName,
2591 SQLSMALLINT cbSchemaName,
2592 SQLWCHAR *szTableName,
2593 SQLSMALLINT cbTableName)
2595 TRACE("\n");
2597 if (!pSQLPrimaryKeysW) return SQL_ERROR;
2598 return pSQLPrimaryKeysW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2599 szTableName, cbTableName);
2602 /*************************************************************************
2603 * SQLProcedureColumnsW [ODBC32.166]
2605 SQLRETURN WINAPI SQLProcedureColumnsW(
2606 SQLHSTMT hstmt,
2607 SQLWCHAR *szCatalogName,
2608 SQLSMALLINT cbCatalogName,
2609 SQLWCHAR *szSchemaName,
2610 SQLSMALLINT cbSchemaName,
2611 SQLWCHAR *szProcName,
2612 SQLSMALLINT cbProcName,
2613 SQLWCHAR *szColumnName,
2614 SQLSMALLINT cbColumnName)
2616 TRACE("\n");
2618 if (!pSQLProcedureColumnsW) return SQL_ERROR;
2619 return pSQLProcedureColumnsW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2620 szProcName, cbProcName, szColumnName, cbColumnName);
2623 /*************************************************************************
2624 * SQLProceduresW [ODBC32.167]
2626 SQLRETURN WINAPI SQLProceduresW(
2627 SQLHSTMT hstmt,
2628 SQLWCHAR *szCatalogName,
2629 SQLSMALLINT cbCatalogName,
2630 SQLWCHAR *szSchemaName,
2631 SQLSMALLINT cbSchemaName,
2632 SQLWCHAR *szProcName,
2633 SQLSMALLINT cbProcName)
2635 TRACE("\n");
2637 if (!pSQLProceduresW) return SQL_ERROR;
2638 return pSQLProceduresW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2639 szProcName, cbProcName);
2642 /*************************************************************************
2643 * SQLTablePrivilegesW [ODBC32.170]
2645 SQLRETURN WINAPI SQLTablePrivilegesW(
2646 SQLHSTMT hstmt,
2647 SQLWCHAR *szCatalogName,
2648 SQLSMALLINT cbCatalogName,
2649 SQLWCHAR *szSchemaName,
2650 SQLSMALLINT cbSchemaName,
2651 SQLWCHAR *szTableName,
2652 SQLSMALLINT cbTableName)
2654 TRACE("\n");
2656 if (!pSQLTablePrivilegesW) return SQL_ERROR;
2657 return pSQLTablePrivilegesW(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName,
2658 szTableName, cbTableName);
2661 /*************************************************************************
2662 * SQLDriversW [ODBC32.171]
2664 SQLRETURN WINAPI SQLDriversW(
2665 SQLHENV henv,
2666 SQLUSMALLINT fDirection,
2667 SQLWCHAR *szDriverDesc,
2668 SQLSMALLINT cbDriverDescMax,
2669 SQLSMALLINT *pcbDriverDesc,
2670 SQLWCHAR *szDriverAttributes,
2671 SQLSMALLINT cbDriverAttrMax,
2672 SQLSMALLINT *pcbDriverAttr)
2674 SQLRETURN ret;
2676 TRACE("(Direction %d)\n", fDirection);
2678 if (!pSQLDriversW) return SQL_ERROR;
2679 ret = pSQLDriversW(henv, fDirection, szDriverDesc, cbDriverDescMax, pcbDriverDesc,
2680 szDriverAttributes, cbDriverAttrMax, pcbDriverAttr);
2682 if (ret == SQL_NO_DATA && fDirection == SQL_FETCH_FIRST)
2683 ERR_(winediag)("No ODBC drivers could be found. "
2684 "Check the settings for your libodbc provider.\n");
2686 return ret;
2689 /*************************************************************************
2690 * SQLSetDescFieldW [ODBC32.173]
2692 SQLRETURN WINAPI SQLSetDescFieldW(SQLHDESC DescriptorHandle,
2693 SQLSMALLINT RecNumber, SQLSMALLINT FieldIdentifier,
2694 SQLPOINTER Value, SQLINTEGER BufferLength)
2696 TRACE("\n");
2698 if (!pSQLSetDescFieldW) return SQL_ERROR;
2699 return pSQLSetDescFieldW(DescriptorHandle, RecNumber, FieldIdentifier, Value, BufferLength);
2702 /*************************************************************************
2703 * SQLSetStmtAttrW [ODBC32.176]
2705 SQLRETURN WINAPI SQLSetStmtAttrW(SQLHSTMT StatementHandle,
2706 SQLINTEGER Attribute, SQLPOINTER Value,
2707 SQLINTEGER StringLength)
2709 SQLRETURN iResult;
2710 TRACE("Attribute = (%02d) Value = %p StringLength = (%d)\n",
2711 Attribute, Value, StringLength);
2713 if (!pSQLSetStmtAttrW) return SQL_ERROR;
2714 iResult = pSQLSetStmtAttrW(StatementHandle, Attribute, Value, StringLength);
2715 if (iResult == SQL_ERROR && (Attribute == SQL_ROWSET_SIZE || Attribute == SQL_ATTR_ROW_ARRAY_SIZE)) {
2716 TRACE("CHEAT: returning SQL_SUCCESS to ADO...\n");
2717 iResult = SQL_SUCCESS;
2718 } else {
2719 TRACE("returning %d...\n", iResult);
2721 return iResult;
2725 /* End of file */