Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

cpl_odbc.h

Go to the documentation of this file.
00001 /****************************************************************************** 00002 * $Id: cpl_odbc.h,v 1.8 2003/11/24 20:45:00 warmerda Exp $ 00003 * 00004 * Project: OGR ODBC Driver 00005 * Purpose: Declarations for ODBC Access Cover API. 00006 * Author: Frank Warmerdam, warmerdam@pobox.com 00007 * 00008 ****************************************************************************** 00009 * Copyright (c) 2003, Frank Warmerdam 00010 * 00011 * Permission is hereby granted, free of charge, to any person obtaining a 00012 * copy of this software and associated documentation files (the "Software"), 00013 * to deal in the Software without restriction, including without limitation 00014 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00015 * and/or sell copies of the Software, and to permit persons to whom the 00016 * Software is furnished to do so, subject to the following conditions: 00017 * 00018 * The above copyright notice and this permission notice shall be included 00019 * in all copies or substantial portions of the Software. 00020 * 00021 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00022 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00023 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00024 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00025 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00026 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00027 * DEALINGS IN THE SOFTWARE. 00028 ****************************************************************************** 00029 * 00030 * $Log: cpl_odbc.h,v $ 00031 * Revision 1.8 2003/11/24 20:45:00 warmerda 00032 * make CollectResultsInfo() public 00033 * 00034 * Revision 1.7 2003/10/29 17:56:57 warmerda 00035 * Added PrimaryKeys() support 00036 * 00037 * Revision 1.6 2003/10/06 20:04:08 warmerda 00038 * added escaping support 00039 * 00040 * Revision 1.5 2003/10/06 17:16:18 warmerda 00041 * added windows.h for windows, and fixed m_panColSize type 00042 * 00043 * Revision 1.4 2003/09/26 20:02:41 warmerda 00044 * update GetColData() 00045 * 00046 * Revision 1.3 2003/09/26 13:51:02 warmerda 00047 * Add documentation 00048 * 00049 * Revision 1.2 2003/09/25 17:09:49 warmerda 00050 * added some more methods 00051 * 00052 * Revision 1.1 2003/09/24 15:39:14 warmerda 00053 * New 00054 * 00055 */ 00056 00057 #ifndef CPL_ODBC_H_INCLUDED 00058 #define CPL_ODBC_H_INCLUDED 00059 00060 #include "cpl_port.h" 00061 00062 #ifdef WIN32 00063 # include <windows.h> 00064 #endif 00065 00066 #include <sql.h> 00067 #include <sqlext.h> 00068 00075 class CPLODBCStatement; 00076 00083 class CPL_DLL CPLODBCSession { 00084 char m_szLastError[SQL_MAX_MESSAGE_LENGTH + 1]; 00085 HENV m_hEnv; 00086 HDBC m_hDBC; 00087 00088 public: 00089 CPLODBCSession(); 00090 ~CPLODBCSession(); 00091 00092 int EstablishSession( const char *pszDSN, 00093 const char *pszUserid, 00094 const char *pszPassword ); 00095 const char *GetLastError(); 00096 00097 // Essentially internal. 00098 00099 int CloseSession(); 00100 00101 int Failed( int, HSTMT = NULL ); 00102 HDBC GetConnection() { return m_hDBC; } 00103 HENV GetEnvironment() { return m_hEnv; } 00104 }; 00105 00115 class CPL_DLL CPLODBCStatement { 00116 00117 CPLODBCSession *m_poSession; 00118 HSTMT m_hStmt; 00119 00120 short m_nColCount; 00121 char **m_papszColNames; 00122 short *m_panColType; 00123 SQLUINTEGER *m_panColSize; 00124 short *m_panColPrecision; 00125 short *m_panColNullable; 00126 00127 char **m_papszColValues; 00128 00129 int Failed( int ); 00130 00131 char *m_pszStatement; 00132 int m_nStatementMax; 00133 int m_nStatementLen; 00134 00135 public: 00136 CPLODBCStatement( CPLODBCSession * ); 00137 ~CPLODBCStatement(); 00138 00139 HSTMT GetStatement() { return m_hStmt; } 00140 00141 // Command buffer related. 00142 void Clear(); 00143 void AppendEscaped( const char * ); 00144 void Append( const char * ); 00145 void Append( int ); 00146 void Append( double ); 00147 int Appendf( const char *, ... ); 00148 const char *GetCommand() { return m_pszStatement; } 00149 00150 int ExecuteSQL( const char * = NULL ); 00151 00152 // Results fetching 00153 int Fetch( int nOrientation = SQL_FETCH_NEXT, 00154 int nOffset = 0 ); 00155 void ClearColumnData(); 00156 00157 int GetColCount(); 00158 const char *GetColName(int iCol); 00159 short GetColType(int iCol); 00160 short GetColSize(int iCol); 00161 short GetColPrecision(int iCol); 00162 short GetColNullable(int iCol); 00163 00164 int GetColId( const char * ); 00165 const char *GetColData( int, const char * = NULL ); 00166 const char *GetColData( const char *, const char * = NULL ); 00167 00168 // Fetch special metadata. 00169 int GetColumns( const char *pszTable, 00170 const char *pszCatalog = NULL, 00171 const char *pszSchema = NULL ); 00172 int GetPrimaryKeys( const char *pszTable, 00173 const char *pszCatalog = NULL, 00174 const char *pszSchema = NULL ); 00175 00176 int GetTables( const char *pszCatalog = NULL, 00177 const char *pszSchema = NULL ); 00178 00179 void DumpResult( FILE *fp, int bShowSchema = FALSE ); 00180 00181 static const char *GetTypeName( int ); 00182 00183 int CollectResultsInfo(); 00184 }; 00185 00186 00187 00188 #endif 00189 00190

Generated on Thu Jul 29 19:47:52 2004 for GDAL by doxygen 1.3.7