aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odb/pgsql/statement.cxx44
-rw-r--r--odb/pgsql/statement.hxx29
2 files changed, 73 insertions, 0 deletions
diff --git a/odb/pgsql/statement.cxx b/odb/pgsql/statement.cxx
index efd7f8e..f3425a6 100644
--- a/odb/pgsql/statement.cxx
+++ b/odb/pgsql/statement.cxx
@@ -128,6 +128,50 @@ namespace odb
return static_cast<unsigned long long> (oid_);
}
+ //
+ // update_statement
+ //
+
+ update_statement::
+ ~update_statement ()
+ {
+ }
+
+ update_statement::
+ update_statement (connection& conn,
+ const string& name,
+ const string& stmt,
+ const Oid* types,
+ size_t n,
+ native_binding& cond,
+ native_binding& data)
+ : statement (conn, name, stmt, types, n),
+ cond_ (cond),
+ data_ (data)
+ {
+ }
+
+ void update_statement::
+ execute ()
+ {
+ result_ptr r (PQexecPrepared (conn_.handle (),
+ name_.c_str (),
+ cond_.count,
+ cond_.values,
+ cond_.lengths,
+ cond_.formats,
+ 1));
+
+ PGresult* h (r.get ());
+
+ if (!is_good_result (h))
+ translate_error (conn_, h);
+
+ const char* s (PQcmdTuples (h));
+
+ if (s[0] == '0')
+ throw object_not_persistent ();
+ }
//
// delete_statement
diff --git a/odb/pgsql/statement.hxx b/odb/pgsql/statement.hxx
index 88b1c14..17d4930 100644
--- a/odb/pgsql/statement.hxx
+++ b/odb/pgsql/statement.hxx
@@ -79,6 +79,35 @@ namespace odb
Oid oid_;
};
+ class LIBODB_PGSQL_EXPORT update_statement: public statement
+ {
+ public:
+ virtual
+ ~update_statement ();
+
+ // Asssumes that cond.values, cond.lengths, and cond.formats are
+ // suffixes of data.values, data.lengths, and data.formats
+ // respectively.
+ //
+ update_statement (connection& conn,
+ const std::string& name,
+ const std::string& stmt,
+ const Oid* types,
+ std::size_t n,
+ native_binding& cond,
+ native_binding& data);
+ void
+ execute ();
+
+ private:
+ update_statement (const update_statement&);
+ update_statement& operator= (const update_statement&);
+
+ private:
+ native_binding& cond_;
+ native_binding& data_;
+ };
+
class LIBODB_PGSQL_EXPORT delete_statement: public statement
{
public: