Client 4—Working with transactors
libpqxx strives to provide a robust connection to a PostgreSQL server, and the transactor<> class reflects that effort. The transactor<> class defines four important member functions:
void operator()( TRANSACTION & trans ); void OnAbort( const char errorMessage[] ) throw(); void OnCommit( void ) throw(); void OnDoubt( void ) throw();
When you derive a class from transactor<>, you must provide your own implementation for the operator() member function: That's where all the real work is done. To execute a transaction, you create an object derived from transactor<> and then pass that object to the connection_base::perform() member function. connection_base::perform() calls the operator() function in your transactor<> ...
Get PostgreSQL, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.