TODBCStatement.h

Go to the documentation of this file.
00001 // @(#)root/odbc:$Id: TODBCStatement.h 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Sergey Linev   6/02/2006
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TODBCStatement
00013 #define ROOT_TODBCStatement
00014 
00015 #ifndef ROOT_TSQLStatement
00016 #include "TSQLStatement.h"
00017 #endif
00018 
00019 
00020 #ifdef __CINT__
00021 typedef void *   SQLHSTMT;
00022 typedef UShort_t SQLUSMALLINT;
00023 typedef UInt_t   SQLUINTEGER;
00024 typedef Short_t  SQLSMALLINT;
00025 typedef Short_t  SQLRETURN;
00026 #else
00027 #ifdef WIN32
00028 #include "windows.h"
00029 #endif
00030 #include <sql.h>
00031 #endif
00032 
00033 class TODBCStatement : public TSQLStatement {
00034 
00035 protected:
00036     #ifdef __CINT__
00037     struct ODBCBufferRec_t;
00038     #else
00039     struct ODBCBufferRec_t {
00040        Int_t       fBroottype;
00041        Int_t       fBsqltype;
00042        Int_t       fBsqlctype;
00043        void       *fBbuffer;
00044        Int_t       fBelementsize;
00045        SQLLEN     *fBlenarray;
00046        char       *fBstrbuffer;
00047        char       *fBnamebuffer;
00048     };
00049     #endif
00050 
00051 protected:
00052    SQLHSTMT         fHstmt;
00053    Int_t            fBufferPreferredSize;
00054    ODBCBufferRec_t *fBuffer;
00055    Int_t            fNumBuffers;
00056    Int_t            fBufferLength;     // number of entries for each parameter/column
00057    Int_t            fBufferCounter;    // used to indicate position in buffers
00058    SQLUSMALLINT    *fStatusBuffer;
00059    Int_t            fWorkingMode;      // 1 - setting parameters, 2 - reading results, 0 - unknown
00060    SQLUINTEGER      fNumParsProcessed; // contains number of parameters, affected by last operation
00061    SQLUINTEGER      fNumRowsFetched;   // indicates number of fetched rows
00062    ULong64_t        fLastResultRow;    // stores values of row number after last fetch operation
00063 
00064    void       *GetParAddr(Int_t npar, Int_t roottype = 0, Int_t length = 0);
00065    long double ConvertToNumeric(Int_t npar);
00066    const char *ConvertToString(Int_t npar);
00067 
00068    Bool_t      BindColumn(Int_t ncol, SQLSMALLINT sqltype, SQLUINTEGER size);
00069    Bool_t      BindParam(Int_t n, Int_t type, Int_t size = 1024);
00070 
00071    Bool_t      ExtractErrors(SQLRETURN retcode, const char* method);
00072 
00073    void        SetNumBuffers(Int_t isize, Int_t ilen);
00074    void        FreeBuffers();
00075 
00076    Bool_t      IsParSettMode() const { return fWorkingMode==1; }
00077    Bool_t      IsResultSet() const { return fWorkingMode==2; }
00078 
00079 public:
00080    TODBCStatement(SQLHSTMT stmt, Int_t rowarrsize, Bool_t errout = kTRUE);
00081    virtual ~TODBCStatement();
00082 
00083    virtual void        Close(Option_t * = "");
00084 
00085    virtual Int_t       GetBufferLength() const { return fBufferLength; }
00086    virtual Int_t       GetNumParameters();
00087 
00088    virtual Bool_t      SetNull(Int_t npar);
00089    virtual Bool_t      SetInt(Int_t npar, Int_t value);
00090    virtual Bool_t      SetUInt(Int_t npar, UInt_t value);
00091    virtual Bool_t      SetLong(Int_t npar, Long_t value);
00092    virtual Bool_t      SetLong64(Int_t npar, Long64_t value);
00093    virtual Bool_t      SetULong64(Int_t npar, ULong64_t value);
00094    virtual Bool_t      SetDouble(Int_t npar, Double_t value);
00095    virtual Bool_t      SetString(Int_t npar, const char* value, Int_t maxsize = 256);
00096    virtual Bool_t      SetBinary(Int_t npar, void* mem, Long_t size, Long_t maxsize = 0x1000);
00097    virtual Bool_t      SetDate(Int_t npar, Int_t year, Int_t month, Int_t day);
00098    virtual Bool_t      SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec);
00099    virtual Bool_t      SetDatime(Int_t npar, Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec);
00100    virtual Bool_t      SetTimestamp(Int_t npar, Int_t year, Int_t month, Int_t day, Int_t hour, Int_t min, Int_t sec, Int_t frac = 0);
00101 
00102    virtual Bool_t      NextIteration();
00103 
00104    virtual Bool_t      Process();
00105    virtual Int_t       GetNumAffectedRows();
00106 
00107    virtual Bool_t      StoreResult();
00108    virtual Int_t       GetNumFields();
00109    virtual const char *GetFieldName(Int_t nfield);
00110    virtual Bool_t      NextResultRow();
00111 
00112    virtual Bool_t      IsNull(Int_t);
00113    virtual Int_t       GetInt(Int_t npar);
00114    virtual UInt_t      GetUInt(Int_t npar);
00115    virtual Long_t      GetLong(Int_t npar);
00116    virtual Long64_t    GetLong64(Int_t npar);
00117    virtual ULong64_t   GetULong64(Int_t npar);
00118    virtual Double_t    GetDouble(Int_t npar);
00119    virtual const char *GetString(Int_t npar);
00120    virtual Bool_t      GetBinary(Int_t npar, void* &mem, Long_t& size);
00121    virtual Bool_t      GetDate(Int_t npar, Int_t& year, Int_t& month, Int_t& day);
00122    virtual Bool_t      GetTime(Int_t npar, Int_t& hour, Int_t& min, Int_t& sec);
00123    virtual Bool_t      GetDatime(Int_t npar, Int_t& year, Int_t& month, Int_t& day, Int_t& hour, Int_t& min, Int_t& sec);
00124    virtual Bool_t      GetTimestamp(Int_t npar, Int_t& year, Int_t& month, Int_t& day, Int_t& hour, Int_t& min, Int_t& sec, Int_t&);
00125 
00126    ClassDef(TODBCStatement, 0); //ODBC implementation of TSQLStatement
00127 };
00128 
00129 #endif

Generated on Tue Jul 5 15:14:38 2011 for ROOT_528-00b_version by  doxygen 1.5.1