CppDB
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Friends
cppdb::statement Class Reference

This class represents a prepared (or ordinary) statement that can be executed. More...

#include <cppdb/frontend.h>

List of all members.

Public Member Functions

 statement ()
 ~statement ()
 statement (statement const &)
statement const & operator= (statement const &)
void reset ()
void clear ()
bool empty () const
statementbind (int v)
statementbind (unsigned v)
statementbind (long v)
statementbind (unsigned long v)
statementbind (long long v)
statementbind (unsigned long long v)
statementbind (double v)
statementbind (long double v)
statementbind (std::string const &v)
statementbind (char const *s)
statementbind (char const *b, char const *e)
statementbind (std::tm const &v)
statementbind (std::istream &v)
statementbind_null ()
void bind (int col, int v)
void bind (int col, unsigned v)
void bind (int col, long v)
void bind (int col, unsigned long v)
void bind (int col, long long v)
void bind (int col, unsigned long long v)
void bind (int col, double v)
void bind (int col, long double v)
void bind (int col, std::string const &v)
void bind (int col, char const *s)
void bind (int col, char const *b, char const *e)
void bind (int col, std::tm const &v)
void bind (int col, std::istream &v)
void bind_null (int col)
long long last_insert_id ()
long long sequence_last (std::string const &seq)
unsigned long long affected ()
result row ()
result query ()
 operator result ()
void exec ()
statementoperator<< (std::string const &v)
statementoperator<< (char const *s)
statementoperator<< (std::tm const &v)
statementoperator<< (std::istream &v)
statementoperator<< (void(*manipulator)(statement &st))
result operator<< (result(*manipulator)(statement &st))
template<typename T >
statementoperator<< (tags::use_tag< T > const &val)
template<typename T >
statementoperator<< (T v)

Friends

class session

Detailed Description

This class represents a prepared (or ordinary) statement that can be executed.

This object is usually created via session::prepare() function.


Constructor & Destructor Documentation

Default constructor, provided for convenience, access to any member function of empty statement will cause an exception being thrown.

Destructor, it releases prepared statement and if the statements cache is enabled it returns it into the cache.

Note: if result object created by this statement is alive, the underlying backned::statement would be on hold until result object is destroyed and only then the statement would be put back into cache.

Copy statement.

Please note it copies only the reference to underlying statement object, so copies of same statement represent same object and it is strongly not recommended to access the underlying backend::statement by two different statement objects.


Member Function Documentation

unsigned long long cppdb::statement::affected ( )

Get the number of affected rows by the last statement,

If the statement is actually query, the behavior is undefined and may vary between backends.

Bind a value v to the next placeholder (starting from the first) marked with '?' marker in the query.

If number of calls is higher then the number placeholders is the statement it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

Bind a value v to the next placeholder (starting from the first) marked with '?' marker in the query.

If number of calls is higher then the number placeholders is the statement it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

Bind a value v to the next placeholder (starting from the first) marked with '?' marker in the query.

If number of calls is higher then the number placeholders is the statement it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

statement& cppdb::statement::bind ( unsigned long  v)

Bind a value v to the next placeholder (starting from the first) marked with '?' marker in the query.

If number of calls is higher then the number placeholders is the statement it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

statement& cppdb::statement::bind ( long long  v)

Bind a value v to the next placeholder (starting from the first) marked with '?' marker in the query.

If number of calls is higher then the number placeholders is the statement it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

statement& cppdb::statement::bind ( unsigned long long  v)

Bind a value v to the next placeholder (starting from the first) marked with '?' marker in the query.

If number of calls is higher then the number placeholders is the statement it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

Bind a value v to the next placeholder (starting from the first) marked with '?' marker in the query.

If number of calls is higher then the number placeholders is the statement it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

statement& cppdb::statement::bind ( long double  v)

Bind a value v to the next placeholder (starting from the first) marked with '?' marker in the query.

If number of calls is higher then the number placeholders is the statement it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

statement& cppdb::statement::bind ( std::string const &  v)

