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.
 
void swap (transaction &rhs) noexcept
 Member swap.
 
void commit ()
 Commits transaction immediately.
 
void rollback () noexcept
 Marks this transaction for rollback.
 
class connection & connection () noexcept
 Returns the connection object.
 
const class connection & connection () 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.

Copies share one transaction. If it has not been committed when the last copy is destroyed, it rolls back any modifying operations.

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: