summaryrefslogtreecommitdiff
path: root/libpqpp/pq-modifycommand.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libpqpp/pq-modifycommand.cpp')
-rw-r--r--libpqpp/pq-modifycommand.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/libpqpp/pq-modifycommand.cpp b/libpqpp/pq-modifycommand.cpp
index b29fda7..53c3231 100644
--- a/libpqpp/pq-modifycommand.cpp
+++ b/libpqpp/pq-modifycommand.cpp
@@ -15,11 +15,10 @@ PQ::ModifyCommand::ModifyCommand(Connection * conn, const std::string & sql, con
unsigned int
PQ::ModifyCommand::execute(bool anc)
{
- PGresult * res = PQexecPrepared(
- c->conn, prepare(), static_cast<int>(values.size()), values.data(), lengths.data(), formats.data(), 0);
- c->checkResult(res, PGRES_COMMAND_OK, PGRES_TUPLES_OK);
- auto rows = atoi(PQcmdTuples(res));
- PQclear(res);
+ const auto res = c->checkResult(PQexecPrepared(c->conn, prepare(), static_cast<int>(values.size()), values.data(),
+ lengths.data(), formats.data(), 0),
+ PGRES_COMMAND_OK, PGRES_TUPLES_OK);
+ auto rows = atoi(PQcmdTuples(res.get()));
if (rows == 0 && !anc) {
throw DB::NoRowsAffected();
}