Logo ROOT  
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
23namespace oracle { namespace occi {
24class Environment;
25class Connection;
26class Statement;
27class ResultSet;
28class MetaData;
29 }}
30#endif
31
33
34protected:
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
60public:
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);
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);
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
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
long Long_t
Definition: RtypesCore.h:50
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
long long Long64_t
Definition: RtypesCore.h:69
unsigned long long ULong64_t
Definition: RtypesCore.h:70
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:326
oracle::occi::Statement * fStmt
virtual Int_t GetNumFields()
Returns number of fields in result set.
virtual Bool_t SetBinary(Int_t npar, void *mem, Long_t size, Long_t maxsize=0x1000)
set parameter value as binary data
virtual Bool_t NextIteration()
Add next iteration for statement with parameters.
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.
void SetBufferSize(Int_t size)
Set buffer size, which is used to keep string values of currently fetched column.
virtual Bool_t SetULong64(Int_t npar, ULong64_t value)
Set unsigned 64-bit integer value for parameter npar.
virtual const char * GetString(Int_t npar)
return field value as string
virtual Bool_t SetUInt(Int_t npar, UInt_t value)
Set unsigned integer value for parameter npar.
virtual Bool_t GetVInt(Int_t npar, std::vector< Int_t > &value)
return field value as vector of integers
virtual Bool_t GetVLong64(Int_t npar, std::vector< Long64_t > &value)
return field value as vector of 64-bit integers
virtual const char * GetFieldName(Int_t nfield)
Return field name in result set.
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.
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.
virtual Long_t GetLong(Int_t npar)
return field value as long integer
virtual void Close(Option_t *="")
Close Oracle statement Removes and destroys all buffers and metainfo.
oracle::occi::Environment * fEnv
virtual Bool_t GetVLong(Int_t npar, std::vector< Long_t > &value)
return field value as vector of long integers
virtual Int_t GetBufferLength() const
virtual Bool_t GetVUInt(Int_t npar, std::vector< UInt_t > &value)
return field value as vector of unsigned integers
virtual Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day)
Set date value for parameter npar.
virtual ~TOracleStatement()
Destructor of TOracleStatement clas.
virtual Double_t GetDouble(Int_t npar)
return field value as double
virtual Bool_t GetVULong64(Int_t npar, std::vector< ULong64_t > &value)
return field value as vector of unsigned 64-bit integers
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.
TBufferRec * fBuffer
virtual Bool_t SetString(Int_t npar, const char *value, Int_t maxsize=256)
Set string value 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 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 SetInt(Int_t npar, Int_t value)
Set integer value for parameter npar.
void CloseBuffer()
Destroy buffers, used in data fetching.
virtual Int_t GetInt(Int_t npar)
return field value as integer
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 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 Process()
Process SQL statement.
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...
virtual Bool_t NextResultRow()
Move cursor to next row in result set.
virtual Bool_t StoreResult()
Store result of statement processing.
Bool_t IsParSettMode() const
virtual Bool_t SetDouble(Int_t npar, Double_t value)
Set double value for parameter npar.
virtual Bool_t SetLong(Int_t npar, Long_t value)
Set long integer value for parameter npar.
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.
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,...
virtual UInt_t GetUInt(Int_t npar)
return field value as unsigned integer
virtual ULong64_t GetULong64(Int_t npar)
return field value as unsigned 64-bit integer
virtual Int_t GetNumParameters()
Return number of parameters in statement Not yet implemented for Oracle.
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 Int_t GetNumAffectedRows()
Return number of affected rows after statement Process() was called Make sense for queries like SELEC...
virtual Bool_t GetVDouble(Int_t npar, std::vector< Double_t > &value)
return field value as vector of doubles
oracle::occi::Connection * fConn
virtual Bool_t GetTime(Int_t npar, Int_t &hour, Int_t &min, Int_t &sec)
return field value as time
Bool_t IsResultSet() const
virtual Bool_t GetDate(Int_t npar, Int_t &year, Int_t &month, Int_t &day)
return field value as date
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 Long64_t GetLong64(Int_t npar)
return field value as 64-bit integer
virtual Bool_t IsNull(Int_t)
Checks if fieled value in result set is NULL.
virtual Bool_t SetLong64(Int_t npar, Long64_t value)
Set 64-bit integer value for parameter npar.
virtual Bool_t SetNull(Int_t npar)
Set NULL as value of parameter npar.
oracle::occi::ResultSet * fResult
std::vector< oracle::occi::MetaData > * fFieldInfo
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 Bool_t SetTimestamp(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t=0)
Set parameter as timestamp.
virtual Bool_t GetTimestamp(Int_t, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &, Int_t &)
Get parameter as timestamp.
Basic string class.
Definition: TString.h:131