libpqxx 4.0.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | List of all members
pqxx::transaction< ISOLATIONLEVEL, READWRITE > Class Template Reference
Transaction classes

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

`#include <transaction.hxx>`

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

## Public Types

typedef isolation_traits < ISOLATIONLEVEL > | isolation_tag

## Public Member Functions

| transaction (connection_base &C, const std::string &TName)
| Create a transaction.
| transaction (connection_base &C)
virtual | ~transaction () throw ()

## Additional Inherited Members

Protected Member Functions inherited from pqxx::basic_transaction
| basic_transaction (connection_base &C, const std::string &IsolationLevel, readwrite_policy)
Static Protected Member Functions inherited from pqxx::dbtransaction
static std::string | fullname (const std::string &ttype, const std::string &isolation)
Protected Attributes inherited from pqxx::transaction_base
internal::reactivation_avoidance_counter | m_reactivation_avoidance
| Resources allocated in this transaction that make reactivation impossible.

## Detailed Description

### template<isolation_level ISOLATIONLEVEL = read_committed, readwrite_policy READWRITE = read_write>
class pqxx::transaction< ISOLATIONLEVEL, 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.

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.

See Also
  pqxx/transactor.hxx

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.
}

## Member Typedef Documentation

template<isolation_level ISOLATIONLEVEL = read_committed, readwrite_policy READWRITE = read_write>

typedef isolation_traits<ISOLATIONLEVEL> pqxx::transaction< ISOLATIONLEVEL, READWRITE >::isolation_tag

## Constructor & Destructor Documentation

template<isolation_level ISOLATIONLEVEL = read_committed, readwrite_policy READWRITE = read_write>

pqxx::transaction< ISOLATIONLEVEL, READWRITE >::transaction | ( | connection_base & | C,
|  | const std::string & | TName
| ) |  |

explicit

Create a transaction.

Parameters

  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().

template<isolation_level ISOLATIONLEVEL = read_committed, readwrite_policy READWRITE = read_write>

pqxx::transaction< ISOLATIONLEVEL, READWRITE >::transaction | ( | connection_base & | C | ) |

explicit

References pqxx::transaction_base::Begin().

template<isolation_level ISOLATIONLEVEL = read_committed, readwrite_policy READWRITE = read_write>

virtual pqxx::transaction< ISOLATIONLEVEL, READWRITE >::~transaction | ( |  | ) | throw ()

virtual

References pqxx::transaction_base::conn(), and pqxx::transaction_base::End().

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

- transaction.hxx