Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
32 class TOracleStatement : public TSQLStatement {
33 
34 protected:
35 
36  struct TBufferRec {
37  char* strbuf;
38  Long_t strbufsize;
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  using TSQLStatement::SetTimestamp;
85  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);
86  virtual void SetTimeFormating(const char* fmt) { fTimeFmt = fmt; }
87  virtual Bool_t SetVInt(Int_t npar, const std::vector<Int_t> value, const char* schemaName, const char* typeName);
88  virtual Bool_t SetVUInt(Int_t npar, const std::vector<UInt_t> value, const char* schemaName, const char* typeName);
89  virtual Bool_t SetVLong(Int_t npar, const std::vector<Long_t> value, const char* schemaName, const char* typeName);
90  virtual Bool_t SetVLong64(Int_t npar, const std::vector<Long64_t> value, const char* schemaName, const char* typeName);
91  virtual Bool_t SetVULong64(Int_t npar, const std::vector<ULong64_t> value, const char* schemaName, const char* typeName);
92  virtual Bool_t SetVDouble(Int_t npar, const std::vector<Double_t> value, const char* schemaName, const char* typeName);
93 
94  virtual Bool_t NextIteration();
95 
96  virtual Bool_t Process();
97  virtual Int_t GetNumAffectedRows();
98 
99  virtual Bool_t StoreResult();
100  virtual Int_t GetNumFields();
101  virtual const char *GetFieldName(Int_t nfield);
102  virtual Bool_t SetMaxFieldSize(Int_t nfield, Long_t maxsize);
103  virtual Bool_t NextResultRow();
104 
105  virtual Bool_t IsNull(Int_t);
106  virtual Int_t GetInt(Int_t npar);
107  virtual UInt_t GetUInt(Int_t npar);
108  virtual Long_t GetLong(Int_t npar);
109  virtual Long64_t GetLong64(Int_t npar);
110  virtual ULong64_t GetULong64(Int_t npar);
111  virtual Double_t GetDouble(Int_t npar);
112  virtual const char *GetString(Int_t npar);
113  virtual Bool_t GetBinary(Int_t npar, void* &mem, Long_t& size);
114  virtual Bool_t GetDate(Int_t npar, Int_t& year, Int_t& month, Int_t& day);
115  virtual Bool_t GetTime(Int_t npar, Int_t& hour, Int_t& min, Int_t& sec);
116  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);
117  using TSQLStatement::GetTimestamp;
118  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);
119  virtual Bool_t GetVInt(Int_t npar, std::vector<Int_t> &value);
120  virtual Bool_t GetVUInt(Int_t npar, std::vector<UInt_t> &value);
121  virtual Bool_t GetVLong(Int_t npar, std::vector<Long_t> &value);
122  virtual Bool_t GetVLong64(Int_t npar, std::vector<Long64_t> &value);
123  virtual Bool_t GetVULong64(Int_t npar, std::vector<ULong64_t> &value);
124  virtual Bool_t GetVDouble(Int_t npar, std::vector<Double_t> &value);
125 
126  ClassDef(TOracleStatement, 0); // SQL statement class for Oracle
127 };
128 
129 #endif