The SOCI library provides the following members of the session class for transaction management:

In addition to the above there is a RAII wrapper that allows to associate the transaction with the given scope of code:

class transaction
    explicit transaction(session & sql);


    void commit();
    void rollback();

    // ...

The object of class transaction will roll back automatically when the object is destroyed (usually as a result of leaving the scope) and when the transaction was not explicitly committed before that.

A typical usage pattern for this class might be:

    transaction tr(sql);

    sql << "insert into ...";
    sql << "more sql queries ...";
    // ...


With the above pattern the transaction is committed only when the code successfully reaches the end of block. If some exception is thrown before that, the scope will be left without reaching the final statement and the transaction object will automatically roll back in its destructor.