So let's execute an actual query. There is no "query class" in libpqxx™; we really do try to keep your life simple.
A query is executed within a transaction by passing the query string to
the transaction object's exec
method. If the query
fails to complete successfully, this method will throw the appropriate
exception.
The query itself is a standard C string in this case, ie. a
const char *
but you'll frequently want to use a C++
string
to make it easy to include variables:
void DeleteEntry(work &T, string Table, long ID) { T.exec("DELETE FROM " + Table + " WHERE ID=" + to_string(ID)); }
In some places, even stringstream
s will work, so
you can use the full stream formatting capabilities, locales etc. in
the standard C++ library to compose your SQL queries.