TSQLStatement.h

Go to the documentation of this file.
00001 // @(#)root/net:$Id: TSQLStatement.h 28011 2009-03-31 15:54:10Z pcanal $
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_TSQLStatement
00013 #define ROOT_TSQLStatement
00014 
00015 #ifndef ROOT_TObject
00016 #include "TObject.h"
00017 #endif
00018 #ifndef ROOT_TString
00019 #include "TString.h"
00020 #endif
00021 #ifndef ROOT_TDatime
00022 #include "TDatime.h"
00023 #endif
00024 #include<vector>
00025 
00026 class TSQLStatement : public TObject {
00027 
00028 protected:
00029    TSQLStatement(Bool_t errout = kTRUE) : TObject(), fErrorCode(0),
00030      fErrorMsg(), fErrorOut(errout) { ClearError(); }
00031 
00032    Int_t     fErrorCode;  // error code of last operation
00033    TString   fErrorMsg;   // error message of last operation
00034    Bool_t    fErrorOut;   // enable error output 
00035 
00036    void                ClearError();
00037    void                SetError(Int_t code, const char* msg, const char* method = 0);
00038 
00039 public:
00040    virtual ~TSQLStatement() {}
00041 
00042    virtual Int_t       GetBufferLength() const = 0;
00043    virtual Int_t       GetNumParameters() = 0;
00044 
00045    virtual Bool_t      NextIteration() = 0;
00046 
00047    virtual Bool_t      SetNull(Int_t) { return kFALSE; }
00048    virtual Bool_t      SetInt(Int_t, Int_t) { return kFALSE; }
00049    virtual Bool_t      SetUInt(Int_t, UInt_t) { return kFALSE; }
00050    virtual Bool_t      SetLong(Int_t, Long_t) { return kFALSE; }
00051    virtual Bool_t      SetLong64(Int_t, Long64_t) { return kFALSE; }
00052    virtual Bool_t      SetULong64(Int_t, ULong64_t) { return kFALSE; }
00053    virtual Bool_t      SetDouble(Int_t, Double_t) { return kFALSE; }
00054    virtual Bool_t      SetString(Int_t, const char*, Int_t = 256) { return kFALSE; }
00055    virtual Bool_t      SetDate(Int_t, Int_t, Int_t, Int_t) { return kFALSE; }
00056            Bool_t      SetDate(Int_t, const TDatime&);
00057    virtual Bool_t      SetTime(Int_t, Int_t, Int_t, Int_t) { return kFALSE; }
00058            Bool_t      SetTime(Int_t, const TDatime&);
00059    virtual Bool_t      SetDatime(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t) { return kFALSE; }
00060            Bool_t      SetDatime(Int_t, const TDatime&);
00061    virtual Bool_t      SetTimestamp(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t = 0) { return kFALSE; }
00062            Bool_t      SetTimestamp(Int_t, const TDatime&);
00063    virtual void        SetTimeFormating(const char*) {}
00064    virtual Bool_t      SetBinary(Int_t, void*, Long_t, Long_t = 0x1000) { return kFALSE; }
00065 #ifndef __MAKECINT__
00066    virtual Bool_t      SetVInt(Int_t, const std::vector<Int_t>, const char*, const char*) { return kFALSE; }
00067    virtual Bool_t      SetVUInt(Int_t, const std::vector<UInt_t>, const char*, const char*) { return kFALSE; }
00068    virtual Bool_t      SetVLong(Int_t, const std::vector<Long_t>, const char*, const char*) { return kFALSE; }
00069    virtual Bool_t      SetVLong64(Int_t, const std::vector<Long64_t>, const char*, const char*) { return kFALSE; }
00070    virtual Bool_t      SetVULong64(Int_t, const std::vector<ULong64_t>, const char*, const char*) { return kFALSE; }
00071    virtual Bool_t      SetVDouble(Int_t, const std::vector<Double_t>, const char*, const char*) { return kFALSE; }
00072 #endif
00073 
00074    virtual Bool_t      Process() = 0;
00075    virtual Int_t       GetNumAffectedRows() { return 0; }
00076 
00077    virtual Bool_t      StoreResult() = 0;
00078    virtual Int_t       GetNumFields() = 0;
00079    virtual const char *GetFieldName(Int_t) = 0;
00080    virtual Bool_t      SetMaxFieldSize(Int_t, Long_t) { return kFALSE; }
00081    virtual Bool_t      NextResultRow() = 0;
00082 
00083    virtual Bool_t      IsNull(Int_t) { return kTRUE; }
00084    virtual Int_t       GetInt(Int_t) { return 0; }
00085    virtual UInt_t      GetUInt(Int_t) { return 0; }
00086    virtual Long_t      GetLong(Int_t) { return 0; }
00087    virtual Long64_t    GetLong64(Int_t) { return 0; }
00088    virtual ULong64_t   GetULong64(Int_t) { return 0; }
00089    virtual Double_t    GetDouble(Int_t) { return 0.; }
00090    virtual const char *GetString(Int_t) { return 0; }
00091    virtual Bool_t      GetBinary(Int_t, void* &, Long_t&) { return kFALSE; }
00092 
00093    virtual Bool_t      GetDate(Int_t, Int_t&, Int_t&, Int_t&) { return kFALSE; }
00094    virtual Bool_t      GetTime(Int_t, Int_t&, Int_t&, Int_t&) { return kFALSE; }
00095    virtual Bool_t      GetDatime(Int_t, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&) { return kFALSE; }
00096            TDatime     GetDatime(Int_t);
00097            Int_t       GetYear(Int_t);
00098            Int_t       GetMonth(Int_t);
00099            Int_t       GetDay(Int_t);
00100            Int_t       GetHour(Int_t);
00101            Int_t       GetMinute(Int_t);
00102            Int_t       GetSecond(Int_t);
00103    virtual Bool_t      GetTimestamp(Int_t, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&) { return kFALSE; }
00104            TDatime     GetTimestamp(Int_t);
00105 #ifndef __MAKECINT__
00106    virtual Bool_t      GetVInt(Int_t, std::vector<Int_t>&) { return kFALSE; }
00107    virtual Bool_t      GetVUInt(Int_t, std::vector<UInt_t>&) { return kFALSE; }
00108    virtual Bool_t      GetVLong(Int_t, std::vector<Long_t>&) { return kFALSE; }
00109    virtual Bool_t      GetVLong64(Int_t, std::vector<Long64_t>&) { return kFALSE; }
00110    virtual Bool_t      GetVULong64(Int_t, std::vector<ULong64_t>&) { return kFALSE; }
00111    virtual Bool_t      GetVDouble(Int_t, std::vector<Double_t>&) { return kFALSE; }
00112 #endif
00113 
00114    virtual Bool_t      IsError() const { return GetErrorCode()!=0; }
00115    virtual Int_t       GetErrorCode() const;
00116    virtual const char* GetErrorMsg() const;
00117    virtual void        EnableErrorOutput(Bool_t on = kTRUE) { fErrorOut = on; }
00118 
00119    ClassDef(TSQLStatement, 0) //SQL statement
00120 };
00121 
00122 #endif

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