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 );
93 int InstallDriver(
const char* pszDriver,
const char* pszPathIn,
94 WORD fRequest = ODBC_INSTALL_COMPLETE );
103 static void InstallMdbToolsDriver();
121 int RemoveDriver(
const char* pszDriverName,
int fRemoveDSN = FALSE );
152 #if defined(_MSC_VER) && !defined(SQLULEN) && !defined(_WIN64)
153 # define MISSING_SQLULEN
157 #if !defined(MISSING_SQLULEN)
159 # define CPL_SQLULEN SQLULEN
160 # define CPL_SQLLEN SQLLEN
162 # define CPL_SQLULEN SQLUINTEGER
163 # define CPL_SQLLEN SQLINTEGER
178 HENV m_hEnv =
nullptr;
179 HDBC m_hDBC =
nullptr;
180 int m_bInTransaction =
false;
181 int m_bAutoCommit =
true;
187 int EstablishSession(
const char *pszDSN,
188 const char *pszUserid,
189 const char *pszPassword );
190 const char *GetLastError();
194 int ClearTransaction();
195 int BeginTransaction();
196 int CommitTransaction();
197 int RollbackTransaction();
205 int Failed(
int, HSTMT =
nullptr );
211 bool ConnectToMsAccess(
const char * pszName,
const char* pszDSNStringTemplate );
229 HSTMT m_hStmt =
nullptr;
231 SQLSMALLINT m_nColCount = 0;
232 char **m_papszColNames =
nullptr;
233 SQLSMALLINT *m_panColType =
nullptr;
234 char **m_papszColTypeNames =
nullptr;
235 CPL_SQLULEN *m_panColSize =
nullptr;
236 SQLSMALLINT *m_panColPrecision =
nullptr;
237 SQLSMALLINT *m_panColNullable =
nullptr;
238 char **m_papszColColumnDef =
nullptr;
240 char **m_papszColValues =
nullptr;
241 CPL_SQLLEN *m_panColValueLengths =
nullptr;
245 char *m_pszStatement =
nullptr;
246 size_t m_nStatementMax = 0;
247 size_t m_nStatementLen = 0;
258 void AppendEscaped(
const char * );
259 void Append(
const char * );
261 void Append(
double );
264 const
char *GetCommand() {
return m_pszStatement; }
266 int ExecuteSQL(
const char * =
nullptr );
269 int Fetch(
int nOrientation = SQL_FETCH_NEXT,
271 void ClearColumnData();
274 const char *GetColName(
int );
275 short GetColType(
int );
276 const char *GetColTypeName(
int );
277 short GetColSize(
int );
278 short GetColPrecision(
int );
279 short GetColNullable(
int );
280 const char *GetColColumnDef(
int );
282 int GetColId(
const char * );
283 const char *GetColData(
int,
const char * =
nullptr );
284 const char *GetColData(
const char *,
const char * =
nullptr );
285 int GetColDataLength(
int );
286 int GetRowCountAffected();
289 int GetColumns(
const char *pszTable,
290 const char *pszCatalog =
nullptr,
291 const char *pszSchema =
nullptr );
292 int GetPrimaryKeys(
const char *pszTable,
293 const char *pszCatalog =
nullptr,
294 const char *pszSchema =
nullptr );
296 int GetTables(
const char *pszCatalog =
nullptr,
297 const char *pszSchema =
nullptr );
299 void DumpResult( FILE *fp,
int bShowSchema = FALSE );
302 static SQLSMALLINT GetTypeMapping( SQLSMALLINT );
304 int CollectResultsInfo();
A class providing functions to install or remove ODBC driver.
Definition: cpl_odbc.h:62
int GetUsageCount() const
The usage count of the driver after this function has been called.
Definition: cpl_odbc.h:124
const char * GetLastError() const
If InstallDriver returns FALSE, then GetLastError then error message can be obtained by calling this ...
Definition: cpl_odbc.h:136
const char * GetPathOut() const
Path of the target directory where the driver should be installed.
Definition: cpl_odbc.h:130
DWORD GetLastErrorCode() const
If InstallDriver returns FALSE, then GetLastErrorCode then error code can be obtained by calling this...
Definition: cpl_odbc.h:143
A class representing an ODBC database session.
Definition: cpl_odbc.h:173
int IsInTransaction()
Returns whether a transaction is active.
Definition: cpl_odbc.h:199
HDBC GetConnection()
Return connection handle.
Definition: cpl_odbc.h:207
HENV GetEnvironment()
Return GetEnvironment handle.
Definition: cpl_odbc.h:209
Abstraction for statement, and resultset.
Definition: cpl_odbc.h:224
HSTMT GetStatement()
Return statement handle.
Definition: cpl_odbc.h:254
Convenient string class based on std::string.
Definition: cpl_string.h:333
Core portability definitions for CPL.
#define CPL_FORMAT_STRING(arg)
Macro into which to wrap the format argument of a printf-like function.
Definition: cpl_port.h:884
#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
Tag a function to have printf() formatting.
Definition: cpl_port.h:869
#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:955
Various convenience functions for working with strings and string lists.