40 unsigned long bindParamcount = sqlite3_bind_parameter_count(fStmt->fRes);
42 if (bindParamcount > 0) {
44 fNumPars = bindParamcount;
47 fNumPars = sqlite3_column_count(fStmt->fRes);
75 #define CheckStmt(method, res) \ 79 SetError(-1,"Statement handle is 0",method); \ 84 #define CheckErrNo(method, force, res) \ 86 int stmterrno = sqlite3_errcode(fStmt->fConn); \ 87 if ((stmterrno!=0) || force) { \ 88 const char* stmterrmsg = sqlite3_errmsg(fStmt->fConn); \ 89 if (stmterrno==0) { stmterrno = -1; stmterrmsg = "SQLite statement error"; } \ 90 SetError(stmterrno, stmterrmsg, method); \ 95 #define CheckGetField(method, res) \ 98 if (!IsResultSetMode()) { \ 99 SetError(-1,"Cannot get statement parameters",method); \ 102 if ((npar<0) || (npar>=fNumPars)) { \ 103 SetError(-1,Form("Invalid parameter number %d", npar),method); \ 111 if (res == SQLITE_RANGE) {
112 SetError(-1,
Form(
"SQLite parameter out of bounds, error: %d %s", res, sqlite3_errmsg(
fStmt->
fConn)), method);
115 if (res != SQLITE_OK) {
116 SetError(-1,
Form(
"SQLite error code during parameter binding, error: %d %s", res, sqlite3_errmsg(
fStmt->
fConn)), method);
130 if ((res != SQLITE_DONE) && (res != SQLITE_ROW)) {
131 SetError(-1,
Form(
"SQLite error code during statement-stepping: %d %s", res, sqlite3_errmsg(
fStmt->
fConn)),
"Process");
137 if (res == SQLITE_DONE) {
151 if (res == SQLITE_ROW) {
216 return sqlite3_column_name(
fStmt->
fRes, nfield);
250 SetError(-1,
"Cannot call for that statement",
"NextIteration");
274 return reinterpret_cast<const char *
>(sqlite3_column_text(
fStmt->
fRes, npar));
284 return (
long double) sqlite3_column_double(
fStmt->
fRes, npar);
294 return (sqlite3_column_type(
fStmt->
fRes, npar) == SQLITE_NULL);
364 return reinterpret_cast<const char *
>(sqlite3_column_text(
fStmt->
fRes, npar));
379 size_t sz = sqlite3_column_bytes(
fStmt->
fRes, npar);
381 delete [](
unsigned char*) mem;
382 mem = (
void*)
new unsigned char[sz];
386 memcpy(mem, sqlite3_column_blob(
fStmt->
fRes, npar), sz);
398 TString val =
reinterpret_cast<const char*
>(sqlite3_column_text(
fStmt->
fRes, npar));
414 TString val =
reinterpret_cast<const char*
>(sqlite3_column_text(
fStmt->
fRes, npar));
430 TString val =
reinterpret_cast<const char*
>(sqlite3_column_text(
fStmt->
fRes, npar));
450 TString val =
reinterpret_cast<const char*
>(sqlite3_column_text(
fStmt->
fRes, npar));
457 month = d.GetMonth();
474 int res = sqlite3_bind_null(
fStmt->
fRes, npar + 1);
484 int res = sqlite3_bind_int(
fStmt->
fRes, npar + 1, value);
505 int res = sqlite3_bind_int64(
fStmt->
fRes, npar + 1, value);
515 int res = sqlite3_bind_int64(
fStmt->
fRes, npar + 1, value);
536 int res = sqlite3_bind_double(
fStmt->
fRes, npar + 1, value);
546 int res = sqlite3_bind_text(
fStmt->
fRes, npar + 1, value, maxsize, SQLITE_TRANSIENT);
559 SetError(-1,
"Passing negative value to size for BLOB to SQLite would cause undefined behaviour, refusing it!",
"SetBinary");
563 int res = sqlite3_bind_blob(
fStmt->
fRes, npar + 1, mem, (
size_t)size, SQLITE_TRANSIENT);
574 int res = sqlite3_bind_text(
fStmt->
fRes, npar + 1, (
char*)d.
AsSQLString(), -1, SQLITE_TRANSIENT);
586 int res = sqlite3_bind_text(
fStmt->
fRes, npar + 1, (
char*)d.
AsSQLString(), -1, SQLITE_TRANSIENT);
598 int res = sqlite3_bind_text(
fStmt->
fRes, npar + 1, (
char*)d.
AsSQLString(), -1, SQLITE_TRANSIENT);
610 TDatime d(year,month,day,hour,min,sec);
614 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...
virtual Bool_t StoreResult()
Store result of statement processing to access them via GetInt(), GetDouble() and so on methods...
const char * Data() const