sq3::transaction Class Reference

This type represents a transaction block in an SQL session. More...

#include <sq3.hpp>

List of all members.

Public Member Functions

 transaction (database &db, bool start=true)
 Creates a transaction for the given db.
 ~transaction ()
 Calls this->rollback().
int begin ()
 Starts the transaction.
int commit ()
 Commits the active transaction.
int rollback ()
 Initiates a rollback and returns the result of executing a rollback command.


Detailed Description

This type represents a transaction block in an SQL session.

Note that as of this writing, sqlite3 does not support nested transactions.

Definition at line 624 of file sq3.hpp.


Constructor & Destructor Documentation

sq3::transaction::transaction ( database db,
bool  start = true 
)

Creates a transaction for the given db.

If start is true (the default) then this->begin() is called.

Definition at line 870 of file sq3.cpp.

References begin().


Member Function Documentation

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


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

Generated on Wed Apr 29 07:59:28 2009 for libsq3 by  doxygen 1.5.8