Logo ROOT  
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 "TTimeStamp.h"
19 #include <vector>
20 
21 class TSQLStatement : public TObject {
22 
23 protected:
24  TSQLStatement(Bool_t errout = kTRUE) { fErrorOut = errout; }
25 
26  Int_t fErrorCode{0}; // error code of last operation
27  TString fErrorMsg; // error message of last operation
28  Bool_t fErrorOut{kFALSE}; // enable error output
29 
30  void ClearError();
31  void SetError(Int_t code, const char* msg, const char *method = nullptr);
32 
33 public:
34  virtual ~TSQLStatement() = default;
35 
36  virtual Int_t GetBufferLength() const = 0;
37  virtual Int_t GetNumParameters() = 0;
38 
39  virtual Bool_t NextIteration() = 0;
40 
41  virtual void Close(Option_t * = "") {}
42 
43  virtual Bool_t SetNull(Int_t) { return kFALSE; }
44  virtual Bool_t SetInt(Int_t, Int_t) { return kFALSE; }
45  virtual Bool_t SetUInt(Int_t, UInt_t) { return kFALSE; }
46  virtual Bool_t SetLong(Int_t, Long_t) { return kFALSE; }
47  virtual Bool_t SetLong64(Int_t, Long64_t) { return kFALSE; }
48  virtual Bool_t SetULong64(Int_t, ULong64_t) { return kFALSE; }
49  virtual Bool_t SetDouble(Int_t, Double_t) { return kFALSE; }
50  virtual Bool_t SetString(Int_t, const char*, Int_t = 256) { return kFALSE; }
51  virtual Bool_t SetDate(Int_t, Int_t, Int_t, Int_t) { return kFALSE; }
52  Bool_t SetDate(Int_t, const TDatime&);
53  virtual Bool_t SetTime(Int_t, Int_t, Int_t, Int_t) { return kFALSE; }
54  Bool_t SetTime(Int_t, const TDatime&);
56  Bool_t SetDatime(Int_t, const TDatime&);
58  virtual Bool_t SetTimestamp(Int_t, const TTimeStamp&);
60  virtual void SetTimeFormating(const char*) {}
61  virtual Bool_t SetBinary(Int_t, void*, Long_t, Long_t = 0x1000) { return kFALSE; }
62  virtual Bool_t SetLargeObject(Int_t col, void* mem, Long_t size, Long_t maxsize = 0x1000) { return SetBinary(col, mem, size, maxsize); }
63 
64  virtual Bool_t SetVInt(Int_t, const std::vector<Int_t>, const char*, const char*) { return kFALSE; }
65  virtual Bool_t SetVUInt(Int_t, const std::vector<UInt_t>, const char*, const char*) { return kFALSE; }
66  virtual Bool_t SetVLong(Int_t, const std::vector<Long_t>, const char*, const char*) { return kFALSE; }
67  virtual Bool_t SetVLong64(Int_t, const std::vector<Long64_t>, const char*, const char*) { return kFALSE; }
68  virtual Bool_t SetVULong64(Int_t, const std::vector<ULong64_t>, const char*, const char*) { return kFALSE; }
69  virtual Bool_t SetVDouble(Int_t, const std::vector<Double_t>, const char*, const char*) { return kFALSE; }
70 
71  virtual Bool_t Process() = 0;
72  virtual Int_t GetNumAffectedRows() { return 0; }
73 
74  virtual Bool_t StoreResult() = 0;
75  virtual Int_t GetNumFields() = 0;
76  virtual const char *GetFieldName(Int_t) = 0;
77  virtual Bool_t SetMaxFieldSize(Int_t, Long_t) { return kFALSE; }
78  virtual Bool_t NextResultRow() = 0;
79 
80  virtual Bool_t IsNull(Int_t) { return kTRUE; }
81  virtual Int_t GetInt(Int_t) { return 0; }
82  virtual UInt_t GetUInt(Int_t) { return 0; }
83  virtual Long_t GetLong(Int_t) { return 0; }
84  virtual Long64_t GetLong64(Int_t) { return 0; }
85  virtual ULong64_t GetULong64(Int_t) { return 0; }
86  virtual Double_t GetDouble(Int_t) { return 0.; }
87  virtual const char *GetString(Int_t) { return 0; }
88  virtual Bool_t GetBinary(Int_t, void* &, Long_t&) { return kFALSE; }
89  virtual Bool_t GetLargeObject(Int_t col, void* &mem, Long_t& size) { return GetBinary(col, mem, size); }
90 
91  virtual Bool_t GetDate(Int_t, Int_t&, Int_t&, Int_t&) { return kFALSE; }
92  virtual Bool_t GetTime(Int_t, Int_t&, Int_t&, Int_t&) { return kFALSE; }
93  virtual Bool_t GetDatime(Int_t, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&) { return kFALSE; }
102  virtual Bool_t GetTimestamp(Int_t, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&);
103  virtual Bool_t GetTimestamp(Int_t, TTimeStamp&);
105  virtual Bool_t GetVInt(Int_t, std::vector<Int_t>&) { return kFALSE; }
106  virtual Bool_t GetVUInt(Int_t, std::vector<UInt_t>&) { return kFALSE; }
107  virtual Bool_t GetVLong(Int_t, std::vector<Long_t>&) { return kFALSE; }
108  virtual Bool_t GetVLong64(Int_t, std::vector<Long64_t>&) { return kFALSE; }
109  virtual Bool_t GetVULong64(Int_t, std::vector<ULong64_t>&) { return kFALSE; }
110  virtual Bool_t GetVDouble(Int_t, std::vector<Double_t>&) { return kFALSE; }
111 
112  virtual Bool_t IsError() const { return GetErrorCode()!=0; }
113  virtual Int_t GetErrorCode() const;
114  virtual const char* GetErrorMsg() const;
115  virtual void EnableErrorOutput(Bool_t on = kTRUE) { fErrorOut = on; }
116 
117  ClassDef(TSQLStatement, 0) //SQL statement
118 };
119 
120 #endif
TSQLStatement::GetTime
virtual Bool_t GetTime(Int_t, Int_t &, Int_t &, Int_t &)
Definition: TSQLStatement.h:92
TSQLStatement::SetString
virtual Bool_t SetString(Int_t, const char *, Int_t=256)
Definition: TSQLStatement.h:50
TSQLStatement::IsError
virtual Bool_t IsError() const
Definition: TSQLStatement.h:112
TSQLStatement::GetBinary
virtual Bool_t GetBinary(Int_t, void *&, Long_t &)
Definition: TSQLStatement.h:88
TSQLStatement::NextResultRow
virtual Bool_t NextResultRow()=0
TSQLStatement::GetVInt
virtual Bool_t GetVInt(Int_t, std::vector< Int_t > &)
Definition: TSQLStatement.h:105
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TSQLStatement::ClearError
void ClearError()
reset error fields
Definition: TSQLStatement.cxx:252
TSQLStatement::SetTimestamp
virtual Bool_t SetTimestamp(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t=0)
Set parameter as timestamp.
Definition: TSQLStatement.cxx:421
TSQLStatement::GetULong64
virtual ULong64_t GetULong64(Int_t)
Definition: TSQLStatement.h:85
Option_t
const char Option_t
Definition: RtypesCore.h:66
TSQLStatement::GetTimestamp
virtual Bool_t GetTimestamp(Int_t, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &)
Get parameter as timestamp.
Definition: TSQLStatement.cxx:438
TTimeStamp.h
TSQLStatement::SetInt
virtual Bool_t SetInt(Int_t, Int_t)
Definition: TSQLStatement.h:44
TSQLStatement::SetLong
virtual Bool_t SetLong(Int_t, Long_t)
Definition: TSQLStatement.h:46
TSQLStatement::GetErrorMsg
virtual const char * GetErrorMsg() const
returns error message of last operation if no errors, return 0 Each specific implementation of TSQLSt...
Definition: TSQLStatement.cxx:244
TSQLStatement::SetVInt
virtual Bool_t SetVInt(Int_t, const std::vector< Int_t >, const char *, const char *)
Definition: TSQLStatement.h:64
TDatime.h
TSQLStatement::IsNull
virtual Bool_t IsNull(Int_t)
Definition: TSQLStatement.h:80
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TSQLStatement::GetLargeObject
virtual Bool_t GetLargeObject(Int_t col, void *&mem, Long_t &size)
Definition: TSQLStatement.h:89
TSQLStatement::SetVULong64
virtual Bool_t SetVULong64(Int_t, const std::vector< ULong64_t >, const char *, const char *)
Definition: TSQLStatement.h:68
TSQLStatement::GetVDouble
virtual Bool_t GetVDouble(Int_t, std::vector< Double_t > &)
Definition: TSQLStatement.h:110
TSQLStatement::SetMaxFieldSize
virtual Bool_t SetMaxFieldSize(Int_t, Long_t)
Definition: TSQLStatement.h:77
Int_t
int Int_t
Definition: RtypesCore.h:45
TSQLStatement::GetBufferLength
virtual Int_t GetBufferLength() const =0
TSQLStatement::GetNumParameters
virtual Int_t GetNumParameters()=0
TSQLStatement::SetVLong
virtual Bool_t SetVLong(Int_t, const std::vector< Long_t >, const char *, const char *)
Definition: TSQLStatement.h:66
TSQLStatement::SetUInt
virtual Bool_t SetUInt(Int_t, UInt_t)
Definition: TSQLStatement.h:45
TSQLStatement::GetInt
virtual Int_t GetInt(Int_t)
Definition: TSQLStatement.h:81
TSQLStatement::NextIteration
virtual Bool_t NextIteration()=0
TString
Basic string class.
Definition: TString.h:136
TSQLStatement::GetDay
Int_t GetDay(Int_t)
return day value for parameter (if applicable)
Definition: TSQLStatement.cxx:348
TSQLStatement::EnableErrorOutput
virtual void EnableErrorOutput(Bool_t on=kTRUE)
Definition: TSQLStatement.h:115
TSQLStatement::GetMonth
Int_t GetMonth(Int_t)
return month value for parameter (if applicable)
Definition: TSQLStatement.cxx:337
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TSQLStatement::GetVLong
virtual Bool_t GetVLong(Int_t, std::vector< Long_t > &)
Definition: TSQLStatement.h:107
TString.h
TSQLStatement::fErrorMsg
TString fErrorMsg
Definition: TSQLStatement.h:27
bool
TSQLStatement::SetULong64
virtual Bool_t SetULong64(Int_t, ULong64_t)
Definition: TSQLStatement.h:48
TSQLStatement::GetVLong64
virtual Bool_t GetVLong64(Int_t, std::vector< Long64_t > &)
Definition: TSQLStatement.h:108
TSQLStatement::GetDatime
virtual Bool_t GetDatime(Int_t, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &)
Definition: TSQLStatement.h:93
TSQLStatement::GetSecond
Int_t GetSecond(Int_t)
return seconds value for parameter (if applicable)
Definition: TSQLStatement.cxx:381
TSQLStatement::GetYear
Int_t GetYear(Int_t)
return year value for parameter (if applicable)
Definition: TSQLStatement.cxx:326
TSQLStatement::SetDouble
virtual Bool_t SetDouble(Int_t, Double_t)
Definition: TSQLStatement.h:49
TSQLStatement::SetLong64
virtual Bool_t SetLong64(Int_t, Long64_t)
Definition: TSQLStatement.h:47
TSQLStatement::GetNumFields
virtual Int_t GetNumFields()=0
TSQLStatement::SetVLong64
virtual Bool_t SetVLong64(Int_t, const std::vector< Long64_t >, const char *, const char *)
Definition: TSQLStatement.h:67
TSQLStatement::GetSecondsFraction
Int_t GetSecondsFraction(Int_t)
return seconds fraction value for parameter (if applicable)
Definition: TSQLStatement.cxx:392
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TSQLStatement::Process
virtual Bool_t Process()=0
TSQLStatement::SetTimeFormating
virtual void SetTimeFormating(const char *)
Definition: TSQLStatement.h:60
Long_t
long Long_t
Definition: RtypesCore.h:54
TSQLStatement::SetError
void SetError(Int_t code, const char *msg, const char *method=nullptr)
set new values for error fields if method specified, displays error message
Definition: TSQLStatement.cxx:262
TSQLStatement::GetFieldName
virtual const char * GetFieldName(Int_t)=0
TSQLStatement::SetVUInt
virtual Bool_t SetVUInt(Int_t, const std::vector< UInt_t >, const char *, const char *)
Definition: TSQLStatement.h:65
TSQLStatement::GetUInt
virtual UInt_t GetUInt(Int_t)
Definition: TSQLStatement.h:82
TSQLStatement::GetString
virtual const char * GetString(Int_t)
Definition: TSQLStatement.h:87
TSQLStatement::fErrorCode
Int_t fErrorCode
Definition: TSQLStatement.h:26
unsigned int
TSQLStatement::SetBinary
virtual Bool_t SetBinary(Int_t, void *, Long_t, Long_t=0x1000)
Definition: TSQLStatement.h:61
TSQLStatement::GetVULong64
virtual Bool_t GetVULong64(Int_t, std::vector< ULong64_t > &)
Definition: TSQLStatement.h:109
TSQLStatement::SetNull
virtual Bool_t SetNull(Int_t)
Definition: TSQLStatement.h:43
TSQLStatement::GetMinute
Int_t GetMinute(Int_t)
return minutes value for parameter (if applicable)
Definition: TSQLStatement.cxx:370
ULong64_t
unsigned long long ULong64_t
Definition: RtypesCore.h:74
Double_t
double Double_t
Definition: RtypesCore.h:59
TSQLStatement::GetHour
Int_t GetHour(Int_t)
return hours value for parameter (if applicable)
Definition: TSQLStatement.cxx:359
TObject.h
TSQLStatement::GetLong64
virtual Long64_t GetLong64(Int_t)
Definition: TSQLStatement.h:84
TSQLStatement::SetTime
virtual Bool_t SetTime(Int_t, Int_t, Int_t, Int_t)
Definition: TSQLStatement.h:53
TSQLStatement::~TSQLStatement
virtual ~TSQLStatement()=default
TSQLStatement::SetDatime
virtual Bool_t SetDatime(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t)
Definition: TSQLStatement.h:55
TSQLStatement::TSQLStatement
TSQLStatement(Bool_t errout=kTRUE)
Definition: TSQLStatement.h:24
TSQLStatement
Definition: TSQLStatement.h:21
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TSQLStatement::GetNumAffectedRows
virtual Int_t GetNumAffectedRows()
Definition: TSQLStatement.h:72
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TSQLStatement::GetVUInt
virtual Bool_t GetVUInt(Int_t, std::vector< UInt_t > &)
Definition: TSQLStatement.h:106
TDatime
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:37
TSQLStatement::SetVDouble
virtual Bool_t SetVDouble(Int_t, const std::vector< Double_t >, const char *, const char *)
Definition: TSQLStatement.h:69
TSQLStatement::SetDate
virtual Bool_t SetDate(Int_t, Int_t, Int_t, Int_t)
Definition: TSQLStatement.h:51
TSQLStatement::SetLargeObject
virtual Bool_t SetLargeObject(Int_t col, void *mem, Long_t size, Long_t maxsize=0x1000)
Definition: TSQLStatement.h:62
TTimeStamp
The TTimeStamp encapsulates seconds and ns since EPOCH.
Definition: TTimeStamp.h:71
TSQLStatement::GetLong
virtual Long_t GetLong(Int_t)
Definition: TSQLStatement.h:83
TSQLStatement::Close
virtual void Close(Option_t *="")
Definition: TSQLStatement.h:41
TSQLStatement::GetDate
virtual Bool_t GetDate(Int_t, Int_t &, Int_t &, Int_t &)
Definition: TSQLStatement.h:91
TSQLStatement::fErrorOut
Bool_t fErrorOut
Definition: TSQLStatement.h:28
TSQLStatement::GetDouble
virtual Double_t GetDouble(Int_t)
Definition: TSQLStatement.h:86
TSQLStatement::GetErrorCode
virtual Int_t GetErrorCode() const
returns error code of last operation if res==0, no error Each specific implementation of TSQLStatemen...
Definition: TSQLStatement.cxx:234
int
TSQLStatement::StoreResult
virtual Bool_t StoreResult()=0