From b18a2a0fd742450a2cc869f134aa03cf831916a1 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Thu, 19 May 2011 13:45:32 +0200 Subject: Add statement, insert_statement, and delete_statement --- odb/pgsql/statement.hxx | 110 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 odb/pgsql/statement.hxx (limited to 'odb/pgsql/statement.hxx') diff --git a/odb/pgsql/statement.hxx b/odb/pgsql/statement.hxx new file mode 100644 index 0000000..88b1c14 --- /dev/null +++ b/odb/pgsql/statement.hxx @@ -0,0 +1,110 @@ +// file : odb/pgsql/statement.hxx +// author : Constantin Michael +// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_PGSQL_STATEMENT_HXX +#define ODB_PGSQL_STATEMENT_HXX + +#include + +#include +#include // std::size_t + +#include + +#include + +#include +#include + +#include + +namespace odb +{ + namespace pgsql + { + class connection; + + class LIBODB_PGSQL_EXPORT statement: public details::shared_base + { + public: + virtual + ~statement () = 0; + + protected: + statement (connection&, + const std::string& name, + const std::string& stmt, + const Oid* types, + std::size_t n); + + protected: + connection& conn_; + std::string name_; + + private: + void + release (); + }; + + class LIBODB_PGSQL_EXPORT insert_statement: public statement + { + public: + virtual + ~insert_statement (); + + insert_statement (connection& conn, + const std::string& name, + const std::string& stmt, + const Oid* types, + std::size_t n, + native_binding& data); + + // Return true if successful and false if the row is a duplicate. + // All other errors are reported by throwing exceptions. + // + bool + execute (); + + unsigned long long + id (); + + private: + insert_statement (const insert_statement&); + insert_statement& operator= (const insert_statement&); + + private: + native_binding& data_; + Oid oid_; + }; + + class LIBODB_PGSQL_EXPORT delete_statement: public statement + { + public: + virtual + ~delete_statement (); + + delete_statement (connection& conn, + const std::string& name, + const std::string& stmt, + const Oid* types, + std::size_t n, + native_binding& cond); + + unsigned long long + execute (); + + private: + delete_statement (const delete_statement&); + delete_statement& operator= (const delete_statement&); + + private: + native_binding& cond_; + }; + } +} + +#include + +#endif // ODB_PGSQL_STATEMENT_HXX -- cgit v1.1