ROSE
0.11.54.0
|
A database operation.
A Statement represents a single SQL statement to be executed within a transaction. Statements may contain value placeholders indicated by '?' characters which are numbered consecutively starting at zero. Actual values must be bound to all the placeholders before the statement can be executed. A single statement may be executed multiple times and may have different actual values bound to its place holders each time.
When a statement is executed within a transaction, it may return zero or more result rows each containing one or more columns of values. The results are returned via STL-like iterators. Re-executing a statement will cause its previous iterators to become invalid and throw exceptions if they are used.
Definition at line 359 of file SqlDatabase.h.
#include <SqlDatabase.h>
Classes | |
class | iterator |
Iterates over the result rows. More... | |
Public Member Functions | |
iterator | begin () |
Execute this statement. More... | |
iterator | end () |
Returns an end iterator. More... | |
void | execute () |
Execute a statement and ignore its result rows if it has any. More... | |
int | execute_int () |
Execute a statement that returns a single integer. More... | |
double | execute_double () |
Execute a statement that returns a single double. More... | |
std::string | execute_string () |
Execute a statement that returns a single std::string. More... | |
std::vector< uint8_t > | execute_blob () |
Execute a statement that returns a single blob. More... | |
Driver | driver () const |
Returns the low-level driver name for this statement. More... | |
TransactionPtr | transaction () const |
Returns the transaction for this statement. More... | |
void | print (std::ostream &) const |
Print some basic info about this statement. More... | |
StatementPtr | bind (size_t idx, int32_t val) |
Bind value to a '?' placeholder in the SQL statement. More... | |
StatementPtr | bind (size_t idx, int64_t val) |
Bind value to a '?' placeholder in the SQL statement. More... | |
StatementPtr | bind (size_t idx, uint32_t val) |
Bind value to a '?' placeholder in the SQL statement. More... | |
StatementPtr | bind (size_t idx, uint64_t val) |
Bind value to a '?' placeholder in the SQL statement. More... | |
StatementPtr | bind (size_t idx, double val) |
Bind value to a '?' placeholder in the SQL statement. More... | |
StatementPtr | bind (size_t idx, const std::string &val) |
Bind value to a '?' placeholder in the SQL statement. More... | |
StatementPtr | bind (size_t idx, const std::vector< uint8_t > &val) |
Bind value to a '?' placeholder in the SQL statement. More... | |
StatementPtr | bind_null (size_t idx) |
Bind value to a '?' placeholder in the SQL statement. More... | |
void | set_debug (FILE *f) |
Debugging property. More... | |
FILE * | get_debug () const |
Debugging property. More... | |
Static Public Member Functions | |
static StatementPtr | create (const TransactionPtr &tranx, const std::string &sql) |
Create a new statement. More... | |
Protected Member Functions | |
Statement (const TransactionPtr &tranx, const std::string &sql) | |
|
inlinestatic |
Create a new statement.
Statements can be created either by this class method or by calling Transaction::statement().
Definition at line 364 of file SqlDatabase.h.
StatementPtr SqlDatabase::Statement::bind | ( | size_t | idx, |
int32_t | val | ||
) |
Bind value to a '?' placeholder in the SQL statement.
Placeholders are counted from zero based on their position in the text of the SQL command. Only after all placeholders are bound to values can this statement be executed. The bind() method returns the statement pointer so that bind calls can be chained together.
StatementPtr SqlDatabase::Statement::bind | ( | size_t | idx, |
int64_t | val | ||
) |
Bind value to a '?' placeholder in the SQL statement.
Placeholders are counted from zero based on their position in the text of the SQL command. Only after all placeholders are bound to values can this statement be executed. The bind() method returns the statement pointer so that bind calls can be chained together.
StatementPtr SqlDatabase::Statement::bind | ( | size_t | idx, |
uint32_t | val | ||
) |
Bind value to a '?' placeholder in the SQL statement.
Placeholders are counted from zero based on their position in the text of the SQL command. Only after all placeholders are bound to values can this statement be executed. The bind() method returns the statement pointer so that bind calls can be chained together.
StatementPtr SqlDatabase::Statement::bind | ( | size_t | idx, |
uint64_t | val | ||
) |
Bind value to a '?' placeholder in the SQL statement.
Placeholders are counted from zero based on their position in the text of the SQL command. Only after all placeholders are bound to values can this statement be executed. The bind() method returns the statement pointer so that bind calls can be chained together.
StatementPtr SqlDatabase::Statement::bind | ( | size_t | idx, |
double | val | ||
) |
Bind value to a '?' placeholder in the SQL statement.
Placeholders are counted from zero based on their position in the text of the SQL command. Only after all placeholders are bound to values can this statement be executed. The bind() method returns the statement pointer so that bind calls can be chained together.
StatementPtr SqlDatabase::Statement::bind | ( | size_t | idx, |
const std::string & | val | ||
) |
Bind value to a '?' placeholder in the SQL statement.
Placeholders are counted from zero based on their position in the text of the SQL command. Only after all placeholders are bound to values can this statement be executed. The bind() method returns the statement pointer so that bind calls can be chained together.
StatementPtr SqlDatabase::Statement::bind | ( | size_t | idx, |
const std::vector< uint8_t > & | val | ||
) |
Bind value to a '?' placeholder in the SQL statement.
Placeholders are counted from zero based on their position in the text of the SQL command. Only after all placeholders are bound to values can this statement be executed. The bind() method returns the statement pointer so that bind calls can be chained together.
StatementPtr SqlDatabase::Statement::bind_null | ( | size_t | idx | ) |
Bind value to a '?' placeholder in the SQL statement.
Placeholders are counted from zero based on their position in the text of the SQL command. Only after all placeholders are bound to values can this statement be executed. The bind() method returns the statement pointer so that bind calls can be chained together.
iterator SqlDatabase::Statement::begin | ( | ) |
Execute this statement.
Returns the iterator pointing to the first row of the result.
|
inline |
Returns an end iterator.
End iterators are just default-constructed iterators–an iterator from any statement can be compared to an end iterator from any statement.
Definition at line 416 of file SqlDatabase.h.
void SqlDatabase::Statement::execute | ( | ) |
Execute a statement and ignore its result rows if it has any.
int SqlDatabase::Statement::execute_int | ( | ) |
Execute a statement that returns a single integer.
double SqlDatabase::Statement::execute_double | ( | ) |
Execute a statement that returns a single double.
std::string SqlDatabase::Statement::execute_string | ( | ) |
Execute a statement that returns a single std::string.
std::vector<uint8_t> SqlDatabase::Statement::execute_blob | ( | ) |
Execute a statement that returns a single blob.
Driver SqlDatabase::Statement::driver | ( | ) | const |
Returns the low-level driver name for this statement.
TransactionPtr SqlDatabase::Statement::transaction | ( | ) | const |
Returns the transaction for this statement.
void SqlDatabase::Statement::set_debug | ( | FILE * | f | ) |
Debugging property.
If non-null, then debugging information is sent to that file. Transactions inherit the debugging property of their connection, and statements inherit the debugging property of their transaction (which is overridden by this method).
FILE* SqlDatabase::Statement::get_debug | ( | ) | const |
Debugging property.
If non-null, then debugging information is sent to that file. Transactions inherit the debugging property of their connection, and statements inherit the debugging property of their transaction (which is overridden by this method).
void SqlDatabase::Statement::print | ( | std::ostream & | ) | const |
Print some basic info about this statement.