43 unsigned long bindParamcount = sqlite3_bind_parameter_count(
fStmt->
fRes);
45 if (bindParamcount > 0) {
78#define CheckStmt(method, res) \
82 SetError(-1,"Statement handle is 0",method); \
87#define CheckErrNo(method, force, res) \
89 int stmterrno = sqlite3_errcode(fStmt->fConn); \
90 if ((stmterrno!=0) || force) { \
91 const char* stmterrmsg = sqlite3_errmsg(fStmt->fConn); \
92 if (stmterrno==0) { stmterrno = -1; stmterrmsg = "SQLite statement error"; } \
93 SetError(stmterrno, stmterrmsg, method); \
98#define CheckGetField(method, res) \
101 if (!IsResultSetMode()) { \
102 SetError(-1,"Cannot get statement parameters",method); \
105 if ((npar<0) || (npar>=fNumPars)) { \
106 SetError(-1,Form("Invalid parameter number %d", npar),method); \
114 if (res == SQLITE_RANGE) {
115 SetError(-1,
Form(
"SQLite parameter out of bounds, error: %d %s", res, sqlite3_errmsg(
fStmt->
fConn)), method);
118 if (res != SQLITE_OK) {
119 SetError(-1,
Form(
"SQLite error code during parameter binding, error: %d %s", res, sqlite3_errmsg(
fStmt->
fConn)), method);
133 if ((res != SQLITE_DONE) && (res != SQLITE_ROW)) {
134 SetError(-1,
Form(
"SQLite error code during statement-stepping: %d %s", res, sqlite3_errmsg(
fStmt->
fConn)),
"Process");
140 if (res == SQLITE_DONE) {
154 if (res == SQLITE_ROW) {
218 return sqlite3_column_name(
fStmt->
fRes, nfield);
252 SetError(-1,
"Cannot call for that statement",
"NextIteration");
276 return reinterpret_cast<const char *
>(sqlite3_column_text(
fStmt->
fRes, npar));
286 return (
long double) sqlite3_column_double(
fStmt->
fRes, npar);
296 return (sqlite3_column_type(
fStmt->
fRes, npar) == SQLITE_NULL);
366 return reinterpret_cast<const char *
>(sqlite3_column_text(
fStmt->
fRes, npar));
381 size_t sz = sqlite3_column_bytes(
fStmt->
fRes, npar);
383 delete [](
unsigned char*) mem;
384 mem = (
void*)
new unsigned char[sz];
388 memcpy(mem, sqlite3_column_blob(
fStmt->
fRes, npar), sz);
400 TString val =
reinterpret_cast<const char*
>(sqlite3_column_text(
fStmt->
fRes, npar));
403 month =
d.GetMonth();
416 TString val =
reinterpret_cast<const char*
>(sqlite3_column_text(
fStmt->
fRes, npar));
432 TString val =
reinterpret_cast<const char*
>(sqlite3_column_text(
fStmt->
fRes, npar));
435 month =
d.GetMonth();
452 TString val =
reinterpret_cast<const char*
>(sqlite3_column_text(
fStmt->
fRes, npar));
459 month =
d.GetMonth();
476 int res = sqlite3_bind_null(
fStmt->
fRes, npar + 1);
548 int res = sqlite3_bind_text(
fStmt->
fRes, npar + 1,
value, maxsize, SQLITE_TRANSIENT);
561 SetError(-1,
"Passing negative value to size for BLOB to SQLite would cause undefined behaviour, refusing it!",
"SetBinary");
565 int res = sqlite3_bind_blob(
fStmt->
fRes, npar + 1, mem, (
size_t)
size, SQLITE_TRANSIENT);
576 int res = sqlite3_bind_text(
fStmt->
fRes, npar + 1, (
char*)
d.AsSQLString(), -1, SQLITE_TRANSIENT);
588 int res = sqlite3_bind_text(
fStmt->
fRes, npar + 1, (
char*)
d.AsSQLString(), -1, SQLITE_TRANSIENT);
600 int res = sqlite3_bind_text(
fStmt->
fRes, npar + 1, (
char*)
d.AsSQLString(), -1, SQLITE_TRANSIENT);
612 TDatime d(year,month,day,hour,min,sec);
614 value.Form(
"%s.%03d", (
char*)
d.AsSQLString(), frac);
616 int res = sqlite3_bind_text(
fStmt->
fRes, npar + 1,
value.Data(), -1, SQLITE_TRANSIENT);
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
unsigned long long ULong64_t
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
#define CheckErrNo(method, force, res)
#define CheckGetField(method, res)
#define CheckStmt(method, res)
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
void SetError(Int_t code, const char *msg, const char *method=nullptr)
set new values for error fields if method specified, displays error message
void ClearError()
reset error fields
Bool_t SetString(Int_t npar, const char *value, Int_t maxsize=256) final
Set parameter value as string.
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.
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.
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.
TSQLiteStatement(SQLite3_Stmt_t *stmt, Bool_t errout=kTRUE)
Normal constructor.
long double ConvertToNumeric(Int_t npar)
Convert field to numeric.
const char * Data() const
Ssiz_t Last(char c) const
Find last occurrence of a character c.
A zero length substring is legal.
const char * Data() const