Version: 1.0.0
odbc_preparedstatement.h
Go to the documentation of this file.
1 #ifndef _WX_DATABASE_ODBC_PREPARED_STATEMENT_H_
2 #define _WX_DATABASE_ODBC_PREPARED_STATEMENT_H_
3 
4 #include "wx/database/wxprec.h"
5 
6 WX_DEFINE_ARRAY_PTR(SQLHSTMT, wxOdbcStatementVector);
7 WX_DEFINE_ARRAY_PTR(wxOdbcParameter*, ArrayOfOdbcParameters);
8 
10 
12 {
13 public:
14  // ctor
15  wxOdbcPreparedStatement(wxOdbcInterface* pInterface, SQLHENV sqlEnvHandle, SQLHDBC sqlHDBC);
16  wxOdbcPreparedStatement(wxOdbcInterface* pInterface, SQLHENV sqlEnvHandle, SQLHDBC sqlHDBC, SQLHSTMT sqlStatementHandle);
17  wxOdbcPreparedStatement(wxOdbcInterface* pInterface, SQLHENV sqlEnvHandle, SQLHDBC sqlHDBC, wxOdbcStatementVector statements);
18 
19  // dtor
20  virtual ~wxOdbcPreparedStatement();
21 
22  virtual void Close();
23 
24  void AddPreparedStatement(SQLHSTMT pStatement);
25 
26  // get field
27  virtual void SetParamInt(int nPosition, int nValue);
28  virtual void SetParamDouble(int nPosition, double dblValue);
29  virtual void SetParamString(int nPosition, const wxString& strValue);
30  virtual void SetParamNull(int nPosition);
31  virtual void SetParamBlob(int nPosition, const void* pData, long nDataLength);
32  virtual void SetParamDate(int nPosition, const wxDateTime& dateValue);
33  virtual void SetParamBool(int nPosition, bool bValue);
34  virtual int GetParameterCount();
35 
36  virtual int RunQuery();
38  virtual wxDatabaseResultSet* RunQueryWithResults(bool bLogForCleanup);
39 
40  SQLHSTMT GetLastStatement() { return (m_Statements.size() > 0) ? m_Statements[m_Statements.size()-1] : NULL; }
41  void SetOneTimer(bool bOneTimer = true) { m_bOneTimeStatement = bOneTimer; }
42 
43 private:
44  void InterpretErrorCodes( long nCode, SQLHSTMT stmth_ptr=NULL );
45  void FreeParameters();
46  void BindParameters();
47  void SetParam(int nPosition, wxOdbcParameter* pParameter);
48 
49 
50  int FindStatementAndAdjustPositionIndex(int* pPosition);
51 
52  bool m_bOneTimeStatement; // Flag to indicate that statement ownership should be handed off to any generated OdbcResultSets
53  SQLHENV m_sqlEnvHandle;
54  SQLHDBC m_sqlHDBC;
55  wxOdbcStatementVector m_Statements;
56 
57  ArrayOfOdbcParameters m_Parameters;
59 };
60 
61 #endif//_WX_DATABASE_ODBC_PREPARED_STATEMENT_H_
62 
virtual void SetParamBool(int nPosition, bool bValue)
Set the parameter at the 1-based position to a boolean value.
virtual int RunQuery()
Run an insert, update, or delete query on the database.
wxOdbcStatementVector m_Statements
virtual wxDatabaseResultSet * RunQueryWithResults()
Run an insert, update, or delete query on the database.
virtual void SetParamBlob(int nPosition, const void *pData, long nDataLength)
Set the parameter at the 1-based position to a Blob value.
int FindStatementAndAdjustPositionIndex(int *pPosition)
virtual ~wxOdbcPreparedStatement()
virtual void Close()
Close the result set (call wxDatabase::ClosePreparedStatement() instead on the statement)
void AddPreparedStatement(SQLHSTMT pStatement)
WX_DEFINE_ARRAY_PTR(SQLHSTMT, wxOdbcStatementVector)
void SetOneTimer(bool bOneTimer=true)
virtual void SetParamInt(int nPosition, int nValue)
Set the parameter at the 1-based position to an int value.
virtual void SetParamString(int nPosition, const wxString &strValue)
Set the parameter at the 1-based position to a wxString value.
wxOdbcPreparedStatement(wxOdbcInterface *pInterface, SQLHENV sqlEnvHandle, SQLHDBC sqlHDBC)
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.
void SetParam(int nPosition, wxOdbcParameter *pParameter)
void InterpretErrorCodes(long nCode, SQLHSTMT stmth_ptr=NULL)
virtual void SetParamDouble(int nPosition, double dblValue)
Set the parameter at the 1-based position to a double value.
ArrayOfOdbcParameters m_Parameters
virtual int GetParameterCount()