Version: 1.0.0
sqlite_preparedstatement.h
Go to the documentation of this file.
1 #ifndef _WX_DATABASE_SQLITE_PREPARED_STATEMENT_H_
2 #define _WX_DATABASE_SQLITE_PREPARED_STATEMENT_H_
3 
4 #include "wx/database/wxprec.h"
5 
6 WX_DEFINE_ARRAY_PTR(sqlite3_stmt*, wxSqliteStatementVector);
7 
9 
11 {
12 public:
13  // ctor
14  wxSqlitePreparedStatement(sqlite3* pDatabase);
15  wxSqlitePreparedStatement(sqlite3* pDatabase, sqlite3_stmt* pStatement);
16  wxSqlitePreparedStatement(sqlite3* pDatabase, wxSqliteStatementVector statements);
17 
18  // dtor
20 
21  virtual void Close();
22 
23  void AddPreparedStatement(sqlite3_stmt* pStatement);
24 
25  // get field
26  virtual void SetParamInt(int nPosition, int nValue);
27  virtual void SetParamDouble(int nPosition, double dblValue);
28  virtual void SetParamString(int nPosition, const wxString& strValue);
29  virtual void SetParamNull(int nPosition);
30  virtual void SetParamBlob(int nPosition, const void* pData, long nDataLength);
31  virtual void SetParamDate(int nPosition, const wxDateTime& dateValue);
32  virtual void SetParamBool(int nPosition, bool bValue);
33  virtual int GetParameterCount();
34 
35  virtual int RunQuery();
37 
38  sqlite3_stmt* GetLastStatement() { return (m_Statements.size() > 0) ? m_Statements[m_Statements.size()-1] : NULL; }
39 
40 private:
41  int FindStatementAndAdjustPositionIndex(int* pPosition);
42 
43  sqlite3* m_pDatabase; // Database pointer needed for error messages
44  wxSqliteStatementVector m_Statements;
45 };
46 
47 #endif//_WX_DATABASE_SQLITE_PREPARED_STATEMENT_H_
48 
virtual void SetParamDouble(int nPosition, double dblValue)
Set the parameter at the 1-based position to a double value.
virtual ~wxSqlitePreparedStatement()
virtual void SetParamBlob(int nPosition, const void *pData, long nDataLength)
Set the parameter at the 1-based position to a Blob value.
virtual void SetParamNull(int nPosition)
Set the parameter at the 1-based position to a NULL value.
virtual void SetParamDate(int nPosition, const wxDateTime &dateValue)
Set the parameter at the 1-based position to a wxDateTime value.
virtual int GetParameterCount()
wxSqlitePreparedStatement(sqlite3 *pDatabase)
virtual void SetParamString(int nPosition, const wxString &strValue)
Set the parameter at the 1-based position to a wxString value.
virtual void Close()
Close the result set (call wxDatabase::ClosePreparedStatement() instead on the statement)
wxSqliteStatementVector m_Statements
virtual void SetParamBool(int nPosition, bool bValue)
Set the parameter at the 1-based position to a boolean value.
void AddPreparedStatement(sqlite3_stmt *pStatement)
virtual int RunQuery()
Run an insert, update, or delete query on the database.
int FindStatementAndAdjustPositionIndex(int *pPosition)
virtual void SetParamInt(int nPosition, int nValue)
Set the parameter at the 1-based position to an int value.
virtual wxDatabaseResultSet * RunQueryWithResults()
Run an insert, update, or delete query on the database.
WX_DEFINE_ARRAY_PTR(sqlite3_stmt *, wxSqliteStatementVector)