ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 #ifndef ROOT_TSQLStatement
16 #include "TSQLStatement.h"
17 #endif
18 
19 #if !defined(__CINT__)
20 #include <occi.h>
21 #ifdef CONST
22 #undef CONST
23 #endif
24 #else
25 namespace oracle { namespace occi {
26 class Environment;
27 class Connection;
28 class Statement;
29 class ResultSet;
30 class MetaData;
31  }}
32 #endif
33 
35 
36 protected:
37 
38  struct TBufferRec {
39  char* strbuf;
41  char* namebuf;
42  };
43 
44  oracle::occi::Environment *fEnv; // environment
45  oracle::occi::Connection *fConn; // connection to Oracle
46  oracle::occi::Statement *fStmt; // executed statement
47  oracle::occi::ResultSet *fResult; // query result (rows)
48  std::vector<oracle::occi::MetaData> *fFieldInfo; // info for each field in the row
49  TBufferRec *fBuffer; // buffer of values and field names
50  Int_t fBufferSize; // size of fBuffer
51  Int_t fNumIterations; // size of internal statement buffer
52  Int_t fIterCounter; //counts nextiteration calls and process iterations, if required
53  Int_t fWorkingMode; // 1 - settingpars, 2 - getting results
54  TString fTimeFmt; // format for date to string conversion, default "MM/DD/YYYY, HH24:MI:SS"
55 
56  Bool_t IsParSettMode() const { return fWorkingMode==1; }
57  Bool_t IsResultSet() const { return (fWorkingMode==2) && (fResult!=0); }
58 
59  void SetBufferSize(Int_t size);
60  void CloseBuffer();
61 
62 public:
63  TOracleStatement(oracle::occi::Environment* env,
64  oracle::occi::Connection* conn,
65  oracle::occi::Statement* stmt,
66  Int_t niter, Bool_t errout = kTRUE);
67  virtual ~TOracleStatement();
68 
69  virtual void Close(Option_t * = "");
70 
71  virtual Int_t GetBufferLength() const { return fNumIterations; }
72  virtual Int_t GetNumParameters();
73 
74  virtual Bool_t SetNull(Int_t npar);
75  virtual Bool_t SetInt(Int_t npar, Int_t value);
76  virtual Bool_t SetUInt(Int_t npar, UInt_t value);
77  virtual Bool_t SetLong(Int_t npar, Long_t value);
78  virtual Bool_t SetLong64(Int_t npar, Long64_t value);
79  virtual Bool_t SetULong64(Int_t npar, ULong64_t value);
80  virtual Bool_t SetDouble(Int_t npar, Double_t value);
81  virtual Bool_t SetString(Int_t npar, const char* value, Int_t maxsize = 256);
82  virtual Bool_t SetBinary(Int_t npar, void* mem, Long_t size, Long_t maxsize = 0x1000);
83  virtual Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day);
84  virtual Bool_t SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec);
85  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);
86  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);
87  virtual void SetTimeFormating(const char* fmt) { fTimeFmt = fmt; }
88  virtual Bool_t SetVInt(Int_t npar, const std::vector<Int_t> value, const char* schemaName, const char* typeName);
89  virtual Bool_t SetVUInt(Int_t npar, const std::vector<UInt_t> value, const char* schemaName, const char* typeName);
90  virtual Bool_t SetVLong(Int_t npar, const std::vector<Long_t> value, const char* schemaName, const char* typeName);
91  virtual Bool_t SetVLong64(Int_t npar, const std::vector<Long64_t> value, const char* schemaName, const char* typeName);
92  virtual Bool_t SetVULong64(Int_t npar, const std::vector<ULong64_t> value, const char* schemaName, const char* typeName);
93  virtual Bool_t SetVDouble(Int_t npar, const std::vector<Double_t> value, const char* schemaName, const char* typeName);
94 
95  virtual Bool_t NextIteration();
96 
97  virtual Bool_t Process();
98  virtual Int_t GetNumAffectedRows();
99 
100  virtual Bool_t StoreResult();
101  virtual Int_t GetNumFields();
102  virtual const char *GetFieldName(Int_t nfield);
103  virtual Bool_t SetMaxFieldSize(Int_t nfield, Long_t maxsize);
104  virtual Bool_t NextResultRow();
105 
106  virtual Bool_t IsNull(Int_t);
107  virtual Int_t GetInt(Int_t npar);
108  virtual UInt_t GetUInt(Int_t npar);
109  virtual Long_t GetLong(Int_t npar);
110  virtual Long64_t GetLong64(Int_t npar);
111  virtual ULong64_t GetULong64(Int_t npar);
112  virtual Double_t GetDouble(Int_t npar);
113  virtual const char *GetString(Int_t npar);
114  virtual Bool_t GetBinary(Int_t npar, void* &mem, Long_t& size);
115  virtual Bool_t GetDate(Int_t npar, Int_t& year, Int_t& month, Int_t& day);
116  virtual Bool_t GetTime(Int_t npar, Int_t& hour, Int_t& min, Int_t& sec);
117  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);
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
virtual const char * GetString(Int_t npar)
return field value as string
virtual Long_t GetLong(Int_t npar)
return field value as long integer
virtual Int_t GetNumAffectedRows()
Return number of affected rows after statement Process() was called Make sense for queries like SELEC...
TOracleStatement(oracle::occi::Environment *env, oracle::occi::Connection *conn, oracle::occi::Statement *stmt, Int_t niter, Bool_t errout=kTRUE)
Normal constructor of TOracleStatement class On creation time specifies buffer length, which should be used in data fetching or data inserting.
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
long long Long64_t
Definition: RtypesCore.h:69
virtual Bool_t GetVLong64(Int_t npar, std::vector< Long64_t > &value)
return field value as vector of 64-bit integers
virtual Bool_t GetVUInt(Int_t npar, std::vector< UInt_t > &value)
return field value as vector of unsigned integers
virtual Bool_t GetVULong64(Int_t npar, std::vector< ULong64_t > &value)
return field value as vector of unsigned 64-bit integers
const char Option_t
Definition: RtypesCore.h:62
virtual Bool_t SetVUInt(Int_t npar, const std::vector< UInt_t > value, const char *schemaName, const char *typeName)
Set vector of unsigned integer values for parameter npar.
std::vector< oracle::occi::MetaData > * fFieldInfo
virtual Bool_t GetDate(Int_t npar, Int_t &year, Int_t &month, Int_t &day)
return field value as date
virtual Bool_t SetVLong64(Int_t npar, const std::vector< Long64_t > value, const char *schemaName, const char *typeName)
Set vector of 64-bit integer values for parameter npar.
void SetBufferSize(Int_t size)
Set buffer size, which is used to keep string values of currently fetched column. ...
oracle::occi::Connection * fConn
virtual Bool_t SetVDouble(Int_t npar, const std::vector< Double_t > value, const char *schemaName, const char *typeName)
Set vector of double values for parameter npar.
virtual const char * GetFieldName(Int_t nfield)
Return field name in result set.
Basic string class.
Definition: TString.h:137
virtual Bool_t SetULong64(Int_t npar, ULong64_t value)
Set unsigned 64-bit integer value for parameter npar.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual Bool_t Process()
Process SQL statement.
virtual Long64_t GetLong64(Int_t npar)
return field value as 64-bit integer
virtual ULong64_t GetULong64(Int_t npar)
return field value as unsigned 64-bit integer
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)
Set date & time value for parameter npar.
const int maxsize
virtual Bool_t GetBinary(Int_t npar, void *&mem, Long_t &size)
Return field value as binary array Supports LONG, BLOB, CLOB, BFILE, CFILE types of columns Reads com...
Bool_t IsParSettMode() const
virtual Bool_t SetBinary(Int_t npar, void *mem, Long_t size, Long_t maxsize=0x1000)
set parameter value as binary data
virtual ~TOracleStatement()
Destructor of TOracleStatement clas.
oracle::occi::Statement * fStmt
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)
return field value as date & time
virtual Int_t GetInt(Int_t npar)
return field value as integer
virtual Bool_t GetVDouble(Int_t npar, std::vector< Double_t > &value)
return field value as vector of doubles
virtual Bool_t GetVInt(Int_t npar, std::vector< Int_t > &value)
return field value as vector of integers
ClassDef(TOracleStatement, 0)
virtual Bool_t SetVInt(Int_t npar, const std::vector< Int_t > value, const char *schemaName, const char *typeName)
Set vector of integer values for parameter npar.
virtual Bool_t SetVULong64(Int_t npar, const std::vector< ULong64_t > value, const char *schemaName, const char *typeName)
Set vector of unsigned 64-bit integer values for parameter npar.
virtual Bool_t GetVLong(Int_t npar, std::vector< Long_t > &value)
return field value as vector of long integers
virtual Bool_t SetUInt(Int_t npar, UInt_t value)
Set unsigned integer value for parameter npar.
virtual Bool_t IsNull(Int_t)
Checks if fieled value in result set is NULL.
void CloseBuffer()
Destroy buffers, used in data fetching.
unsigned int UInt_t
Definition: RtypesCore.h:42
oracle::occi::Environment * fEnv
virtual void SetTimeFormating(const char *fmt)
virtual Bool_t SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec)
Set time value for parameter npar.
Bool_t IsResultSet() const
virtual Bool_t SetDouble(Int_t npar, Double_t value)
Set double value for parameter npar.
virtual Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day)
Set date value for parameter npar.
virtual Bool_t GetTime(Int_t npar, Int_t &hour, Int_t &min, Int_t &sec)
return field value as time
oracle::occi::ResultSet * fResult
virtual Bool_t SetInt(Int_t npar, Int_t value)
Set integer value for parameter npar.
virtual Double_t GetDouble(Int_t npar)
return field value as double
long Long_t
Definition: RtypesCore.h:50
virtual UInt_t GetUInt(Int_t npar)
return field value as unsigned integer
virtual Int_t GetNumParameters()
Return number of parameters in statement Not yet implemented for Oracle.
virtual Bool_t StoreResult()
Store result of statement processing.
double Double_t
Definition: RtypesCore.h:55
unsigned long long ULong64_t
Definition: RtypesCore.h:70
virtual Int_t GetNumFields()
Returns number of fields in result set.
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)
Set date & time value for parameter npar.
virtual Bool_t SetNull(Int_t npar)
Set NULL as value of parameter npar.
virtual Bool_t SetString(Int_t npar, const char *value, Int_t maxsize=256)
Set string value for parameter npar.
virtual Bool_t SetLong64(Int_t npar, Long64_t value)
Set 64-bit integer value for parameter npar.
virtual Int_t GetBufferLength() const
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)
return field value as date & time
virtual Bool_t SetVLong(Int_t npar, const std::vector< Long_t > value, const char *schemaName, const char *typeName)
Set vector of long integer values for parameter npar.
virtual Bool_t SetLong(Int_t npar, Long_t value)
Set long integer value for parameter npar.
const Bool_t kTRUE
Definition: Rtypes.h:91
float value
Definition: math.cpp:443
virtual Bool_t SetMaxFieldSize(Int_t nfield, Long_t maxsize)
Defines maximum size for field which must be used for read or write operation Some Oracle types as LO...
virtual void Close(Option_t *="")
Close Oracle statement Removes and destroys all buffers and metainfo.
virtual Bool_t NextResultRow()
Move cursor to next row in result set.
TBufferRec * fBuffer
virtual Bool_t NextIteration()
Add next iteration for statement with parameters.