Public Member Functions | |
Prepared_statement () | |
Creates new object. | |
Prepared_statement (Database *db) | |
Creates new object with given database connection. | |
Prepared_statement (const wxString &name) | |
Creates new object with given name. | |
Prepared_statement (Database *db, const wxString &name) | |
Creates new object with give database connection and name. | |
virtual | ~Prepared_statement () |
Destructor. | |
void | db (Database *db) |
Set database connection for this object. | |
Database * | db () const |
Return current database connection. | |
void | name (const wxString &name) |
Set name for prepared statement. | |
const wxString & | name () const |
Return statement name. | |
virtual bool | prepare () |
Prepare statement. | |
virtual const wxString | make_execute_sql () |
Construct EXECUTE statement. | |
bool | prepared () const |
Is statement prepared. | |
virtual bool | execute () |
Execute statement. | |
virtual void | deallocate () |
Destroy the server side object. | |
const wxString & | last_err () const |
Return message for last error. | |
virtual void | detach () |
Detach notification from Database. | |
void | statement (const wxString &sql) |
SQL for statement. | |
const wxString & | statement () const |
Get current SQL statement. | |
virtual void | param_def (int type, int idx=-1) |
Define parametter type. | |
virtual int | param_def_get (unsigned idx) |
Get data type of earlier defined parametter. | |
virtual void | param_def_truncate (unsigned size) |
Truncate parametter definitions. | |
virtual void | param_set (int value, int idx=-1) |
Set parametter for statement. | |
virtual void | param_set (double value, int idx=-1) |
Set parametter for statement. | |
virtual void | param_set (const wxString &value, int idx=-1) |
Set parametter for statement. | |
virtual void | param_set (const wxDateTime &value, int idx=-1) |
Set parametter for statement. | |
virtual void | param_set (bool value, int idx=-1) |
Set parametter for statement. | |
virtual void | param_set_null (int idx=-1) |
Set parametter for statement to NULL. | |
Protected Member Functions | |
virtual const wxString | make_prepare_sql () |
Construct PREPARE statement. | |
Protected Attributes | |
wxString | generated_name_ |
Prepared statement has its name. If no name is specified, it is autogenerated.
wxPg::Prepared_statement::Prepared_statement | ( | ) |
Creates new object.
Call database() to complete initialization.
wxPg::Prepared_statement::Prepared_statement | ( | Database * | db | ) | [explicit] |
Creates new object with given database connection.
db | - database connection to be used by this object. |
wxPg::Prepared_statement::Prepared_statement | ( | const wxString & | name | ) | [explicit] |
Creates new object with given name.
Call database() to complete initialization.
name | - name for prepared statement. |
wxPg::Prepared_statement::Prepared_statement | ( | Database * | db, | |
const wxString & | name | |||
) |
Creates new object with give database connection and name.
db | - database connection to be used by this object. | |
name | - name for prepared statement. |
virtual wxPg::Prepared_statement::~Prepared_statement | ( | ) | [virtual] |
Destructor.
Database* wxPg::Prepared_statement::db | ( | ) | const [inline] |
Return current database connection.
void wxPg::Prepared_statement::db | ( | Database * | db | ) |
Set database connection for this object.
You can not change connection while statement is prepared.
db | - database connection. |
virtual void wxPg::Prepared_statement::deallocate | ( | ) | [virtual] |
Destroy the server side object.
After this object can not be executed but can be reinitialized for a new statement.
virtual void wxPg::Prepared_statement::detach | ( | ) | [virtual] |
Detach notification from Database.
This methon is called by wPg::Database, when client is detached because of external reasons (Such as database disconnect).
Implements wxPg::DB_client.
virtual bool wxPg::Prepared_statement::execute | ( | ) | [virtual] |
Execute statement.
const wxString& wxPg::Prepared_statement::last_err | ( | ) | const [inline] |
Return message for last error.
virtual const wxString wxPg::Prepared_statement::make_execute_sql | ( | ) | [virtual] |
Construct EXECUTE statement.
Used internally by this object. Use this method for statements that return result: this will return an sql statement that can be openned by wxPg::Query.
virtual const wxString wxPg::Prepared_statement::make_prepare_sql | ( | ) | [protected, virtual] |
Construct PREPARE statement.
const wxString& wxPg::Prepared_statement::name | ( | ) | const [inline] |
Return statement name.
If no name was given, stement has no name util it is prepared.
void wxPg::Prepared_statement::name | ( | const wxString & | name | ) |
Set name for prepared statement.
This is optional. If no name is given, the name is automatically generated. You can not change name while statement is prepared.
name | - statment name. |
virtual void wxPg::Prepared_statement::param_def | ( | int | type, | |
int | idx = -1 | |||
) | [virtual] |
Define parametter type.
Type definitions are automatically used when preparing statement.
It is optional to define parametter types. Don't change parametter type after setting its value or set its value again after changing type.
type | - one of data types, defined in type.h. | |
idx | - parametter index, appended to the end, if negative. |
virtual int wxPg::Prepared_statement::param_def_get | ( | unsigned | idx | ) | [virtual] |
Get data type of earlier defined parametter.
For undefined parametters TYPE_UNKNOWN is returned.
idx | - parametter idx. |
virtual void wxPg::Prepared_statement::param_def_truncate | ( | unsigned | size | ) | [virtual] |
Truncate parametter definitions.
Nothing is done, if truncating to bigger size than currently is.
size | - numer of arguments to leave. |
virtual void wxPg::Prepared_statement::param_set | ( | bool | value, | |
int | idx = -1 | |||
) | [virtual] |
Set parametter for statement.
If idx is higher than current count of parametters, a necessary amount of NULL parametters is appended.
value | - value for parametter. | |
idx | - parametter index, append to the end if negative. |
virtual void wxPg::Prepared_statement::param_set | ( | const wxDateTime & | value, | |
int | idx = -1 | |||
) | [virtual] |
Set parametter for statement.
If idx is higher than current count of parametters, a necessary amount of NULL parametters is appended.
value | - value for parametter. | |
idx | - parametter index, append to the end if negative. |
virtual void wxPg::Prepared_statement::param_set | ( | const wxString & | value, | |
int | idx = -1 | |||
) | [virtual] |
Set parametter for statement.
If idx is higher than current count of parametters, a necessary amount of NULL parametters is appended.
value | - value for parametter. | |
idx | - parametter index, append to the end if negative. |
virtual void wxPg::Prepared_statement::param_set | ( | double | value, | |
int | idx = -1 | |||
) | [virtual] |
Set parametter for statement.
If idx is higher than current count of parametters, a necessary amount of NULL parametters is appended.
value | - value for parametter. | |
idx | - parametter index, append to the end if negative. |
virtual void wxPg::Prepared_statement::param_set | ( | int | value, | |
int | idx = -1 | |||
) | [virtual] |
Set parametter for statement.
If idx is higher than current count of parametters, a necessary amount of NULL parametters is appended.
value | - value for parametter. | |
idx | - parametter index, append to the end if negative. |
virtual void wxPg::Prepared_statement::param_set_null | ( | int | idx = -1 |
) | [virtual] |
Set parametter for statement to NULL.
If idx is higher than current count of parametters, a necessary amount of NULL parametters is appended.
idx | - parametter index, append to the end if negative. |
virtual bool wxPg::Prepared_statement::prepare | ( | ) | [virtual] |
Prepare statement.
This create a server side object, which is destroyed when database is disconnected or by calling deallocate(). If this method returns false, call last_err() to get error message.
bool wxPg::Prepared_statement::prepared | ( | ) | const [inline] |
Is statement prepared.
const wxString& wxPg::Prepared_statement::statement | ( | ) | const [inline] |
Get current SQL statement.
void wxPg::Prepared_statement::statement | ( | const wxString & | sql | ) |
SQL for statement.
Specify only the statement itself, the full PREPARE statement will be constructed by this object. You can not change statement while it is prepared.
sql | - statement to be prepared. |