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