libcommonc++
0.7
|
An SQL prepared statement that can be efficiently executed multiple times. More...
#include <SQLQuery.h++>
Public Member Functions | |
~SQLQuery () | |
Destructor. More... | |
void | reset () |
Reset the query so that it can be executed again. More... | |
String | toSQL () |
Get the SQL statement represented by this query. More... | |
void | bind (uint_t index) |
Bind a null value to the designated parameter in the query. More... | |
void | bind (const String &name) |
Bind a null value to the designated parameter in the query. More... | |
void | bind (uint_t index, int value) |
Bind an integer value to the designated parameter in the query. More... | |
void | bind (const String &name, int value) |
Bind an integer value to the designated parameter in the query. More... | |
void | bind (uint_t index, const int64_t &value) |
Bind a 64-bit integer value to the designated parameter in the query. More... | |
void | bind (const String &name, const int64_t &value) |
Bind a 64-bit integer value to the designated parameter in the statement. More... | |
void | bind (uint_t index, const double &value) |
Bind a double-precision floating point value to the designated parameter in the query. More... | |
void | bind (const String &name, const double &value) |
Bind a double-precision floating point value to the designated parameter in the query. More... | |
void | bind (uint_t index, const String &value) |
Bind a String value to the designated parameter in the query. More... | |
void | bind (const String &name, const String &value) |
Bind a String value to the designated parameter in the query. More... | |
void | bind (uint_t index, const char *value) |
Bind a string value to the designated parameter in the query. More... | |
void | bind (const String &name, const char *value) |
Bind a string value to the designated parameter in the query. More... | |
void | bind (uint_t index, const Blob &value) |
Bind a Blob value to the designated parameter in the query. More... | |
void | bind (const String &name, const Blob &value) |
Bind a Blob value to the designated parameter in the query. More... | |
void | clear () |
Clear the parameter value bindings for the query. More... | |
uint_t | getParameterCount () |
Get the number of parameters in the query. More... | |
void | execute () |
Execute the query. More... | |
bool | next () |
Advance to the next result. More... | |
uint_t | getColumnCount () |
Get the number of columns in the results. More... | |
Variant | getColumnValue (uint_t column) |
Get the value for the given column in the current row of the results. More... | |
String | getColumnName (uint_t column) |
Get the unaliased name for the given column in the results. More... | |
String | getAliasedColumnName (uint_t column) |
Get the aliased name for the given column in the results. More... | |
String | getTableName (uint_t column) |
Get the name of the table for the given column in the results. More... | |
int | getInt (uint_t column) |
Get the value for the given column in the current row of the results, as an integer. More... | |
int64_t | getInt64 (uint_t column) |
Get the value for the given column in the current row of the results, as a 64-bit integer. More... | |
double | getDouble (uint_t column) |
Get the value for the given column in the current row of the results, as a double-precision floating point value. More... | |
String | getString (uint_t column) |
Get the value for the given column in the current row of the results, as a String. More... | |
Blob | getBlob (uint_t column) |
Get the value for the given column in the current row of the results, as a Blob. More... | |
Friends | |
class | SQLDatabase |
An SQL prepared statement that can be efficiently executed multiple times.
New values may be bound to the statement's parameters (if any) using the various bind*()
methods. Once the statement is executed, the next()
method is used to iterate over the result set, and the various get*()
methods are used to extract the values from each row of the result set.
A SQLQuery must be reset via a call to reset()
before it can be executed again.
An SQLValueBinder may optionally be used to express the parameter value binding and result value extraction in a concise way.
SQLQuery objects should be destroyed before the SQLDatabase that they are associated with is closed.
~SQLQuery | ( | ) |
Destructor.
void bind | ( | uint_t | index | ) |
Bind a null value to the designated parameter in the query.
index | The index of the parameter (where 1 refers to the first parameter). |
SQLException | If a database error occurs. |
void bind | ( | const String & | name | ) |
Bind a null value to the designated parameter in the query.
name | The name of the parameter. |
SQLException | If a database error occurs. |
void bind | ( | uint_t | index, |
int | value | ||
) |
Bind an integer value to the designated parameter in the query.
index | The index of the parameter (where 1 refers to the first parameter). |
value | The value to bind. |
SQLException | If a database error occurs. |
void bind | ( | const String & | name, |
int | value | ||
) |
Bind an integer value to the designated parameter in the query.
name | The name of the parameter. |
value | The value to bind. |
SQLException | If a database error occurs. |
void bind | ( | uint_t | index, |
const int64_t & | value | ||
) |
Bind a 64-bit integer value to the designated parameter in the query.
index | The index of the parameter (where 1 refers to the first parameter). |
value | The value to bind. |
SQLException | If a database error occurs. |
void bind | ( | const String & | name, |
const int64_t & | value | ||
) |
Bind a 64-bit integer value to the designated parameter in the statement.
name | The name of the parameter. |
value | The value to bind. |
SQLException | If a database error occurs. |
void bind | ( | uint_t | index, |
const double & | value | ||
) |
Bind a double-precision floating point value to the designated parameter in the query.
index | The index of the parameter (where 1 refers to the first parameter). |
value | The value to bind. |
SQLException | If a database error occurs. |
void bind | ( | const String & | name, |
const double & | value | ||
) |
Bind a double-precision floating point value to the designated parameter in the query.
name | The name of the parameter. |
value | The value to bind. |
SQLException | If a database error occurs. |
Bind a String value to the designated parameter in the query.
index | The index of the parameter (where 1 refers to the first parameter). |
value | The value to bind. |
SQLException | If a database error occurs. |
Bind a String value to the designated parameter in the query.
name | The name of the parameter. |
value | The value to bind. |
SQLException | If a database error occurs. |
void bind | ( | uint_t | index, |
const char * | value | ||
) |
Bind a string value to the designated parameter in the query.
index | The index of the parameter (where 1 refers to the first parameter). |
value | The value to bind. |
SQLException | If a database error occurs. |
void bind | ( | const String & | name, |
const char * | value | ||
) |
Bind a string value to the designated parameter in the query.
name | The name of the parameter. |
value | The value to bind. |
SQLException | If a database error occurs. |
Bind a Blob value to the designated parameter in the query.
index | The index of the parameter (where 1 refers to the first parameter). |
value | The value to bind. |
SQLException | If a database error occurs. |
Bind a Blob value to the designated parameter in the query.
name | The name of the parameter. |
value | The value to bind. |
SQLException | If a database error occurs. |
void clear | ( | ) |
Clear the parameter value bindings for the query.
SQLException | If a database error occurs. |
void execute | ( | ) |
Execute the query.
SQLException | If a database error occurs. |
InterruptedException | If the operation was interrupted via a call to SQLDatabase::interrupt(). |
Get the aliased name for the given column in the results.
column | The column number (counting from 1). |
SQLException | If a database error occurs. |
Get the value for the given column in the current row of the results, as a Blob.
column | The column number (counting from 1). |
SQLException | If a database error occurs. |
uint_t getColumnCount | ( | ) |
Get the number of columns in the results.
SQLException | If a database error occurs. |
Get the unaliased name for the given column in the results.
column | The column number (counting from 1). |
SQLException | If a database error occurs. |
Get the value for the given column in the current row of the results.
column | The column number (counting from 1). |
SQLException | If a database error occurs. |
double getDouble | ( | uint_t | column | ) |
Get the value for the given column in the current row of the results, as a double-precision floating point value.
column | The column number (counting from 1). |
SQLException | If a database error occurs. |
int getInt | ( | uint_t | column | ) |
Get the value for the given column in the current row of the results, as an integer.
column | The column number (counting from 1). |
SQLException | If a database error occurs. |
int64_t getInt64 | ( | uint_t | column | ) |
Get the value for the given column in the current row of the results, as a 64-bit integer.
column | The column number (counting from 1). |
SQLException | If a database error occurs. |
uint_t getParameterCount | ( | ) |
Get the number of parameters in the query.
SQLException | If a database error occurs. |
Get the value for the given column in the current row of the results, as a String.
column | The column number (counting from 1). |
SQLException | If a database error occurs. |
Get the name of the table for the given column in the results.
column | The column number (counting from 1). |
SQLException | If a database error occurs. |
bool next | ( | ) |
Advance to the next result.
SQLException | If a database error occurs. |
InterruptedException | If the operation was interrupted via a call to SQLDatabase::interrupt(). |
TimeoutException | If a timeout occurs while waiting for database locks. The call should be retried in this case. |
void reset | ( | ) |
Reset the query so that it can be executed again.
SQLException | If a database error occurs. |
String toSQL | ( | ) |
Get the SQL statement represented by this query.
SQLException | If a database error occurs. |
|
friend |