libpqxx  7.0.2
pqxx::pqxx::transaction< ISOLATION, READWRITE > Class Template Referencefinal

Standard back-end transaction, templatized on isolation level. More...

#include <transaction.hxx>

Inheritance diagram for pqxx::pqxx::transaction< ISOLATION, READWRITE >:

Public Member Functions

 transaction (connection &c, std::string const &tname)
 Create a transaction. More...
 
 transaction (connection &c)
 
virtual ~transaction () noexcept override
 

Additional Inherited Members

- Protected Member Functions inherited from pqxx::internal::basic_transaction
 basic_transaction (connection &c, char const begin_command[])
 
- Protected Member Functions inherited from pqxx::dbtransaction
 dbtransaction (connection &c)
 

Detailed Description

template<isolation_level ISOLATION = isolation_level::read_committed, write_policy READWRITE = write_policy::read_write>
class pqxx::pqxx::transaction< ISOLATION, READWRITE >

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.

Usage example: double all wages.

extern connection C;
work T(C);
try
{
T.exec0("UPDATE employees SET wage=wage*2");
T.commit(); // NOTE: do this inside try block
}
catch (exception const &e)
{
cerr << e.what() << endl;
T.abort(); // Usually not needed; same happens when T's life ends.
}

Constructor & Destructor Documentation

◆ transaction() [1/2]

template<isolation_level ISOLATION = isolation_level::read_committed, write_policy READWRITE = write_policy::read_write>
pqxx::pqxx::transaction< ISOLATION, READWRITE >::transaction ( connection &  c,
std::string const &  tname 
)
explicit

Create a transaction.

Parameters
cConnection for this transaction to operate on.
tnameOptional name for transaction. Must begin with a letter and may contain letters and digits only.

◆ transaction() [2/2]

template<isolation_level ISOLATION = isolation_level::read_committed, write_policy READWRITE = write_policy::read_write>
pqxx::pqxx::transaction< ISOLATION, READWRITE >::transaction ( connection &  c)
explicit

◆ ~transaction()

template<isolation_level ISOLATION = isolation_level::read_committed, write_policy READWRITE = write_policy::read_write>
virtual pqxx::pqxx::transaction< ISOLATION, READWRITE >::~transaction ( )
overridevirtualnoexcept

The documentation for this class was generated from the following file: