From 0b762135ae0e28fcda69d58523364aa8bef9637a Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Thu, 19 May 2011 17:08:03 +0200 Subject: Add update_statement --- odb/pgsql/statement.cxx | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'odb/pgsql/statement.cxx') 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 (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 -- cgit v1.1