SQLite::RealTransaction Class Reference

Class handling SQLite transactions. More...

Inherits SQLite::RefObj.

Collaboration diagram for SQLite::RealTransaction:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RealTransaction (const DB &db, Transaction::TransactionType eType, const std::tstring &sName=_T(""))
 Constructor from a database and type.
bool IsValid () const
 Tests if the transaction is live (i.e., started).
const std::tstring & GetLastError () const
bool Close ()
 Commit the transaction and end it.
bool Commit ()
 Commit the transaction, i.e., make the changes up to now permanent.
bool Rollback ()
 Roll back the changes the transaction performed in the database from the last commit.
bool Execute (LPCTSTR pSQL)
 Runs an SQL action on the database (in the transaction).
bool Execute (const std::tstring &sSQL)
 Runs an SQL action on the database (in the transaction).
bool Execute (Statement &statement)
 Runs a prepared SQL statement on the database (in the transaction).
Recordset Query (LPCTSTR pSQL)
 Performs an SQL query on the database (in the transaction).
Recordset Query (const std::tstring &sSQL)
 Performs an SQL query on the database (in the transaction).
Recordset Query (Statement &statement)
 Performs a prepared SQL query on the database (in the transaction).

Protected Member Functions

virtual ~RealTransaction ()
 Destructor; closes the transaction if still active.
bool StartTransaction (Transaction::TransactionType eType)
 Starts the transaction.

Protected Attributes

DB m_db
 Database this transaction belongs to.
std::tstring m_sName
 Name of transaction.
bool m_bActive
 true if the transaction is 'live', i.e., has uncommited data
std::tstring m_sLastError
 Description of last error that occured while executing statements.

Static Protected Attributes

static LPCTSTR TRANSACTION_TYPE []
 SQLite keywords for the transaction types.

Detailed Description

Class handling SQLite transactions.

Definition at line 431 of file SQLiteDB.cpp.


Constructor & Destructor Documentation

SQLite::RealTransaction::RealTransaction ( const DB db,
Transaction::TransactionType  eType,
const std::tstring &  sName = _T("") 
) [inline]

Constructor from a database and type.

Parameters:
db Database wrapper of the database this transaction object belongs to
eType Type of the transaction
sName Name of the transaction (optional, and currenntly not used in SQLite)

Definition at line 441 of file SQLiteDB.cpp.

References m_bActive, and StartTransaction().


Member Function Documentation

bool SQLite::RealTransaction::Close (  ) 

Commit the transaction and end it.

Returns:
true if the transaction was closed successfully, false if failed

Definition at line 563 of file SQLiteDB.cpp.

References SQLite::DB::Execute(), IsValid(), m_bActive, m_db, and m_sName.

Referenced by SQLite::Transaction::Close(), and ~RealTransaction().

bool SQLite::RealTransaction::Commit (  )  [inline]

Commit the transaction, i.e., make the changes up to now permanent.

Returns:
true if commited successfully, false if failed

Definition at line 482 of file SQLiteDB.cpp.

References SQLite::DB::Execute(), SQLite::DB::GetLastError(), IsValid(), m_db, m_sLastError, and m_sName.

Referenced by SQLite::Transaction::Commit().

bool SQLite::RealTransaction::Execute ( Statement statement  )  [inline]

Runs a prepared SQL statement on the database (in the transaction).

Parameters:
statement Statement to perform
Returns:
true if the statement was performed successfully, false if failed

Definition at line 506 of file SQLiteDB.cpp.

References SQLite::Statement::Execute(), SQLite::Statement::GetDB(), IsValid(), and m_db.

bool SQLite::RealTransaction::Execute ( const std::tstring &  sSQL  )  [inline]

Runs an SQL action on the database (in the transaction).

Parameters:
sSQL SQL statement to perform
Returns:
true if the SQL statement was performed successfully, false if failed

Definition at line 500 of file SQLiteDB.cpp.

References SQLite::DB::Execute(), and m_db.

bool SQLite::RealTransaction::Execute ( LPCTSTR  pSQL  )  [inline]

Runs an SQL action on the database (in the transaction).

Parameters:
pSQL SQL statement to perform
Returns:
true if the SQL statement was performed successfully, false if failed

Definition at line 494 of file SQLiteDB.cpp.

References SQLite::DB::Execute(), SQLite::DB::GetLastError(), IsValid(), m_db, and m_sLastError.

Referenced by SQLite::Transaction::Execute().

const std::tstring& SQLite::RealTransaction::GetLastError (  )  const [inline]
Returns:
The description of the last error that occured while performing the transaction

Definition at line 472 of file SQLiteDB.cpp.

References m_sLastError.

Referenced by SQLite::Transaction::GetLastError().

bool SQLite::RealTransaction::IsValid (  )  const [inline]

Tests if the transaction is live (i.e., started).

Returns:
true if the transaction is live, false otherwise

Definition at line 468 of file SQLiteDB.cpp.

References m_bActive.

Referenced by Close(), Commit(), Execute(), Query(), Rollback(), and StartTransaction().

Recordset SQLite::RealTransaction::Query ( Statement statement  )  [inline]

Performs a prepared SQL query on the database (in the transaction).

Parameters:
statement The query to perform
Returns:
The results of the query (empty if there was an error)

Definition at line 524 of file SQLiteDB.cpp.

References SQLite::Statement::GetDB(), IsValid(), m_db, and SQLite::Statement::Query().

Recordset SQLite::RealTransaction::Query ( const std::tstring &  sSQL  )  [inline]

Performs an SQL query on the database (in the transaction).

Parameters:
sSQL SQL query to perform
Returns:
The results of the query (empty if there was an error)

Definition at line 518 of file SQLiteDB.cpp.

References IsValid(), m_db, and SQLite::DB::Query().

Recordset SQLite::RealTransaction::Query ( LPCTSTR  pSQL  )  [inline]

Performs an SQL query on the database (in the transaction).

Parameters:
pSQL SQL query to perform
Returns:
The results of the query (empty if there was an error)

Definition at line 512 of file SQLiteDB.cpp.

References SQLite::DB::GetLastError(), SQLite::Recordset::IsValid(), IsValid(), m_db, m_sLastError, and SQLite::DB::Query().

Referenced by SQLite::Transaction::Query().

bool SQLite::RealTransaction::Rollback (  )  [inline]

Roll back the changes the transaction performed in the database from the last commit.

Returns:
true if rolled back successfully, false if failed

Definition at line 487 of file SQLiteDB.cpp.

References SQLite::DB::Execute(), SQLite::DB::GetLastError(), IsValid(), m_bActive, m_db, m_sLastError, and m_sName.

Referenced by SQLite::Transaction::Rollback().

bool SQLite::RealTransaction::StartTransaction ( Transaction::TransactionType  eType  )  [protected]

Starts the transaction.

Parameters:
eType The type of the transaction to start
Returns:
true if the transaction was started successfully, false if failed to start

Definition at line 545 of file SQLiteDB.cpp.

References SQLite::DB::Execute(), IsValid(), m_bActive, m_db, m_sName, TRANSACTION_TYPE, and tstring.

Referenced by RealTransaction().


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

Generated on Mon Jun 18 12:52:58 2012 for Excel to PDF Converter by doxygen 1.6.1