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
165 CPLString m_osLastError{};
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 );
249 const
char *GetCommand() {
return m_pszStatement; }
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 );
286 static CPLString GetTypeName(
int );
287 static SQLSMALLINT GetTypeMapping( SQLSMALLINT );
289 int CollectResultsInfo();