prepared_statement.hxx
/*-------------------------------------------------------------------------
*
* FILE
* pqxx/prepared_statement.hxx
*
* DESCRIPTION
* Helper classes for defining and executing prepared statements
* See the connection_base hierarchy for more about prepared statements
*
* Copyright (c) 2006-2011, Jeroen T. Vermeulen <jtv@xs4all.nl>
*
* See COPYING for copyright license. If you did not receive a file called
* COPYING with this source code, please notify the distributor of this mistake,
* or contact the author.
*
*-------------------------------------------------------------------------
*/
#ifndef PQXX_H_PREPARED_STATEMENT
#define PQXX_H_PREPARED_STATEMENT
#include "pqxx/compiler-public.hxx"
#include "pqxx/compiler-internal-pre.hxx"
#include "pqxx/internal/statement_parameters.hxx"
namespace pqxx
{
class binarystring;
class connection_base;
class transaction_base;
class result;
namespace prepare
{
class PQXX_LIBEXPORT invocation : internal::statement_parameters
{
public:
invocation(transaction_base &, const PGSTD::string &statement);
result exec() const;
bool exists() const;
invocation &operator()() { add_param(); return *this; }
template<typename T> invocation &operator()(const T &v)
{ add_param(v, true); return *this; }
invocation &operator()(const binarystring &v)
{ add_binary_param(v, true); return *this; }
template<typename T> invocation &operator()(const T &v, bool nonnull)
{ add_param(v, nonnull); return *this; }
invocation &operator()(const binarystring &v, bool nonnull)
{ add_binary_param(v, nonnull); return *this; }
template<typename T> invocation &operator()(T *v, bool nonnull=true)
{ add_param(v, nonnull); return *this; }
invocation &operator()(const char *v, bool nonnull=true)
{ add_param(v, nonnull); return *this; }
private:
invocation &operator=(const invocation &);
transaction_base &m_home;
const PGSTD::string m_statement;
PGSTD::vector<PGSTD::string> m_values;
PGSTD::vector<bool> m_nonnull;
invocation &setparam(const PGSTD::string &, bool nonnull);
};
namespace internal
{
struct PQXX_LIBEXPORT prepared_def
{
PGSTD::string definition;
bool registered;
prepared_def();
explicit prepared_def(const PGSTD::string &);
};
} // namespace pqxx::prepare::internal
} // namespace pqxx::prepare
} // namespace pqxx
#include "pqxx/compiler-internal-post.hxx"
#endif
pqxx::result
Result set containing data returned by a query or command.
Definition: result.hxx:81
pqxx::prepare::invocation::operator()
invocation & operator()(const binarystring &v, bool nonnull)
Pass binary parameter value for a BYTEA field.
Definition: prepared_statement.hxx:165
pqxx::prepare::internal::prepared_def
Internal representation of a prepared statement definition.
Definition: prepared_statement.hxx:214
pqxx::binarystring
Definition: binarystring.hxx:59
pqxx::prepare::internal::prepared_def::definition
std::string definition
Text of prepared query.
Definition: prepared_statement.hxx:217
pqxx::prepare::invocation::operator()
invocation & operator()()
Pass null parameter.
Definition: prepared_statement.hxx:136
pqxx::prepare::invocation::operator()
invocation & operator()(T *v, bool nonnull=true)
Pass C-style parameter string, or null if pointer is null.
Definition: prepared_statement.hxx:187
pqxx::prepare::invocation::operator()
invocation & operator()(const char *v, bool nonnull=true)
Pass C-style string parameter, or null if pointer is null.
Definition: prepared_statement.hxx:195
pqxx::prepare::invocation::operator()
invocation & operator()(const T &v, bool nonnull)
Pass parameter value.
Definition: prepared_statement.hxx:157
pqxx::prepare::invocation::operator()
invocation & operator()(const binarystring &v)
Pass binary parameter value for a BYTEA field.
Definition: prepared_statement.hxx:149
pqxx
The home of all libpqxx classes, functions, templates, etc.
Definition: basic_connection.hxx:35
pqxx::transaction_base
Definition: transaction_base.hxx:133
pqxx::prepare::invocation::operator()
invocation & operator()(const T &v)
Pass parameter value.
Definition: prepared_statement.hxx:142
pqxx::prepare::internal::prepared_def::registered
bool registered
Has this prepared statement been prepared in the current session?
Definition: prepared_statement.hxx:219