Logo ROOT   6.12/07
Reference Guide
TSQLStatement.h
Go to the documentation of this file.
1 // @(#)root/net:$Id$
2 // Author: Sergey Linev 6/02/2006
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TSQLStatement
13 #define ROOT_TSQLStatement
14 
15 #include "TObject.h"
16 #include "TString.h"
17 #include "TDatime.h"
18 #include<vector>
19 
20 class TSQLStatement : public TObject {
21 
22 protected:
24  fErrorMsg(), fErrorOut(errout) { ClearError(); }
25 
26  Int_t fErrorCode; // error code of last operation
27  TString fErrorMsg; // error message of last operation
28  Bool_t fErrorOut; // enable error output
29 
30  void ClearError();
31  void SetError(Int_t code, const char* msg, const char* method = 0);
32 
33 public:
34  virtual ~TSQLStatement() {}
35 
36  virtual Int_t GetBufferLength() const = 0;
37  virtual Int_t GetNumParameters() = 0;
38 
39  virtual Bool_t NextIteration() = 0;
40 
41  virtual Bool_t SetNull(Int_t) { return kFALSE; }
42  virtual Bool_t SetInt(Int_t, Int_t) { return kFALSE; }
43  virtual Bool_t SetUInt(Int_t, UInt_t) { return kFALSE; }
44  virtual Bool_t SetLong(Int_t, Long_t) { return kFALSE; }
45  virtual Bool_t SetLong64(Int_t, Long64_t) { return kFALSE; }
46  virtual Bool_t SetULong64(Int_t, ULong64_t) { return kFALSE; }
47  virtual Bool_t SetDouble(Int_t, Double_t) { return kFALSE; }
48  virtual Bool_t SetString(Int_t, const char*, Int_t = 256) { return kFALSE; }
49  virtual Bool_t SetDate(Int_t, Int_t, Int_t, Int_t) { return kFALSE; }
50  Bool_t SetDate(Int_t, const TDatime&);
51  virtual Bool_t SetTime(Int_t, Int_t, Int_t, Int_t) { return kFALSE; }
52  Bool_t SetTime(Int_t, const TDatime&);
54  Bool_t SetDatime(Int_t, const TDatime&);
55  virtual Bool_t SetTimestamp(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t = 0) { return kFALSE; }
57  virtual void SetTimeFormating(const char*) {}
58  virtual Bool_t SetBinary(Int_t, void*, Long_t, Long_t = 0x1000) { return kFALSE; }
59  virtual Bool_t SetLargeObject(Int_t col, void* mem, Long_t size, Long_t maxsize = 0x1000) { return SetBinary(col, mem, size, maxsize); }
60 #ifndef __MAKECINT__
61  virtual Bool_t SetVInt(Int_t, const std::vector<Int_t>, const char*, const char*) { return kFALSE; }
62  virtual Bool_t SetVUInt(Int_t, const std::vector<UInt_t>, const char*, const char*) { return kFALSE; }
63  virtual Bool_t SetVLong(Int_t, const std::vector<Long_t>, const char*, const char*) { return kFALSE; }
64  virtual Bool_t SetVLong64(Int_t, const std::vector<Long64_t>, const char*, const char*) { return kFALSE; }
65  virtual Bool_t SetVULong64(Int_t, const std::vector<ULong64_t>, const char*, const char*) { return kFALSE; }
66  virtual Bool_t SetVDouble(Int_t, const std::vector<Double_t>, const char*, const char*) { return kFALSE; }
67 #endif
68 
69  virtual Bool_t Process() = 0;
70  virtual Int_t GetNumAffectedRows() { return 0; }
71 
72  virtual Bool_t StoreResult() = 0;
73  virtual Int_t GetNumFields() = 0;
74  virtual const char *GetFieldName(Int_t) = 0;
75  virtual Bool_t SetMaxFieldSize(Int_t, Long_t) { return kFALSE; }
76  virtual Bool_t NextResultRow() = 0;
77 
78  virtual Bool_t IsNull(Int_t) { return kTRUE; }
79  virtual Int_t GetInt(Int_t) { return 0; }
80  virtual UInt_t GetUInt(Int_t) { return 0; }
81  virtual Long_t GetLong(Int_t) { return 0; }
82  virtual Long64_t GetLong64(Int_t) { return 0; }
83  virtual ULong64_t GetULong64(Int_t) { return 0; }
84  virtual Double_t GetDouble(Int_t) { return 0.; }
85  virtual const char *GetString(Int_t) { return 0; }
86  virtual Bool_t GetBinary(Int_t, void* &, Long_t&) { return kFALSE; }
87  virtual Bool_t GetLargeObject(Int_t col, void* &mem, Long_t& size) { return GetBinary(col, mem, size); }
88 
89  virtual Bool_t GetDate(Int_t, Int_t&, Int_t&, Int_t&) { return kFALSE; }
90  virtual Bool_t GetTime(Int_t, Int_t&, Int_t&, Int_t&) { return kFALSE; }
91  virtual Bool_t GetDatime(Int_t, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&) { return kFALSE; }
99  virtual Bool_t GetTimestamp(Int_t, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&) { return kFALSE; }
101 #ifndef __MAKECINT__
102  virtual Bool_t GetVInt(Int_t, std::vector<Int_t>&) { return kFALSE; }
103  virtual Bool_t GetVUInt(Int_t, std::vector<UInt_t>&) { return kFALSE; }
104  virtual Bool_t GetVLong(Int_t, std::vector<Long_t>&) { return kFALSE; }
105  virtual Bool_t GetVLong64(Int_t, std::vector<Long64_t>&) { return kFALSE; }
106  virtual Bool_t GetVULong64(Int_t, std::vector<ULong64_t>&) { return kFALSE; }
107  virtual Bool_t GetVDouble(Int_t, std::vector<Double_t>&) { return kFALSE; }
108 #endif
109 
110  virtual Bool_t IsError() const { return GetErrorCode()!=0; }
111  virtual Int_t GetErrorCode() const;
112  virtual const char* GetErrorMsg() const;
113  virtual void EnableErrorOutput(Bool_t on = kTRUE) { fErrorOut = on; }
114 
115  ClassDef(TSQLStatement, 0) //SQL statement
116 };
117 
118 #endif
virtual Bool_t SetLong(Int_t, Long_t)
Definition: TSQLStatement.h:44
virtual Bool_t SetLargeObject(Int_t col, void *mem, Long_t size, Long_t maxsize=0x1000)
Definition: TSQLStatement.h:59
virtual Bool_t GetTime(Int_t, Int_t &, Int_t &, Int_t &)
Definition: TSQLStatement.h:90
virtual Bool_t IsNull(Int_t)
Definition: TSQLStatement.h:78
virtual Bool_t SetLong64(Int_t, Long64_t)
Definition: TSQLStatement.h:45
long long Long64_t
Definition: RtypesCore.h:69
virtual Long64_t GetLong64(Int_t)
Definition: TSQLStatement.h:82
virtual Bool_t GetVLong64(Int_t, std::vector< Long64_t > &)
virtual Bool_t SetTime(Int_t, Int_t, Int_t, Int_t)
Definition: TSQLStatement.h:51
virtual Bool_t SetVULong64(Int_t, const std::vector< ULong64_t >, const char *, const char *)
Definition: TSQLStatement.h:65
virtual Bool_t SetDate(Int_t, Int_t, Int_t, Int_t)
Definition: TSQLStatement.h:49
virtual Bool_t SetVInt(Int_t, const std::vector< Int_t >, const char *, const char *)
Definition: TSQLStatement.h:61
void ClearError()
reset error fields
virtual Long_t GetLong(Int_t)
Definition: TSQLStatement.h:81
void SetError(Int_t code, const char *msg, const char *method=0)
set new values for error fields if method specified, displays error message
virtual Bool_t GetDate(Int_t, Int_t &, Int_t &, Int_t &)
Definition: TSQLStatement.h:89
virtual Bool_t GetLargeObject(Int_t col, void *&mem, Long_t &size)
Definition: TSQLStatement.h:87
virtual Bool_t NextIteration()=0
virtual Bool_t SetTimestamp(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t=0)
Definition: TSQLStatement.h:55
Basic string class.
Definition: TString.h:125
virtual Bool_t GetVLong(Int_t, std::vector< Long_t > &)
virtual Bool_t StoreResult()=0
virtual Bool_t SetVLong(Int_t, const std::vector< Long_t >, const char *, const char *)
Definition: TSQLStatement.h:63
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual Bool_t SetString(Int_t, const char *, Int_t=256)
Definition: TSQLStatement.h:48
virtual Bool_t SetULong64(Int_t, ULong64_t)
Definition: TSQLStatement.h:46
Bool_t fErrorOut
Definition: TSQLStatement.h:28
virtual const char * GetFieldName(Int_t)=0
virtual Bool_t SetVLong64(Int_t, const std::vector< Long64_t >, const char *, const char *)
Definition: TSQLStatement.h:64
virtual Bool_t GetVDouble(Int_t, std::vector< Double_t > &)
virtual Bool_t SetVDouble(Int_t, const std::vector< Double_t >, const char *, const char *)
Definition: TSQLStatement.h:66
virtual const char * GetString(Int_t)
Definition: TSQLStatement.h:85
Int_t GetHour(Int_t)
return hours value for parameter (if applicable)
#define ClassDef(name, id)
Definition: Rtypes.h:320
virtual Bool_t SetDatime(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t)
Definition: TSQLStatement.h:53
TSQLStatement(Bool_t errout=kTRUE)
Definition: TSQLStatement.h:23
virtual void EnableErrorOutput(Bool_t on=kTRUE)
Int_t GetMinute(Int_t)
return minutes value for parameter (if applicable)
virtual Bool_t SetVUInt(Int_t, const std::vector< UInt_t >, const char *, const char *)
Definition: TSQLStatement.h:62
virtual Bool_t GetVUInt(Int_t, std::vector< UInt_t > &)
virtual ULong64_t GetULong64(Int_t)
Definition: TSQLStatement.h:83
virtual Bool_t SetDouble(Int_t, Double_t)
Definition: TSQLStatement.h:47
virtual Bool_t NextResultRow()=0
Int_t GetSecond(Int_t)
return seconds value for parameter (if applicable)
virtual Int_t GetNumAffectedRows()
Definition: TSQLStatement.h:70
virtual Int_t GetNumParameters()=0
Int_t GetMonth(Int_t)
return month value for parameter (if applicable)
virtual Double_t GetDouble(Int_t)
Definition: TSQLStatement.h:84
virtual Bool_t GetDatime(Int_t, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &)
Definition: TSQLStatement.h:91
virtual Bool_t SetBinary(Int_t, void *, Long_t, Long_t=0x1000)
Definition: TSQLStatement.h:58
virtual Int_t GetBufferLength() const =0
virtual const char * GetErrorMsg() const
returns error message of last operation if no errors, return 0 Each specific implementation of TSQLSt...
virtual ~TSQLStatement()
Definition: TSQLStatement.h:34
Int_t GetDay(Int_t)
return day value for parameter (if applicable)
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual Bool_t IsError() const
virtual Int_t GetInt(Int_t)
Definition: TSQLStatement.h:79
const Bool_t kFALSE
Definition: RtypesCore.h:88
Int_t GetYear(Int_t)
return year value for parameter (if applicable)
long Long_t
Definition: RtypesCore.h:50
double Double_t
Definition: RtypesCore.h:55
unsigned long long ULong64_t
Definition: RtypesCore.h:70
virtual Int_t GetErrorCode() const
returns error code of last operation if res==0, no error Each specific implementation of TSQLStatemen...
virtual Bool_t GetTimestamp(Int_t, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &)
Definition: TSQLStatement.h:99
virtual Bool_t GetBinary(Int_t, void *&, Long_t &)
Definition: TSQLStatement.h:86
virtual Bool_t SetUInt(Int_t, UInt_t)
Definition: TSQLStatement.h:43
Mother of all ROOT objects.
Definition: TObject.h:37
virtual Bool_t GetVULong64(Int_t, std::vector< ULong64_t > &)
virtual Bool_t SetNull(Int_t)
Definition: TSQLStatement.h:41
TString fErrorMsg
Definition: TSQLStatement.h:27
virtual Bool_t Process()=0
virtual Bool_t SetMaxFieldSize(Int_t, Long_t)
Definition: TSQLStatement.h:75
virtual Bool_t GetVInt(Int_t, std::vector< Int_t > &)
virtual Bool_t SetInt(Int_t, Int_t)
Definition: TSQLStatement.h:42
virtual UInt_t GetUInt(Int_t)
Definition: TSQLStatement.h:80
const Bool_t kTRUE
Definition: RtypesCore.h:87
virtual void SetTimeFormating(const char *)
Definition: TSQLStatement.h:57
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:37
virtual Int_t GetNumFields()=0