Logo ROOT   6.14/05
Reference Guide
TOracleStatement.h
Go to the documentation of this file.
1 // @(#)root/oracle:$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_TOracleStatement
13 #define ROOT_TOracleStatement
14 
15 #include "TSQLStatement.h"
16 
17 #if !defined(__CINT__)
18 #include <occi.h>
19 #ifdef CONST
20 #undef CONST
21 #endif
22 #else
23 namespace oracle { namespace occi {
24 class Environment;
25 class Connection;
26 class Statement;
27 class ResultSet;
28 class MetaData;
29  }}
30 #endif
31 
33 
34 protected:
35 
36  struct TBufferRec {
37  char* strbuf;
39  char* namebuf;
40  };
41 
42  oracle::occi::Environment *fEnv; // environment
43  oracle::occi::Connection *fConn; // connection to Oracle
44  oracle::occi::Statement *fStmt; // executed statement
45  oracle::occi::ResultSet *fResult; // query result (rows)
46  std::vector<oracle::occi::MetaData> *fFieldInfo; // info for each field in the row
47  TBufferRec *fBuffer; // buffer of values and field names
48  Int_t fBufferSize; // size of fBuffer
49  Int_t fNumIterations; // size of internal statement buffer
50  Int_t fIterCounter; //counts nextiteration calls and process iterations, if required
51  Int_t fWorkingMode; // 1 - settingpars, 2 - getting results
52  TString fTimeFmt; // format for date to string conversion, default "MM/DD/YYYY, HH24:MI:SS"
53 
54  Bool_t IsParSettMode() const { return fWorkingMode==1; }
55  Bool_t IsResultSet() const { return (fWorkingMode==2) && (fResult!=0); }
56 
57  void SetBufferSize(Int_t size);
58  void CloseBuffer();
59 
60 public:
61  TOracleStatement(oracle::occi::Environment* env,
62  oracle::occi::Connection* conn,
63  oracle::occi::Statement* stmt,
64  Int_t niter, Bool_t errout = kTRUE);
65  virtual ~TOracleStatement();
66 
67  virtual void Close(Option_t * = "");
68 
69  virtual Int_t GetBufferLength() const { return fNumIterations; }
70  virtual Int_t GetNumParameters();
71 
72  virtual Bool_t SetNull(Int_t npar);
73  virtual Bool_t SetInt(Int_t npar, Int_t value);
74  virtual Bool_t SetUInt(Int_t npar, UInt_t value);
75  virtual Bool_t SetLong(Int_t npar, Long_t value);
76  virtual Bool_t SetLong64(Int_t npar, Long64_t value);
77  virtual Bool_t SetULong64(Int_t npar, ULong64_t value);
78  virtual Bool_t SetDouble(Int_t npar, Double_t value);
79  virtual Bool_t SetString(Int_t npar, const char* value, Int_t maxsize = 256);
80  virtual Bool_t SetBinary(Int_t npar, void* mem, Long_t size, Long_t maxsize = 0x1000);
81  virtual Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day);
82  virtual Bool_t SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec);
83  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);
84  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);
85  virtual void SetTimeFormating(const char* fmt) { fTimeFmt = fmt; }
86  virtual Bool_t SetVInt(Int_t npar, const std::vector<Int_t> value, const char* schemaName, const char* typeName);
87  virtual Bool_t SetVUInt(Int_t npar, const std::vector<UInt_t> value, const char* schemaName, const char* typeName);
88  virtual Bool_t SetVLong(Int_t npar, const std::vector<Long_t> value, const char* schemaName, const char* typeName);
89  virtual Bool_t SetVLong64(Int_t npar, const std::vector<Long64_t> value, const char* schemaName, const char* typeName);
90  virtual Bool_t SetVULong64(Int_t npar, const std::vector<ULong64_t> value, const char* schemaName, const char* typeName);
91  virtual Bool_t SetVDouble(Int_t npar, const std::vector<Double_t> value, const char* schemaName, const char* typeName);
92 
93  virtual Bool_t NextIteration();
94 
95  virtual Bool_t Process();
96  virtual Int_t GetNumAffectedRows();
97 
98  virtual Bool_t StoreResult();
99  virtual Int_t GetNumFields();
100  virtual const char *GetFieldName(Int_t nfield);
101  virtual Bool_t SetMaxFieldSize(Int_t nfield, Long_t maxsize);
102  virtual Bool_t NextResultRow();
103 
104  virtual Bool_t IsNull(Int_t);
105  virtual Int_t GetInt(Int_t npar);
106  virtual UInt_t GetUInt(Int_t npar);
107  virtual Long_t GetLong(Int_t npar);
108  virtual Long64_t GetLong64(Int_t npar);
109  virtual ULong64_t GetULong64(Int_t npar);
110  virtual Double_t GetDouble(Int_t npar);
111  virtual const char *GetString(Int_t npar);
112  virtual Bool_t GetBinary(Int_t npar, void* &mem, Long_t& size);
113  virtual Bool_t GetDate(Int_t npar, Int_t& year, Int_t& month, Int_t& day);
114  virtual Bool_t GetTime(Int_t npar, Int_t& hour, Int_t& min, Int_t& sec);
115  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);
116  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);
117  virtual Bool_t GetVInt(Int_t npar, std::vector<Int_t> &value);
118  virtual Bool_t GetVUInt(Int_t npar, std::vector<UInt_t> &value);
119  virtual Bool_t GetVLong(Int_t npar, std::vector<Long_t> &value);
120  virtual Bool_t GetVLong64(Int_t npar, std::vector<Long64_t> &value);
121  virtual Bool_t GetVULong64(Int_t npar, std::vector<ULong64_t> &value);
122  virtual Bool_t GetVDouble(Int_t npar, std::vector<Double_t> &value);
123 
124  ClassDef(TOracleStatement, 0); // SQL statement class for Oracle
125 };
126 
127 #endif
long long Long64_t
Definition: RtypesCore.h:69
const char Option_t
Definition: RtypesCore.h:62
std::vector< oracle::occi::MetaData > * fFieldInfo
oracle::occi::Connection * fConn
Basic string class.
Definition: TString.h:131
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
#define ClassDef(name, id)
Definition: Rtypes.h:320
oracle::occi::Statement * fStmt
virtual Int_t GetBufferLength() const
Bool_t IsResultSet() const
unsigned int UInt_t
Definition: RtypesCore.h:42
oracle::occi::Environment * fEnv
virtual void SetTimeFormating(const char *fmt)
oracle::occi::ResultSet * fResult
long Long_t
Definition: RtypesCore.h:50
double Double_t
Definition: RtypesCore.h:55
unsigned long long ULong64_t
Definition: RtypesCore.h:70
Bool_t IsParSettMode() const
const Bool_t kTRUE
Definition: RtypesCore.h:87
TBufferRec * fBuffer