Bind a string value v to the next placeholder marked with '?' marker in the query.

Note: the reference to the string MUST remain valid until the statement is queried or executed!

If number of calls is higher then the number placeholders is the statement it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

statement& cppdb::statement::bind ( char const *  s)

Bind a null terminated string value s to the next placeholder marked with '?' marker in the query.

Note: the reference to the string MUST remain valid until the statement is queried or executed!

If number of calls is higher then the number placeholders is the statement it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

statement& cppdb::statement::bind ( char const *  b,
char const *  e 
)

Bind a string value in range [b, e ) to the next placeholder marked with '?' marker in the query.

Note: the reference to the string MUST remain valid until the statement is queried or executed!

If number of calls is higher then the number placeholders is the statement it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

statement& cppdb::statement::bind ( std::tm const &  v)

Bind a value v to the next placeholder (starting from the first) marked with '?' marker in the query.

If number of calls is higher then the number placeholders is the statement it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

statement& cppdb::statement::bind ( std::istream &  v)

Bind a BLOB value v to the next placeholder marked with '?' marker in the query.

Note: the reference to the stream MUST remain valid until the statement is queried or executed!

If number of calls is higher then the number placeholders is the statement it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

void cppdb::statement::bind ( int  col,
int  v 
)

Bind a value v to the placeholder number col (starting from 1) marked with '?' marker in the query.

If cols is invalid (less then 1 or higher then the number of the placeholders is the statement) it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

void cppdb::statement::bind ( int  col,
unsigned  v 
)

Bind a value v to the placeholder number col (starting from 1) marked with '?' marker in the query.

If cols is invalid (less then 1 or higher then the number of the placeholders is the statement) it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

void cppdb::statement::bind ( int  col,
long  v 
)

Bind a value v to the placeholder number col (starting from 1) marked with '?' marker in the query.

If cols is invalid (less then 1 or higher then the number of the placeholders is the statement) it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

void cppdb::statement::bind ( int  col,
unsigned long  v 
)

Bind a value v to the placeholder number col (starting from 1) marked with '?' marker in the query.

If cols is invalid (less then 1 or higher then the number of the placeholders is the statement) it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

void cppdb::statement::bind ( int  col,
long long  v 
)

Bind a value v to the placeholder number col (starting from 1) marked with '?' marker in the query.

If cols is invalid (less then 1 or higher then the number of the placeholders is the statement) it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

void cppdb::statement::bind ( int  col,
unsigned long long  v 
)

Bind a value v to the placeholder number col (starting from 1) marked with '?' marker in the query.

If cols is invalid (less then 1 or higher then the number of the placeholders is the statement) it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

void cppdb::statement::bind ( int  col,
double  v 
)

Bind a value v to the placeholder number col (starting from 1) marked with '?' marker in the query.

If cols is invalid (less then 1 or higher then the number of the placeholders is the statement) it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

void cppdb::statement::bind ( int  col,
long double  v 
)

Bind a value v to the placeholder number col (starting from 1) marked with '?' marker in the query.

If cols is invalid (less then 1 or higher then the number of the placeholders is the statement) it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

void cppdb::statement::bind ( int  col,
std::string const &  v 
)

Bind a string value v to the placeholder number col (starting from 1) marked with '?' marker in the query.

Note: the reference to the string MUST remain valid until the statement is queried or executed!

If cols is invalid (less then 1 or higher then the number of the placeholders is the statement) it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

void cppdb::statement::bind ( int  col,
char const *  s 
)

Bind a null terminated string value s to the placeholder number col (starting from 1) marked with '?' marker in the query.

Note: the reference to the string MUST remain valid until the statement is queried or executed!

If cols is invalid (less then 1 or higher then the number of the placeholders is the statement) it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

void cppdb::statement::bind ( int  col,
char const *  b,
char const *  e 
)

Bind a string value in range [b, e ) to the placeholder number col (starting from 1) marked with '?' marker in the query.

Note: the reference to the string MUST remain valid until the statement is queried or executed!

