Class handling the abstruction of SQLite prepared SQL statements. More...
Inherits SQLite::RefObj.
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. |
Class handling the abstruction of SQLite prepared SQL statements.
Definition at line 585 of file SQLiteDB.cpp.
SQLite::RealStatement::RealStatement | ( | const DB & | db, | |
LPCTSTR | pStatement | |||
) | [inline] |
Constructor from a database and SQL statement.
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().
bool SQLite::RealStatement::BindParameter | ( | int | nParam, | |
int | nValue | |||
) | [inline] |
Sets a parameter's value in the statement (by index).
nParam | The parameter's index | |
nValue | The parameter's new value |
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).
nParam | The parameter's index | |
pValue | The parameter's new value |
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).
pParam | The parameter's name | |
nValue | The parameter's new value |
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).
pParam | The parameter's name | |
pValue | The parameter's new value |
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.
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.
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.
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.
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.
pParam | The name of the parameter to check |
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).
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.
pParam | The parameter to find |
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.
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).
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().