Go to the documentation of this file.
30 #ifndef CPL_ODBC_H_INCLUDED
31 #define CPL_ODBC_H_INCLUDED
46 #define ODBC_FILENAME_MAX PATH_MAX
48 #define ODBC_FILENAME_MAX (255 + 1)
63 char m_szPathOut[ODBC_FILENAME_MAX];
64 char m_szError[SQL_MAX_MESSAGE_LENGTH];
68 static bool FindMdbToolsDriverLib(
CPLString &osDriverFile);
69 static bool LibraryExists(
const char *pszLibPath);
92 int InstallDriver(
const char *pszDriver,
const char *pszPathIn,
93 WORD fRequest = ODBC_INSTALL_COMPLETE);
102 static void InstallMdbToolsDriver();
120 int RemoveDriver(
const char *pszDriverName,
int fRemoveDSN = FALSE);
125 return m_nUsageCount;
163 #if defined(_MSC_VER) && !defined(SQLULEN) && !defined(_WIN64)
164 #define MISSING_SQLULEN
168 #if !defined(MISSING_SQLULEN)
170 #define CPL_SQLULEN SQLULEN
171 #define CPL_SQLLEN SQLLEN
173 #define CPL_SQLULEN SQLUINTEGER
174 #define CPL_SQLLEN SQLINTEGER
192 HENV m_hEnv =
nullptr;
193 HDBC m_hDBC =
nullptr;
194 int m_bInTransaction =
false;
195 int m_bAutoCommit =
true;
202 int EstablishSession(
const char *pszDSN,
const char *pszUserid,
203 const char *pszPassword);
204 const char *GetLastError();
208 int ClearTransaction();
209 int BeginTransaction();
210 int CommitTransaction();
211 int RollbackTransaction();
215 return m_bInTransaction;
222 int Failed(
int, HSTMT =
nullptr);
234 bool ConnectToMsAccess(
const char *pszName,
235 const char *pszDSNStringTemplate);
257 HSTMT m_hStmt =
nullptr;
259 SQLSMALLINT m_nColCount = 0;
260 char **m_papszColNames =
nullptr;
261 SQLSMALLINT *m_panColType =
nullptr;
262 char **m_papszColTypeNames =
nullptr;
263 CPL_SQLULEN *m_panColSize =
nullptr;
264 SQLSMALLINT *m_panColPrecision =
nullptr;
265 SQLSMALLINT *m_panColNullable =
nullptr;
266 char **m_papszColColumnDef =
nullptr;
268 char **m_papszColValues =
nullptr;
269 CPL_SQLLEN *m_panColValueLengths =
nullptr;
270 double *m_padColValuesAsDouble =
nullptr;
274 char *m_pszStatement =
nullptr;
275 size_t m_nStatementMax = 0;
276 size_t m_nStatementLen = 0;
299 RetrieveNumericColumnsAsDouble = 1 << 0,
321 void AppendEscaped(
const char *);
322 void Append(
const char *);
329 const
char *GetCommand()
331 return m_pszStatement;
334 int ExecuteSQL(
const char * =
nullptr);
337 int Fetch(
int nOrientation = SQL_FETCH_NEXT,
int nOffset = 0);
338 void ClearColumnData();
341 const char *GetColName(
int);
342 short GetColType(
int);
343 const char *GetColTypeName(
int);
344 short GetColSize(
int);
345 short GetColPrecision(
int);
346 short GetColNullable(
int);
347 const char *GetColColumnDef(
int);
349 int GetColId(
const char *)
const;
350 const char *GetColData(
int,
const char * =
nullptr);
351 const char *GetColData(
const char *,
const char * =
nullptr);
352 int GetColDataLength(
int);
354 double GetColDataAsDouble(
int)
const;
355 double GetColDataAsDouble(
const char *)
const;
357 int GetRowCountAffected();
360 int GetColumns(
const char *pszTable,
const char *pszCatalog =
nullptr,
361 const char *pszSchema =
nullptr);
362 int GetPrimaryKeys(
const char *pszTable,
const char *pszCatalog =
nullptr,
363 const char *pszSchema =
nullptr);
365 int GetTables(
const char *pszCatalog =
nullptr,
366 const char *pszSchema =
nullptr);
368 void DumpResult(FILE *fp,
int bShowSchema = FALSE);
371 static SQLSMALLINT GetTypeMapping(SQLSMALLINT);
373 int CollectResultsInfo();
#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
Tag a function to have printf() formatting.
Definition: cpl_port.h:950
Convenient string class based on std::string.
Definition: cpl_string.h:311
HSTMT GetStatement()
Return statement handle.
Definition: cpl_odbc.h:306
HDBC GetConnection()
Return connection handle.
Definition: cpl_odbc.h:224
HENV GetEnvironment()
Return GetEnvironment handle.
Definition: cpl_odbc.h:229
Abstraction for statement, and resultset.
Definition: cpl_odbc.h:247
A class representing an ODBC database session.
Definition: cpl_odbc.h:184
const char * GetLastError() const
If InstallDriver returns FALSE, then GetLastError then error message can be obtained by calling this ...
Definition: cpl_odbc.h:141
const char * GetPathOut() const
Path of the target directory where the driver should be installed.
Definition: cpl_odbc.h:132
DWORD GetLastErrorCode() const
If InstallDriver returns FALSE, then GetLastErrorCode then error code can be obtained by calling this...
Definition: cpl_odbc.h:151
#define CPL_FORMAT_STRING(arg)
Macro into which to wrap the format argument of a printf-like function.
Definition: cpl_port.h:966
int GetUsageCount() const
The usage count of the driver after this function has been called.
Definition: cpl_odbc.h:123
int Flags() const
Returns statement flags.
Definition: cpl_odbc.h:314
A class providing functions to install or remove ODBC driver.
Definition: cpl_odbc.h:61
int IsInTransaction()
Returns whether a transaction is active.
Definition: cpl_odbc.h:213
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:1042
Flag
Flags which control ODBC statement behavior.
Definition: cpl_odbc.h:283