nanodbc
A small C++ wrapper for the native C ODBC API
Loading...
Searching...
No Matches
nanodbc::transaction Class Reference

A resource for managing transaction commits and rollbacks. More...

#include <nanodbc.h>

Public Member Functions

 transaction (const class connection &conn)
 Begin a transaction on the given connection object.
 
 transaction (const transaction &rhs) noexcept
 Copy constructor.
 
 transaction (transaction &&rhs) noexcept
 Move constructor.
 
transactionoperator= (transaction rhs) noexcept
 Assignment.
 
void swap (transaction &rhs) noexcept
 Member swap.
 
 ~transaction () noexcept
 If this transaction has not been committed, it will rollback any modifying ops.
 
void commit ()
 Commits transaction immediately.
 
void rollback () noexcept
 Marks this transaction for rollback.
 
class connectionconnection () noexcept
 Returns the connection object.
 
const class connectionconnection () const noexcept
 Returns the connection object.
 
 operator class connection & () noexcept
 Returns the connection object.
 
 operator const class connection & () const noexcept
 Returns the connection object.
 

Detailed Description

A resource for managing transaction commits and rollbacks.

Attention
You will want to use transactions if you are doing batch operations because it will prevent auto commits from occurring after each individual operation is executed.

Constructor & Destructor Documentation

◆ transaction()

nanodbc::transaction::transaction ( const class connection conn)
explicit

Begin a transaction on the given connection object.

Postcondition
Operations that modify the database must now be committed before taking effect.
Exceptions
database_error

Member Function Documentation

◆ commit()

void nanodbc::transaction::commit ( )

Commits transaction immediately.

Exceptions
database_error

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