wxPg::Prepared_statement Class Reference

Prepared statement class. More...

Inheritance diagram for wxPg::Prepared_statement:

wxPg::DB_client

List of all members.

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.
Databasedb () 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_


Detailed Description

Prepared statement class.

Prepared statement has its name. If no name is specified, it is autogenerated.


Constructor & Destructor Documentation

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.

Parameters:
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.

Parameters:
name - name for prepared statement.

wxPg::Prepared_statement::Prepared_statement ( Database db,
const wxString &  name 
)

Creates new object with give database connection and name.

Parameters:
db - database connection to be used by this object.
name - name for prepared statement.

virtual wxPg::Prepared_statement::~Prepared_statement (  )  [virtual]

Destructor.


Member Function Documentation

Database* wxPg::Prepared_statement::db (  )  const [inline]

Return current database connection.

Returns:
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.

Parameters:
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.

Returns:
true on success, false on error.

const wxString& wxPg::Prepared_statement::last_err (  )  const [inline]

Return message for last error.

Returns:
last error message.

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.

Returns:
Execute statement of empty string on error.

virtual const wxString wxPg::Prepared_statement::make_prepare_sql (  )  [protected, virtual]

Construct PREPARE statement.

Returns:
PREPARE statement or empty string on error.

const wxString& wxPg::Prepared_statement::name (  )  const [inline]

Return statement name.

If no name was given, stement has no name util it is prepared.

Returns:
statement name.

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.

Parameters:
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.

Parameters:
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.

Parameters:
idx - parametter idx.
Returns:
one of types, defined in type.h.

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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Returns:
true on success, false on error.

bool wxPg::Prepared_statement::prepared (  )  const [inline]

Is statement prepared.

Returns:
true if statement is prepared, false otherwise.

const wxString& wxPg::Prepared_statement::statement (  )  const [inline]

Get current SQL statement.

Returns:
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.

Parameters:
sql - statement to be prepared.


Generated on Wed Oct 7 23:14:40 2009 for wxPostgres by  doxygen 1.5.8