Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TSQLiteStatement.h
Go to the documentation of this file.
1// @(#)root/sqlite:$Id$
2// Author: o.freyermuth <o.f@cern.ch>, 01/06/2013
3
4/*************************************************************************
5 * Copyright (C) 1995-2013, 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_TSQLiteStatement
13#define ROOT_TSQLiteStatement
14
15#include "TSQLStatement.h"
16
17class sqlite3;
18class sqlite3_stmt;
19
21 sqlite3 *fConn;
22 sqlite3_stmt *fRes;
23};
24
26
27private:
28 SQLite3_Stmt_t *fStmt{nullptr}; //! executed statement
29 Int_t fWorkingMode{0}; //! 1 - setting parameters, 2 - retrieving results
30 Int_t fNumPars{0}; //! Number of bindable / gettable parameters
31 Int_t fIterationCount{0}; //! Iteration count
32
33 Bool_t IsSetParsMode() const { return fWorkingMode==1; }
34 Bool_t IsResultSetMode() const { return fWorkingMode==2; }
35
36 Bool_t SetSQLParamType(Int_t npar, int sqltype, bool sig, int sqlsize = 0);
37
38 long double ConvertToNumeric(Int_t npar);
39 const char *ConvertToString(Int_t npar);
40
41 Bool_t CheckBindError(const char *method, int res);
42
43public:
45 virtual ~TSQLiteStatement();
46
47 void Close(Option_t * = "") final;
48
49 Int_t GetBufferLength() const final { return 1; }
50 Int_t GetNumParameters() final;
51
52 Bool_t SetNull(Int_t npar) final;
53 Bool_t SetInt(Int_t npar, Int_t value) final;
54 Bool_t SetUInt(Int_t npar, UInt_t value) final;
55 Bool_t SetLong(Int_t npar, Long_t value) final;
56 Bool_t SetLong64(Int_t npar, Long64_t value) final;
58 Bool_t SetDouble(Int_t npar, Double_t value) final;
59 Bool_t SetString(Int_t npar, const char* value, Int_t maxsize = 256) final;
60 Bool_t SetBinary(Int_t npar, void* mem, Long_t size, Long_t maxsize = 0x1000) final;
61 Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day) final;
62 Bool_t SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec) final;
63 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;
65 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;
66
67 Bool_t NextIteration() final;
68
69 Bool_t Process() final;
71
72 Bool_t StoreResult() final;
73 Int_t GetNumFields() final;
74 const char *GetFieldName(Int_t nfield) final;
75 Bool_t NextResultRow() final;
76
77 Bool_t IsNull(Int_t npar) final;
78 Int_t GetInt(Int_t npar) final;
79 UInt_t GetUInt(Int_t npar) final;
80 Long_t GetLong(Int_t npar) final;
81 Long64_t GetLong64(Int_t npar) final;
82 ULong64_t GetULong64(Int_t npar) final;
83 Double_t GetDouble(Int_t npar) final;
84 const char *GetString(Int_t npar) final;
85 Bool_t GetBinary(Int_t npar, void* &mem, Long_t& size) final;
86 Bool_t GetDate(Int_t npar, Int_t& year, Int_t& month, Int_t& day) final;
87 Bool_t GetTime(Int_t npar, Int_t& hour, Int_t& min, Int_t& sec) final;
88 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;
90 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;
91
92 ClassDefOverride(TSQLiteStatement, 0); // SQL statement class for SQLite DB
93};
94
95#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
Bool_t SetString(Int_t npar, const char *value, Int_t maxsize=256) final
Set parameter value as string.
Int_t GetBufferLength() const final
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.
Bool_t GetTime(Int_t npar, Int_t &hour, Int_t &min, Int_t &sec) final
Return field as time.
void Close(Option_t *="") final
Close statement.
Bool_t SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec) final
Set parameter value as time.
Bool_t SetBinary(Int_t npar, void *mem, Long_t size, Long_t maxsize=0x1000) final
Set parameter value as binary data.
Bool_t SetLong64(Int_t npar, Long64_t value) final
Set parameter value as 64-bit integer.
UInt_t GetUInt(Int_t npar) final
Get unsigned 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 &) final
Return field as timestamp.
Bool_t IsNull(Int_t npar) final
Checks if field value is null.
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.
virtual ~TSQLiteStatement()
Destructor.
SQLite3_Stmt_t * fStmt
Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day) final
Set parameter value as date.
Int_t fIterationCount
Number of bindable / gettable parameters.
Long_t GetLong(Int_t npar) final
Get long.
Int_t GetInt(Int_t npar) final
Get integer.
Bool_t GetBinary(Int_t npar, void *&mem, Long_t &size) final
Return field value as binary array.
Bool_t CheckBindError(const char *method, int res)
ULong64_t GetULong64(Int_t npar) final
Return field value as unsigned 64-bit integer.
Bool_t SetLong(Int_t npar, Long_t value) final
Set parameter value as long.
const char * GetString(Int_t npar) final
Return field value as string.
Bool_t SetNull(Int_t npar) final
Set NULL as parameter value.
const char * ConvertToString(Int_t npar)
Convert field value to string.
Int_t fWorkingMode
executed statement
Bool_t SetInt(Int_t npar, Int_t value) final
Set parameter value as integer.
Bool_t IsSetParsMode() const
Iteration count.
Bool_t GetDate(Int_t npar, Int_t &year, Int_t &month, Int_t &day) final
Return field value as date.
Bool_t SetSQLParamType(Int_t npar, int sqltype, bool sig, int sqlsize=0)
Int_t fNumPars
1 - setting parameters, 2 - retrieving results
Long64_t GetLong64(Int_t npar) final
Get long64.
Bool_t NextIteration() final
Increment iteration counter for statement, where parameter can be set.
Bool_t IsResultSetMode() const
Bool_t StoreResult() final
Store result of statement processing to access them via GetInt(), GetDouble() and so on methods.
Bool_t SetDouble(Int_t npar, Double_t value) final
Set parameter value as double value.
Int_t GetNumAffectedRows() final
Return number of affected rows after statement is processed.
Bool_t Process() final
Process statement.
Bool_t SetULong64(Int_t npar, ULong64_t value) final
Set parameter value as unsigned 64-bit integer.
Bool_t SetUInt(Int_t npar, UInt_t value) final
Set parameter value as unsigned integer.
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.
Bool_t NextResultRow() final
Shift cursor to next row in result set.
const char * GetFieldName(Int_t nfield) final
Returns field name in result set.
Int_t GetNumFields() final
Return number of fields in result set.
Double_t GetDouble(Int_t npar) final
Return field value as double.
Int_t GetNumParameters() final
Return number of statement parameters.
long double ConvertToNumeric(Int_t npar)
Convert field to numeric.
sqlite3_stmt * fRes