libdballe
9.11
|
SQLite statement. More...
#include <sqlite.h>
Public Member Functions | |
SQLiteStatement (SQLiteConnection &conn, const std::string &query) | |
SQLiteStatement (const SQLiteStatement &)=delete | |
SQLiteStatement (const SQLiteStatement &&)=delete | |
SQLiteStatement & | operator= (const SQLiteStatement &)=delete |
template<typename... Args> | |
void | bind (const Args &...args) |
Bind all the arguments in a single invocation. More... | |
void | bind_null_val (int idx) |
void | bind_val (int idx, int val) |
void | bind_val (int idx, unsigned val) |
void | bind_val (int idx, unsigned short val) |
void | bind_val (int idx, const Datetime &val) |
void | bind_val (int idx, const char *val) |
void | bind_val (int idx, const std::string &val) |
void | bind_val (int idx, const std::vector< uint8_t > &val) |
void | execute () |
Run the query, ignoring all results. | |
void | execute (std::function< void()> on_row) |
Run the query, calling on_row for every row in the result. More... | |
void | execute_one (std::function< void()> on_row) |
Run the query, raising an error if there is more than one row in the result. | |
int | column_int (int col) |
Read the int value of a column in the result set (0-based) | |
sqlite3_int64 | column_int64 (int col) |
Read the int value of a column in the result set (0-based) | |
double | column_double (int col) |
Read the double value of a column in the result set (0-based) | |
const char * | column_string (int col) |
Read the string value of a column in the result set (0-based) | |
std::vector< uint8_t > | column_blob (int col) |
Read the string value of a column in the result set (0-based) | |
Datetime | column_datetime (int col) |
Read the string value of a column and parse it as a Datetime. | |
bool | column_isnull (int col) |
Check if a column has a NULL value (0-based) | |
void | wrap_sqlite3_reset () |
void | wrap_sqlite3_reset_nothrow () noexcept |
void | reset_and_throw (const std::string &errmsg) |
Get the current error message, reset the statement and throw error_sqlite. | |
operator sqlite3_stmt * () | |
Public Attributes | |
SQLiteConnection & | conn |
std::string | query |
sqlite3_stmt * | stm = nullptr |
SQLite statement.
|
inline |
Bind all the arguments in a single invocation.
Note that the parameter positions are used as bind column numbers, so calling this function twice will re-bind columns instead of adding new ones.
void dballe::sql::SQLiteStatement::execute | ( | std::function< void()> | on_row | ) |
Run the query, calling on_row for every row in the result.
At the end of the function, the statement is reset, even in case an exception is thrown.