ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #ifndef ROOT_TSQLStatement
16 #include "TSQLStatement.h"
17 #endif
18 
19 #include <sqlite3.h>
20 
22  sqlite3 *fConn;
23  sqlite3_stmt *fRes;
24 };
25 
26 
28 
29 private:
30  SQLite3_Stmt_t *fStmt; //! executed statement
31  Int_t fWorkingMode; //! 1 - setting parameters, 2 - retrieving results
32  Int_t fNumPars; //! Number of bindable / gettable parameters
33  Int_t fIterationCount; //! Iteration count
34 
35  Bool_t IsSetParsMode() const { return fWorkingMode==1; }
36  Bool_t IsResultSetMode() const { return fWorkingMode==2; }
37 
38  Bool_t SetSQLParamType(Int_t npar, int sqltype, bool sig, int sqlsize = 0);
39 
40  long double ConvertToNumeric(Int_t npar);
41  const char *ConvertToString(Int_t npar);
42 
43  Bool_t CheckBindError(const char *method, int res);
44 
45 public:
47  virtual ~TSQLiteStatement();
48 
49  virtual void Close(Option_t * = "");
50 
51  virtual Int_t GetBufferLength() const { return 1; }
52  virtual Int_t GetNumParameters();
53 
54  virtual Bool_t SetNull(Int_t npar);
55  virtual Bool_t SetInt(Int_t npar, Int_t value);
56  virtual Bool_t SetUInt(Int_t npar, UInt_t value);
57  virtual Bool_t SetLong(Int_t npar, Long_t value);
58  virtual Bool_t SetLong64(Int_t npar, Long64_t value);
59  virtual Bool_t SetULong64(Int_t npar, ULong64_t value);
60  virtual Bool_t SetDouble(Int_t npar, Double_t value);
61  virtual Bool_t SetString(Int_t npar, const char* value, Int_t maxsize = 256);
62  virtual Bool_t SetBinary(Int_t npar, void* mem, Long_t size, Long_t maxsize = 0x1000);
63  virtual Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day);
64  virtual Bool_t SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec);
65  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);
66  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);
67 
68  virtual Bool_t NextIteration();
69 
70  virtual Bool_t Process();
71  virtual Int_t GetNumAffectedRows();
72 
73  virtual Bool_t StoreResult();
74  virtual Int_t GetNumFields();
75  virtual const char *GetFieldName(Int_t nfield);
76  virtual Bool_t NextResultRow();
77 
78  virtual Bool_t IsNull(Int_t npar);
79  virtual Int_t GetInt(Int_t npar);
80  virtual UInt_t GetUInt(Int_t npar);
81  virtual Long_t GetLong(Int_t npar);
82  virtual Long64_t GetLong64(Int_t npar);
83  virtual ULong64_t GetULong64(Int_t npar);
84  virtual Double_t GetDouble(Int_t npar);
85  virtual const char *GetString(Int_t npar);
86  virtual Bool_t GetBinary(Int_t npar, void* &mem, Long_t& size);
87  virtual Bool_t GetDate(Int_t npar, Int_t& year, Int_t& month, Int_t& day);
88  virtual Bool_t GetTime(Int_t npar, Int_t& hour, Int_t& min, Int_t& sec);
89  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);
90  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&);
91 
92  ClassDef(TSQLiteStatement, 0); // SQL statement class for SQLite DB
93 };
94 
95 #endif
virtual Bool_t GetBinary(Int_t npar, void *&mem, Long_t &size)
Return field value as binary array.
SQLite3_Stmt_t * fStmt
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
virtual Bool_t IsNull(Int_t npar)
Checks if field value is null.
virtual Bool_t SetUInt(Int_t npar, UInt_t value)
Set parameter value as unsigned integer.
long long Long64_t
Definition: RtypesCore.h:69
Bool_t IsSetParsMode() const
Iteration count.
virtual const char * GetString(Int_t npar)
Return field value as string.
virtual Bool_t SetLong64(Int_t npar, Long64_t value)
Set parameter value as 64-bit integer.
const char Option_t
Definition: RtypesCore.h:62
virtual Int_t GetBufferLength() const
virtual Bool_t Process()
Process statement.
virtual Bool_t SetLong(Int_t npar, Long_t value)
Set parameter value as long.
virtual Int_t GetInt(Int_t npar)
Get integer.
virtual Double_t GetDouble(Int_t npar)
Return field value as double.
int Int_t
Definition: RtypesCore.h:41
Int_t fNumPars
1 - setting parameters, 2 - retrieving results
bool Bool_t
Definition: RtypesCore.h:59
Int_t fWorkingMode
executed statement
virtual Long_t GetLong(Int_t npar)
Get long.
virtual Bool_t SetULong64(Int_t npar, ULong64_t value)
Set parameter value as unsigned 64-bit integer.
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 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.
const int maxsize
virtual Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day)
Set parameter value as date.
ClassDef(TSQLiteStatement, 0)
Int_t fIterationCount
Number of bindable / gettable parameters.
virtual Bool_t SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec)
Set parameter value as time.
virtual Bool_t SetString(Int_t npar, const char *value, Int_t maxsize=256)
Set parameter value as string.
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual Bool_t NextIteration()
Increment iteration counter for statement, where parameter can be set.
const char * ConvertToString(Int_t npar)
Convert field value to string.
Bool_t CheckBindError(const char *method, int res)
virtual UInt_t GetUInt(Int_t npar)
Get unsigned integer.
virtual const char * GetFieldName(Int_t nfield)
Returns field name in result set.
virtual Bool_t SetNull(Int_t npar)
Set NULL as parameter value.
virtual ~TSQLiteStatement()
Destructor.
virtual Int_t GetNumFields()
Return number of fields in result set.
long Long_t
Definition: RtypesCore.h:50
virtual Bool_t NextResultRow()
Shift cursor to next row in result set.
virtual Bool_t SetInt(Int_t npar, Int_t value)
Set parameter value as integer.
double Double_t
Definition: RtypesCore.h:55
virtual Int_t GetNumParameters()
Return number of statement parameters.
unsigned long long ULong64_t
Definition: RtypesCore.h:70
virtual Bool_t SetDouble(Int_t npar, Double_t value)
Set parameter value as double value.
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 parameter value as timestamp.
virtual Int_t GetNumAffectedRows()
Return number of affected rows after statement is processed.
sqlite3_stmt * fRes
long double ConvertToNumeric(Int_t npar)
Convert field to numeric.
virtual Bool_t GetTime(Int_t npar, Int_t &hour, Int_t &min, Int_t &sec)
Return field as time.
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 &)
Return field as timestamp.
virtual void Close(Option_t *="")
Close statement.
virtual Bool_t GetDate(Int_t npar, Int_t &year, Int_t &month, Int_t &day)
Return field value as date.
Bool_t IsResultSetMode() const
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual Long64_t GetLong64(Int_t npar)
Get long64.
float value
Definition: math.cpp:443
Bool_t SetSQLParamType(Int_t npar, int sqltype, bool sig, int sqlsize=0)
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 parameter value as date & time.
virtual ULong64_t GetULong64(Int_t npar)
Return field value as unsigned 64-bit integer.
TSQLiteStatement(SQLite3_Stmt_t *stmt, Bool_t errout=kTRUE)
virtual Bool_t StoreResult()
Store result of statement processing to access them via GetInt(), GetDouble() and so on methods...