Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TPgSQLStatement.h
Go to the documentation of this file.
1// @(#)root/mysql:$Id$
2// Author: Dennis Box (dbox@fnal.gov) 3/12/2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, 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_TPgSQLStatement
13#define ROOT_TPgSQLStatement
14
15#include "TSQLStatement.h"
16
17struct pg_conn;
18typedef struct pg_conn PGconn;
19
20struct pg_result;
21typedef struct pg_result PGresult;
22
23
27};
28
30
31private:
32
33 PgSQL_Stmt_t *fStmt{nullptr}; //! executed statement
34 Int_t fNumBuffers{0}; //! number of statement parameters
35 char **fBind{nullptr}; //! array of data for input
36 char **fFieldName{nullptr}; //! array of column names
37 Int_t fWorkingMode{0}; //! 1 - setting parameters, 2 - retrieving results
38 Int_t fIterationCount{0}; //! number of iteration
39 int *fParamLengths{nullptr}; //! length of column
40 int *fParamFormats{nullptr}; //! data type (OID)
43
44 Bool_t IsSetParsMode() const { return fWorkingMode==1; }
45 Bool_t IsResultSetMode() const { return fWorkingMode==2; }
46
47 Bool_t SetSQLParamType(Int_t npar, Bool_t isbinary = kFALSE, Int_t param_len = 0, Int_t maxsize = 0);
48
49 long double ConvertToNumeric(Int_t npar);
50 const char *ConvertToString(Int_t npar);
51
52 void FreeBuffers();
54
55 void ConvertTimeToUTC(const TString &PQvalue, Int_t& year, Int_t& month, Int_t& day, Int_t& hour, Int_t& min, Int_t& sec);
56
57public:
59 virtual ~TPgSQLStatement();
60
61 void Close(Option_t * = "") final;
62
63 Int_t GetBufferLength() const final { return 1; }
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;
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 SetLargeObject(Int_t npar, void* mem, Long_t size, Long_t maxsize = 0x1000) final;
76 Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day) final;
77 Bool_t SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec) final;
78 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 Bool_t SetTimestamp(Int_t npar, const TTimeStamp& tm) final;
81
82 Bool_t NextIteration() final;
83
84 Bool_t Process() final;
86
87 Bool_t StoreResult() final;
88 Int_t GetNumFields() final;
89 const char *GetFieldName(Int_t nfield) final;
90 Bool_t NextResultRow() final;
91
92 Bool_t IsNull(Int_t npar) final;
93 Int_t GetInt(Int_t npar) final;
94 UInt_t GetUInt(Int_t npar) final;
95 Long_t GetLong(Int_t npar) final;
96 Long64_t GetLong64(Int_t npar) final;
97 ULong64_t GetULong64(Int_t npar) final;
98 Double_t GetDouble(Int_t npar) final;
99 const char *GetString(Int_t npar) final;
100 Bool_t GetBinary(Int_t npar, void* &mem, Long_t& size) final;
101 Bool_t GetLargeObject(Int_t npar, void* &mem, Long_t& size) final;
102 Bool_t GetDate(Int_t npar, Int_t& year, Int_t& month, Int_t& day) final;
103 Bool_t GetTime(Int_t npar, Int_t& hour, Int_t& min, Int_t& sec) final;
104 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;
105 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&) final;
106 Bool_t GetTimestamp(Int_t npar, TTimeStamp& tm) final;
107
108 ClassDefOverride(TPgSQLStatement, 0); // SQL statement class for PgSQL DB
109};
110
111#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
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
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
struct pg_result PGresult
struct pg_conn PGconn
struct pg_conn PGconn
struct pg_result PGresult
PgSQL_Stmt_t * fStmt
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 parameter value as date & time.
void ConvertTimeToUTC(const TString &PQvalue, Int_t &year, Int_t &month, Int_t &day, Int_t &hour, Int_t &min, Int_t &sec)
void SetBuffersNumber(Int_t n)
Allocate buffers for statement parameters/ result fields.
Int_t fNumResultRows
data type (OID)
UInt_t GetUInt(Int_t npar) final
Return field value as unsigned integer.
Bool_t SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec) final
Set parameter value as time.
long double ConvertToNumeric(Int_t npar)
Convert field to numeric value.
Bool_t GetTime(Int_t npar, Int_t &hour, Int_t &min, Int_t &sec) final
Return field value as time.
Bool_t SetLargeObject(Int_t npar, void *mem, Long_t size, Long_t maxsize=0x1000) final
Set parameter value to large object and immediately insert the large object into DB.
Bool_t IsResultSetMode() const
int * fParamLengths
number of iteration
Bool_t GetDate(Int_t npar, Int_t &year, Int_t &month, Int_t &day) final
Return field value as date.
Int_t GetInt(Int_t npar) final
Return field value as integer.
Int_t GetNumParameters() final
Return number of statement parameters.
const char * GetString(Int_t npar) final
Return field value as string.
Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day) final
Set parameter value as date.
Bool_t GetLargeObject(Int_t npar, void *&mem, Long_t &size) final
Return large object whose oid is in the given field.
Bool_t SetInt(Int_t npar, Int_t value) final
Set parameter value as integer.
ULong64_t GetULong64(Int_t npar) final
Return field value as unsigned 64-bit integer.
Long_t GetLong(Int_t npar) final
Return field value as long integer.
Bool_t SetSQLParamType(Int_t npar, Bool_t isbinary=kFALSE, Int_t param_len=0, Int_t maxsize=0)
Set parameter type to be used as buffer.
Int_t fIterationCount
1 - setting parameters, 2 - retrieving results
Int_t fNumBuffers
executed statement
Int_t fWorkingMode
array of column names
Bool_t GetBinary(Int_t npar, void *&mem, Long_t &size) final
Return field value as binary array.
Int_t GetBufferLength() const final
Bool_t IsSetParsMode() const
Bool_t IsNull(Int_t npar) final
Checks if field value is null.
Int_t GetNumFields() final
Return number of fields in result set.
Double_t GetDouble(Int_t npar) final
Return field value as double.
Bool_t SetDouble(Int_t npar, Double_t value) final
Set parameter value as double.
Bool_t NextResultRow() final
Shift cursor to nect row in result set.
Long64_t GetLong64(Int_t npar) final
Return field value as 64-bit integer.
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 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 parameter value as timestamp.
Int_t GetNumAffectedRows() final
Return number of affected rows after statement is processed.
Bool_t SetLong(Int_t npar, Long_t value) final
Set parameter value as long integer.
Bool_t StoreResult() final
Store result of statement processing to access them via GetInt(), GetDouble() and so on methods.
Bool_t SetUInt(Int_t npar, UInt_t value) final
Set parameter value as unsigned integer.
const char * GetFieldName(Int_t nfield) final
Returns field name in result set.
Bool_t SetNull(Int_t npar) final
Set NULL as parameter value.
const char * ConvertToString(Int_t npar)
Convert field value to string.
Bool_t SetULong64(Int_t npar, ULong64_t value) final
Set parameter value as unsigned 64-bit integer.
char ** fBind
number of statement parameters
void FreeBuffers()
Release all buffers, used by statement.
Bool_t SetLong64(Int_t npar, Long64_t value) final
Set parameter value as 64-bit integer.
virtual ~TPgSQLStatement()
Destructor.
Bool_t SetString(Int_t npar, const char *value, Int_t maxsize=256) final
Set parameter value as string.
Bool_t SetBinary(Int_t npar, void *mem, Long_t size, Long_t maxsize=0x1000) final
Set parameter value as binary data.
Bool_t Process() final
Process statement.
int * fParamFormats
length of column
char ** fFieldName
array of data for input
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 &) final
Return field value as time stamp.
Bool_t NextIteration() final
Increment iteration counter for statement, where parameter can be set.
void Close(Option_t *="") final
Close statement.
Basic string class.
Definition TString.h:139
The TTimeStamp encapsulates seconds and ns since EPOCH.
Definition TTimeStamp.h:45
const Int_t n
Definition legend1.C:16
PGresult * fRes