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];
90 int InstallDriver(
const char* pszDriver,
const char* pszPathIn,
91 WORD fRequest = ODBC_INSTALL_COMPLETE );
109 int RemoveDriver(
const char* pszDriverName,
int fRemoveDSN = FALSE );
140 #if defined(_MSC_VER) && !defined(SQLULEN) && !defined(_WIN64) 141 # define MISSING_SQLULEN 145 #if !defined(MISSING_SQLULEN) 147 # define CPL_SQLULEN SQLULEN 148 # define CPL_SQLLEN SQLLEN 150 # define CPL_SQLULEN SQLUINTEGER 151 # define CPL_SQLLEN SQLINTEGER 166 HENV m_hEnv =
nullptr;
167 HDBC m_hDBC =
nullptr;
168 int m_bInTransaction =
false;
169 int m_bAutoCommit =
true;
175 int EstablishSession(
const char *pszDSN,
176 const char *pszUserid,
177 const char *pszPassword );
178 const char *GetLastError();
182 int ClearTransaction();
183 int BeginTransaction();
184 int CommitTransaction();
185 int RollbackTransaction();
193 int Failed(
int, HSTMT =
nullptr );
214 HSTMT m_hStmt =
nullptr;
216 SQLSMALLINT m_nColCount = 0;
217 char **m_papszColNames =
nullptr;
218 SQLSMALLINT *m_panColType =
nullptr;
219 char **m_papszColTypeNames =
nullptr;
220 CPL_SQLULEN *m_panColSize =
nullptr;
221 SQLSMALLINT *m_panColPrecision =
nullptr;
222 SQLSMALLINT *m_panColNullable =
nullptr;
223 char **m_papszColColumnDef =
nullptr;
225 char **m_papszColValues =
nullptr;
226 CPL_SQLLEN *m_panColValueLengths =
nullptr;
230 char *m_pszStatement =
nullptr;
231 size_t m_nStatementMax = 0;
232 size_t m_nStatementLen = 0;
243 void AppendEscaped(
const char * );
244 void Append(
const char * );
246 void Append(
double );
251 int ExecuteSQL(
const char * =
nullptr );
254 int Fetch(
int nOrientation = SQL_FETCH_NEXT,
256 void ClearColumnData();
259 const char *GetColName(
int );
260 short GetColType(
int );
261 const char *GetColTypeName(
int );
262 short GetColSize(
int );
263 short GetColPrecision(
int );
264 short GetColNullable(
int );
265 const char *GetColColumnDef(
int );
267 int GetColId(
const char * );
268 const char *GetColData(
int,
const char * =
nullptr );
269 const char *GetColData(
const char *,
const char * =
nullptr );
270 int GetColDataLength(
int );
271 int GetRowCountAffected();
274 int GetColumns(
const char *pszTable,
275 const char *pszCatalog =
nullptr,
276 const char *pszSchema =
nullptr );
277 int GetPrimaryKeys(
const char *pszTable,
278 const char *pszCatalog =
nullptr,
279 const char *pszSchema =
nullptr );
281 int GetTables(
const char *pszCatalog =
nullptr,
282 const char *pszSchema =
nullptr );
284 void DumpResult( FILE *fp,
int bShowSchema = FALSE );
287 static SQLSMALLINT GetTypeMapping( SQLSMALLINT );
289 int CollectResultsInfo();
int IsInTransaction()
Returns whether a transaction is active.
Definition: cpl_odbc.h:187
Core portability definitions for CPL.
A class representing an ODBC database session.
Definition: cpl_odbc.h:161
HDBC GetConnection()
Return connection handle.
Definition: cpl_odbc.h:195
Convenient string class based on std::string.
Definition: cpl_string.h:329
#define CPL_PRINT_FUNC_FORMAT(format_idx, arg_idx)
Tag a function to have printf() formatting.
Definition: cpl_port.h:906
Abstraction for statement, and resultset.
Definition: cpl_odbc.h:209
Various convenience functions for working with strings and string lists.
DWORD GetLastErrorCode() const
If InstallDriver returns FALSE, then GetLastErrorCode then error code can be obtained by calling this...
Definition: cpl_odbc.h:131
const char * GetPathOut() const
Path of the target directory where the driver should be installed.
Definition: cpl_odbc.h:118
int GetUsageCount() const
The usage count of the driver after this function has been called.
Definition: cpl_odbc.h:112
A class providing functions to install or remove ODBC driver.
Definition: cpl_odbc.h:61
HENV GetEnvironment()
Return GetEnvironment handle.
Definition: cpl_odbc.h:197
HSTMT GetStatement()
Return statement handle.
Definition: cpl_odbc.h:239
const char * GetLastError() const
If InstallDriver returns FALSE, then GetLastError then error message can be obtained by calling this ...
Definition: cpl_odbc.h:124
#define CPL_FORMAT_STRING(arg)
Macro into which to wrap the format argument of a printf-like function.
Definition: cpl_port.h:921
const char * GetCommand()
Return statement string.
Definition: cpl_odbc.h:249
#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:989