Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 <vector>
18
19namespace oracle {
20namespace occi {
21 class Environment;
22 class Connection;
23 class Statement;
24 class ResultSet;
25 struct MetaData;
26}
27}
28
30
31protected:
32
33 struct TBufferRec {
34 void *membuf{nullptr};
36 std::string namebuf;
37 };
38
39 oracle::occi::Environment *fEnv{nullptr}; // environment
40 oracle::occi::Connection *fConn{nullptr}; // connection to Oracle
41 oracle::occi::Statement *fStmt{nullptr}; // executed statement
42 oracle::occi::ResultSet *fResult{nullptr}; // query result (rows)
43 std::vector<oracle::occi::MetaData> *fFieldInfo{nullptr}; // info for each field in the row
44 TBufferRec *fBuffer{nullptr}; // buffer of values and field names
45 Int_t fBufferSize{0}; // size of fBuffer
46 Int_t fNumIterations{0}; // size of internal statement buffer
47 Int_t fIterCounter{0}; // counts nextiteration calls and process iterations, if required
48 Int_t fWorkingMode{0}; // 1 - settingpars, 2 - getting results
49 TString fTimeFmt; // format for date to string conversion, default "MM/DD/YYYY, HH24:MI:SS"
50
51 Bool_t IsParSettMode() const { return fWorkingMode == 1; }
52 Bool_t IsResultSet() const { return (fWorkingMode == 2) && (fResult != nullptr); }
53
55 void CloseBuffer();
56
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 void Close(Option_t * = "") final;
68
69 Int_t GetBufferLength() const final { return fNumIterations; }
70 Int_t GetNumParameters() final;
71
72 Bool_t SetNull(Int_t npar) final;
73 Bool_t SetInt(Int_t npar, Int_t value) final;
74 Bool_t SetUInt(Int_t npar, UInt_t value) final;
75 Bool_t SetLong(Int_t npar, Long_t value) final;
76 Bool_t SetLong64(Int_t npar, Long64_t value) final;
78 Bool_t SetDouble(Int_t npar, Double_t value) final;
79 Bool_t SetString(Int_t npar, const char* value, Int_t maxsize = 256) final;
80 Bool_t SetBinary(Int_t npar, void* mem, Long_t size, Long_t maxsize = 0x1000) final;
81 Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day) final;
82 Bool_t SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec) final;
83 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;
85 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;
86 void SetTimeFormating(const char *fmt) final { fTimeFmt = fmt; }
87 Bool_t SetVInt(Int_t npar, const std::vector<Int_t> value, const char* schemaName, const char* typeName) final;
88 Bool_t SetVUInt(Int_t npar, const std::vector<UInt_t> value, const char* schemaName, const char* typeName) final;
89 Bool_t SetVLong(Int_t npar, const std::vector<Long_t> value, const char* schemaName, const char* typeName) final;
90 Bool_t SetVLong64(Int_t npar, const std::vector<Long64_t> value, const char* schemaName, const char* typeName) final;
91 Bool_t SetVULong64(Int_t npar, const std::vector<ULong64_t> value, const char* schemaName, const char* typeName) final;
92 Bool_t SetVDouble(Int_t npar, const std::vector<Double_t> value, const char* schemaName, const char* typeName) final;
93
94 Bool_t NextIteration() final;
95
96 Bool_t Process() final;
98
99 Bool_t StoreResult() final;
100 Int_t GetNumFields() final;
101 const char *GetFieldName(Int_t nfield) final;
102 Bool_t SetMaxFieldSize(Int_t nfield, Long_t maxsize) final;
103 Bool_t NextResultRow() final;
104
105 Bool_t IsNull(Int_t) final;
106 Int_t GetInt(Int_t npar) final;
107 UInt_t GetUInt(Int_t npar) final;
108 Long_t GetLong(Int_t npar) final;
109 Long64_t GetLong64(Int_t npar) final;
110 ULong64_t GetULong64(Int_t npar) final;
111 Double_t GetDouble(Int_t npar) final;
112 const char *GetString(Int_t npar) final;
113 Bool_t GetBinary(Int_t npar, void* &mem, Long_t& size) final;
114 Bool_t GetDate(Int_t npar, Int_t& year, Int_t& month, Int_t& day) final;
115 Bool_t GetTime(Int_t npar, Int_t& hour, Int_t& min, Int_t& sec) final;
116 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;
118 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;
119 Bool_t GetVInt(Int_t npar, std::vector<Int_t> &value) final;
120 Bool_t GetVUInt(Int_t npar, std::vector<UInt_t> &value) final;
121 Bool_t GetVLong(Int_t npar, std::vector<Long_t> &value) final;
122 Bool_t GetVLong64(Int_t npar, std::vector<Long64_t> &value) final;
123 Bool_t GetVULong64(Int_t npar, std::vector<ULong64_t> &value) final;
124 Bool_t GetVDouble(Int_t npar, std::vector<Double_t> &value) final;
125
126 ClassDefOverride(TOracleStatement, 0); // SQL statement class for Oracle
127};
128
129#endif
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
long Long_t
Definition RtypesCore.h:54
unsigned int UInt_t
Definition RtypesCore.h:46
double Double_t
Definition RtypesCore.h:59
long long Long64_t
Definition RtypesCore.h:80
unsigned long long ULong64_t
Definition RtypesCore.h:81
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
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
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
oracle::occi::ResultSet * fResult
std::vector< oracle::occi::MetaData > * fFieldInfo
Basic string class.
Definition TString.h:139