libsq3
2007.10.18
|
This type represents a transaction block in an SQL session. More...
#include <sq3.hpp>
Public Member Functions | |
transaction (database &db, bool start=true) | |
Creates a transaction for the given db. More... | |
~transaction () | |
Calls this->rollback() | |
int | begin () |
Starts the transaction. More... | |
int | commit () |
Commits the active transaction. More... | |
int | rollback () |
Initiates a rollback and returns the result of executing a rollback command. More... | |
This type represents a transaction block in an SQL session.
Note that as of this writing, sqlite3 does not support nested transactions.
sq3::transaction::transaction | ( | database & | db, |
bool | start = true |
||
) |
int sq3::transaction::begin | ( | ) |
Starts the transaction.
Return value is the result of calling sqlite3_exec(db,"begin;"). If SQLITE_OK is returned then this object considers itself to be active, such that calling commit() and rollback() should be able to succeed.
Definition at line 881 of file sq3.cpp.
References sq3::database::execute().
Referenced by transaction().
int sq3::transaction::commit | ( | ) |
Commits the active transaction.
Returns SQLITE_OK on success and any other value on error. Return value is that of the underlying sqlite3_exec() call.
After calling this function, this object is considered to NOT be in a transaction unless SQLITE_BUSY is returned. If that happens, the transaction is still open and commit() should be called later to close the transaction.
Definition at line 892 of file sq3.cpp.
References sq3::database::execute().
int sq3::transaction::rollback | ( | ) |
Initiates a rollback and returns the result of executing a rollback command.
If this object is not active (begin() has not been called) then this function returns SQLITE_ERROR and has no side-effects. Return value is that of the underlying sqlite3_exec() call.
Definition at line 907 of file sq3.cpp.
References sq3::database::execute().
Referenced by ~transaction().