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 );
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
180 HENV m_hEnv =
nullptr;
181 HDBC m_hDBC =
nullptr;
182 int m_bInTransaction =
false;
183 int m_bAutoCommit =
true;
190 int EstablishSession(
const char *pszDSN,
191 const char *pszUserid,
192 const char *pszPassword );
193 const char *GetLastError();
197 int ClearTransaction();
198 int BeginTransaction();
199 int CommitTransaction();
200 int RollbackTransaction();
208 int Failed(
int, HSTMT =
nullptr );
214 bool ConnectToMsAccess(
const char * pszName,
const char* pszDSNStringTemplate );
236 HSTMT m_hStmt =
nullptr;
238 SQLSMALLINT m_nColCount = 0;
239 char **m_papszColNames =
nullptr;
240 SQLSMALLINT *m_panColType =
nullptr;
241 char **m_papszColTypeNames =
nullptr;
242 CPL_SQLULEN *m_panColSize =
nullptr;
243 SQLSMALLINT *m_panColPrecision =
nullptr;
244 SQLSMALLINT *m_panColNullable =
nullptr;
245 char **m_papszColColumnDef =
nullptr;
247 char **m_papszColValues =
nullptr;
248 CPL_SQLLEN *m_panColValueLengths =
nullptr;
249 double *m_padColValuesAsDouble =
nullptr;
253 char *m_pszStatement =
nullptr;
254 size_t m_nStatementMax = 0;
255 size_t m_nStatementLen = 0;
275 RetrieveNumericColumnsAsDouble = 1 << 0,
287 int Flags()
const {
return m_nFlags; }
291 void AppendEscaped(
const char * );
292 void Append(
const char * );
294 void Append(
double );
297 const
char *GetCommand() {
return m_pszStatement; }
299 int ExecuteSQL(
const char * =
nullptr );
302 int Fetch(
int nOrientation = SQL_FETCH_NEXT,
304 void ClearColumnData();
307 const char *GetColName(
int );
308 short GetColType(
int );
309 const char *GetColTypeName(
int );
310 short GetColSize(
int );
311 short GetColPrecision(
int );
312 short GetColNullable(
int );
313 const char *GetColColumnDef(
int );
315 int GetColId(
const char * )
const;
316 const char *GetColData(
int,
const char * =
nullptr );
317 const char *GetColData(
const char *,
const char * =
nullptr );
318 int GetColDataLength(
int );
320 double GetColDataAsDouble(
int )
const;
321 double GetColDataAsDouble(
const char * )
const;
323 int GetRowCountAffected();
326 int GetColumns(
const char *pszTable,
327 const char *pszCatalog =
nullptr,
328 const char *pszSchema =
nullptr );
329 int GetPrimaryKeys(
const char *pszTable,
330 const char *pszCatalog =
nullptr,
331 const char *pszSchema =
nullptr );
333 int GetTables(
const char *pszCatalog =
nullptr,
334 const char *pszSchema =
nullptr );
336 void DumpResult( FILE *fp,
int bShowSchema = FALSE );
339 static SQLSMALLINT GetTypeMapping( SQLSMALLINT );
341 int CollectResultsInfo();
#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
Tag a function to have printf() formatting.
Definition: cpl_port.h:844
Convenient string class based on std::string.
Definition: cpl_string.h:320
HSTMT GetStatement()
Return statement handle.
Definition: cpl_odbc.h:282
HDBC GetConnection()
Return connection handle.
Definition: cpl_odbc.h:210
HENV GetEnvironment()
Return GetEnvironment handle.
Definition: cpl_odbc.h:212
Abstraction for statement, and resultset.
Definition: cpl_odbc.h:227
A class representing an ODBC database session.
Definition: cpl_odbc.h:173
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
#define CPL_FORMAT_STRING(arg)
Macro into which to wrap the format argument of a printf-like function.
Definition: cpl_port.h:859
int GetUsageCount() const
The usage count of the driver after this function has been called.
Definition: cpl_odbc.h:124
int Flags() const
Returns statement flags.
Definition: cpl_odbc.h:287
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:202
#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:930
Flag
Flags which control ODBC statement behavior.
Definition: cpl_odbc.h:263