Logo ROOT   6.10/09
Reference Guide
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 
17 #include <sqlite3.h>
18 
20  sqlite3 *fConn;
21  sqlite3_stmt *fRes;
22 };
23 
24 
26 
27 private:
28  SQLite3_Stmt_t *fStmt; //! executed statement
29  Int_t fWorkingMode; //! 1 - setting parameters, 2 - retrieving results
30  Int_t fNumPars; //! Number of bindable / gettable parameters
31  Int_t fIterationCount; //! 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 
43 public:
45  virtual ~TSQLiteStatement();
46 
47  virtual void Close(Option_t * = "");
48 
49  virtual Int_t GetBufferLength() const { return 1; }
50  virtual Int_t GetNumParameters();
51 
52  virtual Bool_t SetNull(Int_t npar);
53  virtual Bool_t SetInt(Int_t npar, Int_t value);
54  virtual Bool_t SetUInt(Int_t npar, UInt_t value);
55  virtual Bool_t SetLong(Int_t npar, Long_t value);
56  virtual Bool_t SetLong64(Int_t npar, Long64_t value);
57  virtual Bool_t SetULong64(Int_t npar, ULong64_t value);
58  virtual Bool_t SetDouble(Int_t npar, Double_t value);
59  virtual Bool_t SetString(Int_t npar, const char* value, Int_t maxsize = 256);
60  virtual Bool_t SetBinary(Int_t npar, void* mem, Long_t size, Long_t maxsize = 0x1000);
61  virtual Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day);
62  virtual Bool_t SetTime(Int_t npar, Int_t hour, Int_t min, Int_t sec);
63  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);
64  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);
65 
66  virtual Bool_t NextIteration();
67 
68  virtual Bool_t Process();
69  virtual Int_t GetNumAffectedRows();
70 
71  virtual Bool_t StoreResult();
72  virtual Int_t GetNumFields();
73  virtual const char *GetFieldName(Int_t nfield);
74  virtual Bool_t NextResultRow();
75 
76  virtual Bool_t IsNull(Int_t npar);
77  virtual Int_t GetInt(Int_t npar);
78  virtual UInt_t GetUInt(Int_t npar);
79  virtual Long_t GetLong(Int_t npar);
80  virtual Long64_t GetLong64(Int_t npar);
81  virtual ULong64_t GetULong64(Int_t npar);
82  virtual Double_t GetDouble(Int_t npar);
83  virtual const char *GetString(Int_t npar);
84  virtual Bool_t GetBinary(Int_t npar, void* &mem, Long_t& size);
85  virtual Bool_t GetDate(Int_t npar, Int_t& year, Int_t& month, Int_t& day);
86  virtual Bool_t GetTime(Int_t npar, Int_t& hour, Int_t& min, Int_t& sec);
87  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);
88  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&);
89 
90  ClassDef(TSQLiteStatement, 0); // SQL statement class for SQLite DB
91 };
92 
93 #endif
Bool_t IsSetParsMode() const
Iteration count.
SQLite3_Stmt_t * fStmt
long long Long64_t
Definition: RtypesCore.h:69
const char Option_t
Definition: RtypesCore.h:62
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
Bool_t IsResultSetMode() const
#define ClassDef(name, id)
Definition: Rtypes.h:297
const int maxsize
Int_t fIterationCount
Number of bindable / gettable parameters.
unsigned int UInt_t
Definition: RtypesCore.h:42
long Long_t
Definition: RtypesCore.h:50
double Double_t
Definition: RtypesCore.h:55
unsigned long long ULong64_t
Definition: RtypesCore.h:70
sqlite3_stmt * fRes
virtual Int_t GetBufferLength() const
const Bool_t kTRUE
Definition: RtypesCore.h:91