From 576e4b9894157341815ca48cb8317b71499f82df Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 17 Oct 2015 22:11:44 +0100 Subject: Add support for getting last insert value --- libpqpp/connection.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libpqpp/connection.cpp') diff --git a/libpqpp/connection.cpp b/libpqpp/connection.cpp index e41cd3b..98f9054 100644 --- a/libpqpp/connection.cpp +++ b/libpqpp/connection.cpp @@ -186,3 +186,14 @@ PQ::Connection::bulkUploadData(const char * data, size_t len) const } } +int64_t +PQ::Connection::insertId() const +{ + SelectCommand getId(this, "SELECT lastval()", pstmntNo++); + int64_t id = -1; + while (getId.fetch()) { + getId[0] >> id; + } + return id; +} + -- cgit v1.2.3