TOracleStatement.h

Go to the documentation of this file.
00001 // @(#)root/oracle:$Id: TOracleStatement.h 27990 2009-03-30 14:33:07Z brun $
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_TOracleStatement
00013 #define ROOT_TOracleStatement
00014 
00015 #ifndef ROOT_TSQLStatement
00016 #include "TSQLStatement.h"
00017 #endif
00018 
00019 #if !defined(__CINT__)
00020 #include <occi.h>
00021 using namespace oracle::occi;
00022 #ifdef CONST
00023 #undef CONST
00024 #endif
00025 #else
00026 class Environment;
00027 class Connection;
00028 class Statement;
00029 class ResultSet;
00030 class MetaData;
00031 #endif
00032 
00033 class TOracleStatement : public TSQLStatement {
00034 
00035 protected:
00036 
00037    struct TBufferRec {
00038       char* strbuf;
00039       Long_t strbufsize;
00040       char* namebuf;
00041    };
00042 
00043    Environment           *fEnv;         // enviroment 
00044    Connection            *fConn;        // connection to Oracle
00045    Statement             *fStmt;        // executed statement
00046    ResultSet             *fResult;      // query result (rows)
00047    std::vector<MetaData> *fFieldInfo;   // info for each field in the row
00048    TBufferRec            *fBuffer;       // buffer of values and field names
00049    Int_t                  fBufferSize;   // size of fBuffer
00050    Int_t                  fNumIterations;  // size of internal statement buffer
00051    Int_t                  fIterCounter; //counts nextiteration calls and process iterations, if required
00052    Int_t                  fWorkingMode; // 1 - settingpars, 2 - getting results
00053    TString                fTimeFmt;     // format for date to string conversion, default "MM/DD/YYYY, HH24:MI:SS" 
00054 
00055    Bool_t      IsParSettMode() const { return fWorkingMode==1; }
00056    Bool_t      IsResultSet() const { return (fWorkingMode==2) && (fResult!=0); }
00057 
00058    void        SetBufferSize(Int_t size);
00059    void        CloseBuffer();
00060    
00061 public:
00062    TOracleStatement(Environment* env, Connection* conn, Statement* stmt, Int_t niter, Bool_t errout = kTRUE);
00063    virtual ~TOracleStatement();
00064 
00065    virtual void        Close(Option_t * = "");
00066 
00067    virtual Int_t       GetBufferLength() const { return fNumIterations; }
00068    virtual Int_t       GetNumParameters();
00069 
00070    virtual Bool_t      SetNull(Int_t npar);
00071    virtual Bool_t      SetInt(Int_t npar, Int_t value);
00072    virtual Bool_t      SetUInt(Int_t npar, UInt_t value);
00073    virtual Bool_t      SetLong(Int_t npar, Long_t value);
00074    virtual Bool_t      SetLong64(Int_t npar, Long64_t value);
00075    virtual Bool_t      SetULong64(Int_t npar, ULong64_t value);
00076    virtual Bool_t      SetDouble(Int_t npar, Double_t value);
00077    virtual Bool_t      SetString(Int_t npar, const char* value, Int_t maxsize = 256);
00078    virtual Bool_t      SetBinary(Int_t npar, void* mem, Long_t size, Long_t maxsize = 0x1000);
00079    virtual Bool_t      SetDate(Int_t npar, Int_t year, Int_t month, Int_t day);
00080    virtual Bool_t      SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec);
00081    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);
00082    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);
00083    virtual void        SetTimeFormating(const char* fmt) { fTimeFmt = fmt; }
00084    virtual Bool_t      SetVInt(Int_t npar, const std::vector<Int_t> value, const char* schemaName, const char* typeName);
00085    virtual Bool_t      SetVUInt(Int_t npar, const std::vector<UInt_t> value, const char* schemaName, const char* typeName);
00086    virtual Bool_t      SetVLong(Int_t npar, const std::vector<Long_t> value, const char* schemaName, const char* typeName);
00087    virtual Bool_t      SetVLong64(Int_t npar, const std::vector<Long64_t> value, const char* schemaName, const char* typeName);
00088    virtual Bool_t      SetVULong64(Int_t npar, const std::vector<ULong64_t> value, const char* schemaName, const char* typeName);
00089    virtual Bool_t      SetVDouble(Int_t npar, const std::vector<Double_t> value, const char* schemaName, const char* typeName);
00090 
00091    virtual Bool_t      NextIteration();
00092 
00093    virtual Bool_t      Process();
00094    virtual Int_t       GetNumAffectedRows();
00095 
00096    virtual Bool_t      StoreResult();
00097    virtual Int_t       GetNumFields();
00098    virtual const char *GetFieldName(Int_t nfield);
00099    virtual Bool_t      SetMaxFieldSize(Int_t nfield, Long_t maxsize);
00100    virtual Bool_t      NextResultRow();
00101 
00102    virtual Bool_t      IsNull(Int_t);
00103    virtual Int_t       GetInt(Int_t npar);
00104    virtual UInt_t      GetUInt(Int_t npar);
00105    virtual Long_t      GetLong(Int_t npar);
00106    virtual Long64_t    GetLong64(Int_t npar);
00107    virtual ULong64_t   GetULong64(Int_t npar);
00108    virtual Double_t    GetDouble(Int_t npar);
00109    virtual const char *GetString(Int_t npar);
00110    virtual Bool_t      GetBinary(Int_t npar, void* &mem, Long_t& size);
00111    virtual Bool_t      GetDate(Int_t npar, Int_t& year, Int_t& month, Int_t& day);
00112    virtual Bool_t      GetTime(Int_t npar, Int_t& hour, Int_t& min, Int_t& sec);
00113    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);
00114    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& frac);
00115    virtual Bool_t      GetVInt(Int_t npar, std::vector<Int_t> &value);
00116    virtual Bool_t      GetVUInt(Int_t npar, std::vector<UInt_t> &value);
00117    virtual Bool_t      GetVLong(Int_t npar, std::vector<Long_t> &value);
00118    virtual Bool_t      GetVLong64(Int_t npar, std::vector<Long64_t> &value);
00119    virtual Bool_t      GetVULong64(Int_t npar, std::vector<ULong64_t> &value);
00120    virtual Bool_t      GetVDouble(Int_t npar, std::vector<Double_t> &value);
00121 
00122    ClassDef(TOracleStatement, 0); // SQL statement class for Oracle
00123 };
00124 
00125 #endif

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