DUNE: Uniform Navigational Environment  2.6.1
DUNE::Database::Statement Class Reference

Detailed Description

SQL statement.

Public Member Functions

 Statement (const char *sql_stmt, Connection &conn)
 
 ~Statement ()
 
bool execute (int *count=0)
 
void reset (void)
 
Statementoperator<< (Null null)
 
Statementoperator<< (int value)
 
Statementoperator<< (double value)
 
Statementoperator<< (const std::string &value)
 
Statementoperator<< (const char *value)
 
Statementoperator<< (const Blob &value)
 
template<typename T >
Statementoperator<< (T value)
 
Statementoperator>> (int &value)
 
Statementoperator>> (double &value)
 
Statementoperator>> (std::string &value)
 
Statementoperator>> (Blob &value)
 
template<typename T >
Statementoperator>> (T &value)
 
template<typename T >
Statementoperator>> (std::pair< bool, T > &r)
 

Constructor & Destructor Documentation

DUNE::Database::Statement::Statement ( const char *  sql_stmt,
Connection conn 
)

Constructor.

Parameters
sql_stmtSQL statement.
connDatabase connection.

References DUNE::Database::Connection::handle().

DUNE::Database::Statement::~Statement ( void  )

Destructor.

Member Function Documentation

bool DUNE::Database::Statement::execute ( int *  count = 0)

Execute statement.

All statement arguments must be bound when this method is called using operator<<() in order of the statement wildcards. It will return true if there are more rows to process, false otherwise. When it returns true, the results can be obtained using operator>>() in order of the column results. When it returns false, reset() will have been called internally, so there is no need to call it subsequently.

Parameters
countfor INSERT, UPDATE or DELETE statements, may return the number of rows affected by the operation
Returns
true if there are more rows to process.

References DUNE::Database::Connection::handle(), and reset().

Referenced by DUNE::Database::Connection::beginTransaction(), DUNE::Database::Connection::commit(), and DUNE::Database::Connection::rollback().

Statement & DUNE::Database::Statement::operator<< ( Null  null)

Bind an argument to NULL.

Parameters
nullNull datum.
Statement & DUNE::Database::Statement::operator<< ( int  value)

Bind an argument to an integer value.

Parameters
valueargument value.
Statement & DUNE::Database::Statement::operator<< ( double  value)

Bind an argument to a double value.

Parameters
valueargument value.
Statement & DUNE::Database::Statement::operator<< ( const std::string &  value)

Bind an argument to a string value.

Parameters
valueargument value.
Statement & DUNE::Database::Statement::operator<< ( const char *  value)

Bind an argument to a string value.

Parameters
valueargument value.
Statement & DUNE::Database::Statement::operator<< ( const Blob value)

Bind an argument to a blob value.

Parameters
valueargument value.
template<typename T >
Statement& DUNE::Database::Statement::operator<< ( value)
inline

Bind an argument to an integer value (template version for other integral types).

Parameters
valueargument value.
Statement & DUNE::Database::Statement::operator>> ( int &  value)

Get a column result of INTEGER type (queries only).

Parameters
valueresult reference.
Statement & DUNE::Database::Statement::operator>> ( double &  value)

Get a column result of REAL type (queries only).

Parameters
valueresult reference.
Statement & DUNE::Database::Statement::operator>> ( std::string &  value)

Get a column result of VARCHAR type (queries only).

Parameters
valueresult reference.
Statement & DUNE::Database::Statement::operator>> ( Blob value)

Get a column result of BLOB type (queries only).

Parameters
valueresult reference.
template<typename T >
Statement& DUNE::Database::Statement::operator>> ( T &  value)
inline

Get a column result of INTEGER type (queries only) – template version.

Parameters
valueresult reference.
template<typename T >
Statement& DUNE::Database::Statement::operator>> ( std::pair< bool, T > &  r)
inline

Get a possibly NULL result of a given type.

The first pair element will be set to 'true' if result is defined (i.e. not NULL), and in that case the second pair element

Parameters
rresult reference.
void DUNE::Database::Statement::reset ( void  )

Reset.

The statement will not be bound to any arguments nor have any available results afterwards.

Referenced by execute().

Collaboration diagram for DUNE::Database::Statement:
Collaboration graph