SQLite::RealStatement Class Reference

Class handling the abstruction of SQLite prepared SQL statements. More...

Inherits SQLite::RefObj.

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

List of all members.

Public Member Functions

 RealStatement (const DB &db, LPCTSTR pStatement)
 Constructor from a database and SQL statement.
 ~RealStatement ()
 Destructor.
const DB GetDB () const
 Retrieves the database this statement is perpared for.
bool IsValid () const
 Tests if the statement is valid (prepared successfully).
const std::tstring & GetLastError () const
 Retrieves the description of the last error occured while preparing or performing the statement.
bool HasParameter (LPCTSTR pParam) const
 Tests if a parameter of the requested name exists in the statement.
bool BindParameter (LPCTSTR pParam, LPCTSTR pValue)
 Sets a parameter's value in the statement (by name).
bool BindParameter (LPCTSTR pParam, int nValue)
 Sets a parameter's value in the statement (by name).
bool BindParameter (int nParam, LPCTSTR pValue)
 Sets a parameter's value in the statement (by index).
bool BindParameter (int nParam, int nValue)
 Sets a parameter's value in the statement (by index).
bool Execute ()
 Executes the statement.
Recordset Query ()
 Runs the statement and returns the result set.
sqlite_int64 GetLastInsertRowid () const
 Retrieves the ID of the last row inserted by the statement.

Protected Member Functions

bool Reset ()
 Resets the statement (allowing it to run again).
int ParameterIndex (LPCTSTR pParam)
 Retrieves the index of a named parameter.

Protected Attributes

DB m_db
 Wrapper object of the database this statement belongs to.
std::tstring m_sLastError
 Description of the last error that occured while creating or running the statement.
sqlite3_stmt * m_pStatement
 Pointer to the internal SQLite statement structure.
bool m_bExecuted
 true while executing the statement, false after the statement is finished
sqlite_int64 m_nLastInsertRowid
 The ID of the last row inserted by the statement.

Detailed Description

Class handling the abstruction of SQLite prepared SQL statements.

Definition at line 585 of file SQLiteDB.cpp.


Constructor & Destructor Documentation

SQLite::RealStatement::RealStatement ( const DB db,
LPCTSTR  pStatement 
) [inline]

Constructor from a database and SQL statement.

Parameters:
db The database to prepare the statement for
pStatement The SQL statement to perpare

Definition at line 602 of file SQLiteDB.cpp.

References SQLite::RealDB::GetLastError(), SQLite::RealDB::GetSQLiteDB(), m_db, SQLite::DB::m_pDB, m_pStatement, m_sLastError, and MakeAnsiString().


Member Function Documentation

bool SQLite::RealStatement::BindParameter ( int  nParam,
int  nValue 
) [inline]

Sets a parameter's value in the statement (by index).

Parameters:
nParam The parameter's index
nValue The parameter's new value
Returns:
true if set successfully, false if failed

Definition at line 681 of file SQLiteDB.cpp.

References SQLite::DB::GetLastError(), IsValid(), m_bExecuted, m_db, m_pStatement, m_sLastError, and Reset().

bool SQLite::RealStatement::BindParameter ( int  nParam,
LPCTSTR  pValue 
) [inline]

Sets a parameter's value in the statement (by index).

Parameters:
nParam The parameter's index
pValue The parameter's new value
Returns:
true if set successfully, false if failed

Definition at line 674 of file SQLiteDB.cpp.

References SQLite::DB::GetLastError(), IsValid(), m_bExecuted, m_db, m_pStatement, m_sLastError, MakeAnsiString(), and Reset().

bool SQLite::RealStatement::BindParameter ( LPCTSTR  pParam,
int  nValue 
) [inline]

Sets a parameter's value in the statement (by name).

Parameters:
pParam The parameter's name
nValue The parameter's new value
Returns:
true if set successfully, false if failed

Definition at line 667 of file SQLiteDB.cpp.

References BindParameter(), and ParameterIndex().

Referenced by BindParameter().

bool SQLite::RealStatement::BindParameter ( LPCTSTR  pParam,
LPCTSTR  pValue 
) [inline]

Sets a parameter's value in the statement (by name).

Parameters:
pParam The parameter's name
pValue The parameter's new value
Returns:
true if set successfully, false if failed

Definition at line 660 of file SQLiteDB.cpp.

References BindParameter(), and ParameterIndex().

Referenced by SQLite::Statement::BindParameter(), and BindParameter().

bool SQLite::RealStatement::Execute (  )  [inline]

Executes the statement.

Returns:
true if the statement was performed successfully, false if failed

Definition at line 687 of file SQLiteDB.cpp.

References SQLite::DB::GetLastError(), SQLite::DB::GetLastInsertRowid(), IsValid(), m_bExecuted, m_db, m_nLastInsertRowid, m_pStatement, and m_sLastError.

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

const DB SQLite::RealStatement::GetDB (  )  const [inline]

Retrieves the database this statement is perpared for.

Returns:
A database wrapper object for the requested database

Definition at line 634 of file SQLiteDB.cpp.

References m_db.

Referenced by SQLite::Statement::GetDB().

const std::tstring& SQLite::RealStatement::GetLastError (  )  const [inline]

Retrieves the description of the last error occured while preparing or performing the statement.

Returns:
The description of the last error

Definition at line 644 of file SQLiteDB.cpp.

References m_sLastError.

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

sqlite_int64 SQLite::RealStatement::GetLastInsertRowid (  )  const [inline]

Retrieves the ID of the last row inserted by the statement.

Returns:
The ID of the last row inserted by the statement

Definition at line 697 of file SQLiteDB.cpp.

References IsValid(), and m_nLastInsertRowid.

Referenced by SQLite::Statement::GetLastInsertRowid().

bool SQLite::RealStatement::HasParameter ( LPCTSTR  pParam  )  const [inline]

Tests if a parameter of the requested name exists in the statement.

Parameters:
pParam The name of the parameter to check
Returns:
true if the statement contains this named parameter, false if not

Definition at line 650 of file SQLiteDB.cpp.

References IsValid(), m_pStatement, and MakeAnsiString().

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

Tests if the statement is valid (prepared successfully).

Returns:
true if the statement is valid, false otherwise

Definition at line 639 of file SQLiteDB.cpp.

References m_pStatement.

Referenced by BindParameter(), Execute(), GetLastInsertRowid(), HasParameter(), SQLite::Statement::IsValid(), ParameterIndex(), and Query().

int SQLite::RealStatement::ParameterIndex ( LPCTSTR  pParam  )  [inline, protected]

Retrieves the index of a named parameter.

Parameters:
pParam The parameter to find
Returns:
The 1-based index of the named parameter (0 if not found)

Definition at line 711 of file SQLiteDB.cpp.

References IsValid(), m_pStatement, and MakeAnsiString().

Referenced by BindParameter().

Recordset SQLite::RealStatement::Query (  ) 

Runs the statement and returns the result set.

Returns:
The record set that is the result of the query statement

Definition at line 717 of file SQLiteDB.cpp.

References IsValid(), and m_nLastInsertRowid.

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

bool SQLite::RealStatement::Reset (  )  [inline, protected]

Resets the statement (allowing it to run again).

Returns:
true if the statement was reset successfully, false if failed for some reason

Definition at line 705 of file SQLiteDB.cpp.

References SQLite::DB::GetLastError(), m_bExecuted, m_db, m_pStatement, and m_sLastError.

Referenced by BindParameter(), and SQLite::Realset::Realset().


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

Generated on Mon Jun 18 12:40:51 2012 for CC PDF Converter by doxygen 1.6.1