libpqxx 4.0
|
Standard back-end transaction, templatized on isolation level. More...
#include <transaction.hxx>
Public Types | |
typedef isolation_traits < ISOLATIONLEVEL > | isolation_tag |
If nothing else is known, our isolation level is at least read_committed. | |
Public Member Functions | |
transaction (connection_base &C, const std::string &TName) | |
Create a transaction. | |
transaction (connection_base &C) | |
virtual | ~transaction () throw () |
Standard back-end transaction, templatized on isolation level.
This is the type you'll normally want to use to represent a transaction on the database.
While you may choose to create your own transaction object to interface to the database backend, it is recommended that you wrap your transaction code into a transactor code instead and let the transaction be created for you.
If you should find that using a transactor makes your code less portable or too complex, go ahead, create your own transaction anyway.
Usage example: double all wages
extern connection C; work T(C); try { T.exec("UPDATE employees SET wage=wage*2"); T.commit(); // NOTE: do this inside try block } catch (const exception &e) { cerr << e.what() << endl; T.abort(); // Usually not needed; same happens when T's life ends. }
typedef isolation_traits<ISOLATIONLEVEL> pqxx::transaction< ISOLATIONLEVEL, READWRITE >::isolation_tag |
If nothing else is known, our isolation level is at least read_committed.
Reimplemented from pqxx::transaction_base.
pqxx::transaction< ISOLATIONLEVEL, READWRITE >::transaction | ( | connection_base & | C, |
const std::string & | TName | ||
) | [explicit] |
Create a transaction.
C | Connection for this transaction to operate on |
TName | Optional name for transaction; must begin with a letter and may contain letters and digits only |
References pqxx::transaction_base::Begin().
pqxx::transaction< ISOLATIONLEVEL, READWRITE >::transaction | ( | connection_base & | C | ) | [explicit] |
References pqxx::transaction_base::Begin().
virtual pqxx::transaction< ISOLATIONLEVEL, READWRITE >::~transaction | ( | ) | throw () [virtual] |
References pqxx::transaction_base::conn(), and pqxx::transaction_base::End().