A handle for a SQLite3 statement.
More...
#include <sqlitepp/sqlitepp.h>
|
| ~Statement () |
| Deconstructs this object and finalizes the statement. More...
|
|
void | bind (const int index, const double value) |
| Binds the given double value to the column with the given index. More...
|
|
void | bind (const std::string &name, const double value) |
| Binds the given double value to the column with the given name. More...
|
|
void | bind (const int index, const int value) |
| Binds the given integer value to the column with the given index. More...
|
|
void | bind (const std::string &name, const int value) |
| Binds the given integer value to the column with the given name. More...
|
|
void | bind (const int index, const std::string &value) |
| Binds the given string value to the column with the given index. More...
|
|
void | bind (const std::string &name, const std::string &value) |
| Binds the given string value to the column with the given name. More...
|
|
void | close () |
| Closes this statement. More...
|
|
ResultSet | execute () |
| Executes this statement and returns the result (if any). More...
|
|
bool | reset () |
| Resets the statement. More...
|
|
bool | isOpen () const |
| Checks whether this object is open. More...
|
|
|
class | Database |
|
class | ResultSet |
|
A handle for a SQLite3 statement.
This class stores a reference to a prepared SQLite3 statement and provides methods to bind parameters to the query, execute it and read the results. If a database operation fails, a DatabaseError is thrown.
Use Database::prepare to obtain instances of this class.
◆ ~Statement()
sqlitepp::Statement::~Statement |
( |
| ) |
|
Deconstructs this object and finalizes the statement.
Errors that occur when the statement is finalized are ignored as they already occured during the last operation.
◆ bind() [1/6]
void sqlitepp::Statement::bind |
( |
const int |
index, |
|
|
const double |
value |
|
) |
| |
Binds the given double value to the column with the given index.
- Parameters
-
index | the index of the column to bind the value to |
value | the value to bind to that column |
- Exceptions
-
std::logic_error | if the statement is not open |
std::out_of_range | if the given index is out of range |
std::runtime_error | if there is not enough memory to bind the value |
DatabaseError | if an database error occured during the binding |
◆ bind() [2/6]
void sqlitepp::Statement::bind |
( |
const std::string & |
name, |
|
|
const double |
value |
|
) |
| |
Binds the given double value to the column with the given name.
- Parameters
-
index | the name of the column to bind the value to |
value | the value to bind to that column |
- Exceptions
-
std::logic_error | if the statement is not open |
std::invalid_argument | if there is no column witht the given name |
std::runtime_error | if there is not enough memory to bind the value |
DatabaseError | if an database error occured during the binding |
◆ bind() [3/6]
void sqlitepp::Statement::bind |
( |
const int |
index, |
|
|
const int |
value |
|
) |
| |
Binds the given integer value to the column with the given index.
- Parameters
-
index | the index of the column to bind the value to |
value | the value to bind to that column |
- Exceptions
-
std::logic_error | if the statement is not open |
std::out_of_range | if the given index is out of range |
std::runtime_error | if there is not enough memory to bind the value |
DatabaseError | if an database error occured during the binding |
◆ bind() [4/6]
void sqlitepp::Statement::bind |
( |
const std::string & |
name, |
|
|
const int |
value |
|
) |
| |
Binds the given integer value to the column with the given name.
- Parameters
-
index | the name of the column to bind the value to |
value | the value to bind to that column |
- Exceptions
-
std::logic_error | if the statement is not open |
std::invalid_argument | if there is no column witht the given name |
std::runtime_error | if there is not enough memory to bind the value |
DatabaseError | if an database error occured during the binding |
◆ bind() [5/6]
void sqlitepp::Statement::bind |
( |
const int |
index, |
|
|
const std::string & |
value |
|
) |
| |
Binds the given string value to the column with the given index.
- Parameters
-
index | the index of the column to bind the value to |
value | the value to bind to that column |
- Exceptions
-
std::logic_error | if the statement is not open |
std::out_of_range | if the given index is out of range |
std::runtime_error | if there is not enough memory to bind the value |
DatabaseError | if an database error occured during the binding |
◆ bind() [6/6]
void sqlitepp::Statement::bind |
( |
const std::string & |
name, |
|
|
const std::string & |
value |
|
) |
| |
Binds the given string value to the column with the given name.
- Parameters
-
index | the name of the column to bind the value to |
value | the value to bind to that column |
- Exceptions
-
std::logic_error | if the statement is not open |
std::invalid_argument | if there is no column witht the given name |
std::runtime_error | if there is not enough memory to bind the value |
DatabaseError | if an database error occured during the binding |
◆ close()
void sqlitepp::Statement::close |
( |
| ) |
|
Closes this statement.
Once you closed this statement, you may no longer access it. Any errors that occur during finalization are ignored as they already occurred during the last operation.
◆ execute()
Executes this statement and returns the result (if any).
- Returns
- the result returned from the query (empty if there was no result)
- Exceptions
-
std::logic_error | if the statement is not open |
DatabaseError | if a database error occurs during the query execution |
◆ reset()
bool sqlitepp::Statement::reset |
( |
| ) |
|
Resets the statement.
Resets the statement so that it can be re-executed. Bindings are not resetted.
- Returns
true
if the reset was successful; otherwise false
- Exceptions
-
std::logic_error | if the statement is not open |
The documentation for this class was generated from the following files: