41 unsigned long bindParamcount = sqlite3_bind_parameter_count(
fStmt->
fRes);
43 if (bindParamcount > 0) {
76 #define CheckStmt(method, res) \ 80 SetError(-1,"Statement handle is 0",method); \ 85 #define CheckErrNo(method, force, res) \ 87 int stmterrno = sqlite3_errcode(fStmt->fConn); \ 88 if ((stmterrno!=0) || force) { \ 89 const char* stmterrmsg = sqlite3_errmsg(fStmt->fConn); \ 90 if (stmterrno==0) { stmterrno = -1; stmterrmsg = "SQLite statement error"; } \ 91 SetError(stmterrno, stmterrmsg, method); \ 96 #define CheckGetField(method, res) \ 99 if (!IsResultSetMode()) { \ 100 SetError(-1,"Cannot get statement parameters",method); \ 103 if ((npar<0) || (npar>=fNumPars)) { \ 104 SetError(-1,Form("Invalid parameter number %d", npar),method); \ 112 if (res == SQLITE_RANGE) {
113 SetError(-1,
Form(
"SQLite parameter out of bounds, error: %d %s", res, sqlite3_errmsg(
fStmt->
fConn)), method);
116 if (res != SQLITE_OK) {
117 SetError(-1,
Form(
"SQLite error code during parameter binding, error: %d %s", res, sqlite3_errmsg(
fStmt->
fConn)), method);
131 if ((res != SQLITE_DONE) && (res != SQLITE_ROW)) {
132 SetError(-1,
Form(
"SQLite error code during statement-stepping: %d %s", res, sqlite3_errmsg(
fStmt->
fConn)),
"Process");
138 if (res == SQLITE_DONE) {
152 if (res == SQLITE_ROW) {
217 return sqlite3_column_name(
fStmt->
fRes, nfield);
251 SetError(-1,
"Cannot call for that statement",
"NextIteration");
275 return reinterpret_cast<const char *
>(sqlite3_column_text(
fStmt->
fRes, npar));
285 return (
long double) sqlite3_column_double(
fStmt->
fRes, npar);
295 return (sqlite3_column_type(
fStmt->
fRes, npar) == SQLITE_NULL);
365 return reinterpret_cast<const char *
>(sqlite3_column_text(
fStmt->
fRes, npar));
380 size_t sz = sqlite3_column_bytes(
fStmt->
fRes, npar);
382 delete [](
unsigned char*) mem;
383 mem = (
void*)
new unsigned char[sz];
387 memcpy(mem, sqlite3_column_blob(
fStmt->
fRes, npar), sz);
399 TString val =
reinterpret_cast<const char*
>(sqlite3_column_text(
fStmt->
fRes, npar));
415 TString val =
reinterpret_cast<const char*
>(sqlite3_column_text(
fStmt->
fRes, npar));
431 TString val =
reinterpret_cast<const char*
>(sqlite3_column_text(
fStmt->
fRes, npar));
451 TString val =
reinterpret_cast<const char*
>(sqlite3_column_text(
fStmt->
fRes, npar));
458 month =
d.GetMonth();
475 int res = sqlite3_bind_null(
fStmt->
fRes, npar + 1);
485 int res = sqlite3_bind_int(
fStmt->
fRes, npar + 1, value);
506 int res = sqlite3_bind_int64(
fStmt->
fRes, npar + 1, value);
516 int res = sqlite3_bind_int64(
fStmt->
fRes, npar + 1, value);
537 int res = sqlite3_bind_double(
fStmt->
fRes, npar + 1, value);
547 int res = sqlite3_bind_text(
fStmt->
fRes, npar + 1, value, maxsize, SQLITE_TRANSIENT);
560 SetError(-1,
"Passing negative value to size for BLOB to SQLite would cause undefined behaviour, refusing it!",
"SetBinary");
564 int res = sqlite3_bind_blob(
fStmt->
fRes, npar + 1, mem, (
size_t)size, SQLITE_TRANSIENT);
575 int res = sqlite3_bind_text(
fStmt->
fRes, npar + 1, (
char*)d.
AsSQLString(), -1, SQLITE_TRANSIENT);
587 int res = sqlite3_bind_text(
fStmt->
fRes, npar + 1, (
char*)d.
AsSQLString(), -1, SQLITE_TRANSIENT);
599 int res = sqlite3_bind_text(
fStmt->
fRes, npar + 1, (
char*)d.
AsSQLString(), -1, SQLITE_TRANSIENT);
611 TDatime d(year,month,day,hour,min,sec);
615 int res = sqlite3_bind_text(
fStmt->
fRes, npar + 1, value.
Data(), -1, SQLITE_TRANSIENT);
A zero length substring is legal.
Bool_t IsSetParsMode() const
Iteration count.
virtual Bool_t GetBinary(Int_t npar, void *&mem, Long_t &size)
Return field value as binary array.
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.
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.
#define CheckStmt(method, res)
void ClearError()
reset error fields
void SetError(Int_t code, const char *msg, const char *method=0)
set new values for error fields if method specified, displays error message
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_t fNumPars
1 - setting parameters, 2 - retrieving results
const char * Data() const
Int_t fWorkingMode
executed statement
Bool_t IsResultSetMode() const
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.
#define CheckGetField(method, res)
virtual Bool_t SetDate(Int_t npar, Int_t year, Int_t month, Int_t day)
Set parameter value as date.
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.
const char * AsSQLString() const
Return the date & time in SQL compatible string format, like: 1997-01-15 20:16:28.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
char * Form(const char *fmt,...)
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.
#define CheckErrNo(method, force, res)
virtual ~TSQLiteStatement()
Destructor.
virtual Int_t GetNumFields()
Return number of fields in result set.
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.
Ssiz_t Last(char c) const
Find last occurrence of a character c.
virtual Int_t GetNumParameters()
Return number of statement parameters.
unsigned long long ULong64_t
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.
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.
virtual Long64_t GetLong64(Int_t npar)
Get long64.
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.
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
TSQLiteStatement(SQLite3_Stmt_t *stmt, Bool_t errout=kTRUE)
Normal constructor.
virtual Bool_t StoreResult()
Store result of statement processing to access them via GetInt(), GetDouble() and so on methods...
const char * Data() const