If cols is invalid (less then 1 or higher then the number of the placeholders is the statement) it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

void cppdb::statement::bind ( int  col,
std::tm const &  v 
)

Bind a value v to the placeholder number col (starting from 1) marked with '?' marker in the query.

If cols is invalid (less then 1 or higher then the number of the placeholders is the statement) it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

void cppdb::statement::bind ( int  col,
std::istream &  v 
)

Bind a BLOB value v to the placeholder number col (starting from 1) marked with '?' marker in the query.

Note: the reference to the stream MUST remain valid until the statement is queried or executed!

If cols is invalid (less then 1 or higher then the number of the placeholders is the statement) it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

Bind a NULL value to the next placeholder marked with '?' marker in the query.

If number of calls is higher then the number placeholders is the statement it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

void cppdb::statement::bind_null ( int  col)

Bind a NULL value to the placeholder number col (starting from 1) marked with '?' marker in the query.

If cols is invalid (less then 1 or higher then the number of the placeholders is the statement) it may throw invalid_placeholder exception.

If placeholder was not binded the behavior is undefined and may vary between different backends.

Clear the statement, removes it, any access to statement object would throw an exception till it would be assigned once again

bool cppdb::statement::empty ( ) const

Check if the statement is empty, it is empty when created with default constructor or when cleared with clear() member function.

Execute a statement, of the statement is actually SELECT like operator, it throws cppdb_error exception, however the behavior may vary between backends that may ignore this error.

Get last insert id from the last executed statement, note, it is the same as sequence_last("").

Some backends requires explicit sequence name so you should use sequence_last("sequence_name") in such case.

If the statement is actually query, the behavior is undefined and may vary between backends.

cppdb::statement::operator result ( )

Same as query() - syntactic sugar

statement& cppdb::statement::operator<< ( std::string const &  v)

Same as bind(v);

statement& cppdb::statement::operator<< ( char const *  s)

Same as bind(s);

statement& cppdb::statement::operator<< ( std::tm const &  v)

Same as bind(v);

statement& cppdb::statement::operator<< ( std::istream &  v)

Same as bind(v);

statement& cppdb::statement::operator<< ( void(*)(statement &st)  manipulator)

Apply manipulator on the statement, same as manipulator(*this).

result cppdb::statement::operator<< ( result(*)(statement &st)  manipulator)

Apply manipulator on the statement, same as manipulator(*this).

template<typename T >
statement& cppdb::statement::operator<< ( tags::use_tag< T > const &  val) [inline]

Used together with use() function.

The call st<<use(x,tag) is same as

  (tag == null_value) ?  st.bind_null() : st.bind(x)
template<typename T >
statement& cppdb::statement::operator<< ( v) [inline]

Same as bind(v);

statement const& cppdb::statement::operator= ( statement const &  )

Assign a statement.

Please note it copies only the reference to underlying statement object, so copies of same statement represent same object and it is strongly not recommended to access the underlying backend::statement by two different statement objects.

Fetch a result of the query, if the statement is not query statement (like SELECT) it would likely throw an exception, however the behavior may vary between backends that may ignore this error.

Reset the statement - remove all bindings and return it into initial state so query() or exec() functions can be called once again.

You must use it if you use the same statement multiple times.

Note, it is different from clear() where the statement is fully released and access to it would throw an exception

Fetch a single row from the query. Unlike query(), you should not call result::next() function as it is already called. You may check if the data was fetched using result::empty() function.

If the result set consists of more then one row it throws multiple_rows_query exception, however some backends may ignore this.

If the statement is not query statement (like SELECT) it would likely throw an exception, however the behavior may vary between backends that may ignore this error.

long long cppdb::statement::sequence_last ( std::string const &  seq)

Get last created sequence value from the last executed statement.

If the backend does not support named sequences but rather supports "auto increment" columns (like MySQL, Sqlite3), the seq parameter is ignored.

If the statement is actually query, the behavior is undefined and may vary between backends.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator