diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-10-17 22:11:44 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-10-17 22:11:44 +0100 |
commit | cf7a1dc4c55d9388ba4015c36627f507d1b3f73a (patch) | |
tree | 0fe50b1812647f219deae4eef8b2b9727dad39bd /libpqpp/connection.cpp | |
parent | Add override attributes (diff) | |
download | libdbpp-postgresql-cf7a1dc4c55d9388ba4015c36627f507d1b3f73a.tar.bz2 libdbpp-postgresql-cf7a1dc4c55d9388ba4015c36627f507d1b3f73a.tar.xz libdbpp-postgresql-cf7a1dc4c55d9388ba4015c36627f507d1b3f73a.zip |
Add support for getting last insert valuelibdbpp-postgresql-0.9.1
Diffstat (limited to 'libpqpp/connection.cpp')
-rw-r--r-- | libpqpp/connection.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
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; +} + |