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

cpl_odbc.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  * $Id: cpl_odbc.h,v 1.4 2003/09/26 20:02:41 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.4  2003/09/26 20:02:41  warmerda
00032  * update GetColData()
00033  *
00034  * Revision 1.3  2003/09/26 13:51:02  warmerda
00035  * Add documentation
00036  *
00037  * Revision 1.2  2003/09/25 17:09:49  warmerda
00038  * added some more methods
00039  *
00040  * Revision 1.1  2003/09/24 15:39:14  warmerda
00041  * New
00042  *
00043  */
00044 
00045 #ifndef CPL_ODBC_H_INCLUDED
00046 #define CPL_ODBC_H_INCLUDED
00047 
00048 #include "cpl_port.h"
00049 
00050 #include <sql.h>
00051 #include <sqlext.h>
00052 
00059 class CPLODBCStatement;
00060 
00067 class CPL_DLL CPLODBCSession {
00068     char      m_szLastError[SQL_MAX_MESSAGE_LENGTH + 1];
00069     HENV      m_hEnv;
00070     HDBC      m_hDBC;
00071 
00072   public:
00073     CPLODBCSession();
00074     ~CPLODBCSession();
00075 
00076     int         EstablishSession( const char *pszDSN, 
00077                                   const char *pszUserid, 
00078                                   const char *pszPassword );
00079     const char  *GetLastError();
00080 
00081     // Essentially internal. 
00082 
00083     int         CloseSession();
00084 
00085     int         Failed( int, HSTMT = NULL );
00086     HDBC        GetConnection() { return m_hDBC; }
00087     HENV        GetEnvironment()  { return m_hEnv; }
00088 };
00089 
00099 class CPL_DLL CPLODBCStatement {
00100 
00101     CPLODBCSession     *m_poSession;
00102     HSTMT               m_hStmt;
00103 
00104     short          m_nColCount;
00105     char         **m_papszColNames;
00106     short         *m_panColType;
00107     SQLULEN       *m_panColSize;
00108     short         *m_panColPrecision;
00109     short         *m_panColNullable;
00110 
00111     char         **m_papszColValues;
00112     
00113     int            Failed( int );
00114 
00115     char          *m_pszStatement;
00116     int            m_nStatementMax;
00117     int            m_nStatementLen;
00118 
00119     int            CollectResultsInfo();
00120 
00121   public:
00122     CPLODBCStatement( CPLODBCSession * );
00123     ~CPLODBCStatement();
00124 
00125     HSTMT          GetStatement() { return m_hStmt; }
00126 
00127     // Command buffer related.
00128     void           Clear();
00129     void           Append( const char * );
00130     void           Append( int );
00131     void           Append( double );
00132     int            Appendf( const char *, ... );
00133     const char    *GetCommand() { return m_pszStatement; }
00134 
00135     int            ExecuteSQL( const char * = NULL );
00136 
00137     // Results fetching
00138     int            Fetch( int nOrientation = SQL_FETCH_NEXT, 
00139                           int nOffset = 0 );
00140     void           ClearColumnData();
00141 
00142     int            GetColCount();
00143     const char    *GetColName(int iCol);
00144     short          GetColType(int iCol);
00145     short          GetColSize(int iCol);
00146     short          GetColPrecision(int iCol);
00147     short          GetColNullable(int iCol);
00148 
00149     int            GetColId( const char * );
00150     const char    *GetColData( int, const char * = NULL );
00151     const char    *GetColData( const char *, const char * = NULL );
00152 
00153     // Fetch special metadata.
00154     int            GetColumns( const char *pszTable, 
00155                                const char *pszCatalog = NULL,
00156                                const char *pszSchema = NULL );
00157 
00158     int            GetTables( const char *pszCatalog = NULL,
00159                               const char *pszSchema = NULL );
00160 
00161     void           DumpResult( FILE *fp, int bShowSchema = FALSE );
00162 
00163     static const char *GetTypeName( int );
00164 };
00165 
00166 
00167 
00168 #endif
00169 
00170 

Generated on Mon Oct 6 16:31:38 2003 for SDTS_AL by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002