Version: 1.0.0
wxOdbcDatabase Class Reference

#include <odbc_database.h>

+ Inheritance diagram for wxOdbcDatabase:

Detailed Description

Definition at line 12 of file odbc_database.h.

Public Member Functions

 wxOdbcDatabase ()
 
virtual ~wxOdbcDatabase ()
 
virtual bool Open ()
 
virtual bool Open (const wxString &strConnection)
 
virtual bool Open (const wxString &strDSN, const wxString &strUser, const wxString &strPassword)
 
virtual bool Close ()
 close database More...
 
virtual bool IsOpen ()
 Is the connection to the database open? More...
 
virtual void BeginTransaction ()
 Begin a transaction. More...
 
virtual void Commit ()
 Commit the current transaction. More...
 
virtual void RollBack ()
 Rollback the current transaction. More...
 
virtual int RunQuery (const wxString &strQuery, bool bParseQuery)
 Run an insert, update, or delete query on the database. More...
 
virtual wxDatabaseResultSetRunQueryWithResults (const wxString &strQuery)
 Run a select query on the database. More...
 
virtual wxPreparedStatementPrepareStatement (const wxString &strQuery)
 Prepare a SQL statement which can be reused with different parameters. More...
 
virtual bool TableExists (const wxString &table)
 Check for the existence of a table by name. More...
 
virtual bool ViewExists (const wxString &view)
 Check for the existence of a view by name. More...
 
virtual wxArrayString GetTables ()
 Retrieve all table names. More...
 
virtual wxArrayString GetViews ()
 Retrieve all view names. More...
 
virtual wxArrayString GetColumns (const wxString &table)
 Retrieve all column names for a table. More...
 
virtual wxArrayString GetPKColumns (const wxString &table)
 get Primary keys column names More...
 
void InterpretErrorCodes (long nCode, void *stmth_ptr=NULL)
 
void * allocStmth ()
 
- Public Member Functions inherited from wxDatabase
 wxDatabase ()
 Constructor. More...
 
virtual ~wxDatabase ()
 Destructor. More...
 
virtual bool ChangeDatabase (const wxString &database)
 
virtual int RunQuery (const wxString &strQuery)
 Run an insert, update, or delete query on the database. More...
 
virtual bool CloseResultSet (wxDatabaseResultSet *pResultSet)
 Close a result set returned by the database or a prepared statement previously. More...
 
virtual bool CloseStatement (wxPreparedStatement *pStatement)
 Close a prepared statement previously prepared by the database. More...
 
int ExecuteUpdate (const wxString &strQuery)
 See RunQuery. More...
 
wxDatabaseResultSetExecuteQuery (const wxString &strQuery)
 See RunQueryWithResults. More...
 
virtual int GetSingleResultInt (const wxString &strSQL, int nField, bool bRequireUniqueResult=true)
 With the GetSingleResultX API, two additional exception types are thrown: wxDATABASE_NO_ROWS_FOUND - No database rows were returned wxDATABASE_NON_UNIQUE_RESULTSET - More than one database row was returned. More...
 
virtual int GetSingleResultInt (const wxString &strSQL, const wxString &strField, bool bRequireUniqueResult=true)
 
virtual wxString GetSingleResultString (const wxString &strSQL, int nField, bool bRequireUniqueResult=true)
 Retrieve a single string value from a query If multiple records are returned from the query, a wxDATABASE_NON_UNIQUE_RESULTSET exception is thrown unless bRequireUniqueResult is false. More...
 
virtual wxString GetSingleResultString (const wxString &strSQL, const wxString &strField, bool bRequireUniqueResult=true)
 
virtual long GetSingleResultLong (const wxString &strSQL, int nField, bool bRequireUniqueResult=true)
 Retrieve a single long value from a query If multiple records are returned from the query, a wxDATABASE_NON_UNIQUE_RESULTSET exception is thrown unless bRequireUniqueResult is false. More...
 
virtual long GetSingleResultLong (const wxString &strSQL, const wxString &strField, bool bRequireUniqueResult=true)
 
virtual bool GetSingleResultBool (const wxString &strSQL, int nField, bool bRequireUniqueResult=true)
 Retrieve a single bool value from a query If multiple records are returned from the query, a wxDATABASE_NON_UNIQUE_RESULTSET exception is thrown unless bRequireUniqueResult is false. More...
 
virtual bool GetSingleResultBool (const wxString &strSQL, const wxString &strField, bool bRequireUniqueResult=true)
 
virtual wxDateTime GetSingleResultDate (const wxString &strSQL, int nField, bool bRequireUniqueResult=true)
 Retrieve a single date/time value from a query If multiple records are returned from the query, a wxDATABASE_NON_UNIQUE_RESULTSET exception is thrown unless bRequireUniqueResult is false. More...
 
virtual wxDateTime GetSingleResultDate (const wxString &strSQL, const wxString &strField, bool bRequireUniqueResult=true)
 
virtual void * GetSingleResultBlob (const wxString &strSQL, int nField, wxMemoryBuffer &Buffer, bool bRequireUniqueResult=true)
 Retrieve a single Blob value from a query If multiple records are returned from the query, a wxDATABASE_NON_UNIQUE_RESULTSET exception is thrown unless bRequireUniqueResult is false. More...
 
virtual void * GetSingleResultBlob (const wxString &strSQL, const wxString &strField, wxMemoryBuffer &Buffer, bool bRequireUniqueResult=true)
 
virtual double GetSingleResultDouble (const wxString &strSQL, int nField, bool bRequireUniqueResult=true)
 Retrieve a single double value from a query If multiple records are returned from the query, a wxDATABASE_NON_UNIQUE_RESULTSET exception is thrown unless bRequireUniqueResult is false. More...
 
virtual double GetSingleResultDouble (const wxString &strSQL, const wxString &strField, bool bRequireUniqueResult=true)
 
virtual wxArrayInt GetResultsArrayInt (const wxString &strSQL, int nField)
 Retrieve all the values of one field in a result set. More...
 
virtual wxArrayInt GetResultsArrayInt (const wxString &strSQL, const wxString &Field)
 
virtual wxArrayString GetResultsArrayString (const wxString &strSQL, int nField)
 
virtual wxArrayString GetResultsArrayString (const wxString &strSQL, const wxString &Field)
 
virtual wxArrayLong GetResultsArrayLong (const wxString &strSQL, int nField)
 
virtual wxArrayLong GetResultsArrayLong (const wxString &strSQL, const wxString &Field)
 
virtual wxArrayDouble GetResultsArrayDouble (const wxString &strSQL, int nField)
 
virtual wxArrayDouble GetResultsArrayDouble (const wxString &strSQL, const wxString &Field)
 
void CloseResultSets ()
 Close all result set objects that have been generated but not yet closed. More...
 
void CloseStatements ()
 Close all prepared statement objects that have been generated but not yet closed. More...
 
const wxString & GetTypeName ()
 Get a descriptive name for the type of database. More...
 
bool IsViaODBC ()
 Is the connection via ODBC. More...
 
const wxString & GetLibraryPath ()
 Get the library path required by the database. More...
 
- Public Member Functions inherited from wxDatabaseErrorReporter
 wxDatabaseErrorReporter ()
 
virtual ~wxDatabaseErrorReporter ()
 
const wxString & GetErrorMessage ()
 
int GetErrorCode ()
 
void ResetErrorCodes ()
 
- Public Member Functions inherited from wxDatabaseStringConverter
 wxDatabaseStringConverter ()
 
 wxDatabaseStringConverter (const wxChar *charset)
 
virtual ~wxDatabaseStringConverter ()
 
void SetEncoding (wxFontEncoding encoding)
 
void SetEncoding (const wxCSConv *conv)
 
const wxCSConv * GetEncoding ()
 
virtual const wxCharBuffer ConvertToUnicodeStream (const wxString &inputString)
 
virtual size_t GetEncodedStreamLength (const wxString &inputString)
 
virtual wxString ConvertFromUnicodeStream (const char *inputBuffer)
 
virtual wxString ConvertFromUnicodeStream (const wxChar *inputBuffer)
 

Static Public Member Functions

static bool IsAvailable ()
 
- Static Public Member Functions inherited from wxDatabase
static wxDatabaseGetDatabase (wxConfigBase &config, wxString *err=NULL, const wxString &path="/")
 Get an instance of the first valid database specified in config. More...
 
- Static Public Member Functions inherited from wxDatabaseStringConverter
static const wxCharBuffer ConvertToUnicodeStream (const wxString &inputString, const char *encoding)
 
static wxString ConvertFromUnicodeStream (const char *inputBuffer, const char *encoding)
 
static size_t GetEncodedStreamLength (const wxString &inputString, const char *encoding)
 
static wxString ConvertFromUnicodeStream (const wxChar *inputBuffer, const char *encoding)
 

Private Member Functions

virtual wxPreparedStatementPrepareStatement (const wxString &strQuery, bool bParseQuery)
 

Private Attributes

void * m_sqlEnvHandle
 
void * m_sqlHDBC
 
wxString m_strDSN
 
wxString m_strUser
 
wxString m_strPassword
 
wxString m_strConnection
 
bool m_bIsConnected
 
wxOdbcInterfacem_pInterface
 

Additional Inherited Members

- Protected Member Functions inherited from wxDatabase
void LogResultSetForCleanup (wxDatabaseResultSet *pResultSet)
 Add result set object pointer to the list for "garbage collection". More...
 
void LogStatementForCleanup (wxPreparedStatement *pStatement)
 Add prepared statement object pointer to the list for "garbage collection". More...
 
- Protected Member Functions inherited from wxDatabaseErrorReporter
void SetErrorMessage (const wxString &strErrorMessage)
 
void SetErrorCode (int nErrorCode)
 
void ThrowDatabaseException ()
 

Constructor & Destructor Documentation

◆ wxOdbcDatabase()

wxOdbcDatabase::wxOdbcDatabase ( )

◆ ~wxOdbcDatabase()

virtual wxOdbcDatabase::~wxOdbcDatabase ( )
virtual

Member Function Documentation

◆ allocStmth()

void* wxOdbcDatabase::allocStmth ( )

◆ BeginTransaction()

virtual void wxOdbcDatabase::BeginTransaction ( )
virtual

Begin a transaction.

Implements wxDatabase.

◆ Close()

virtual bool wxOdbcDatabase::Close ( )
virtual

close database

Implements wxDatabase.

◆ Commit()

virtual void wxOdbcDatabase::Commit ( )
virtual

Commit the current transaction.

Implements wxDatabase.

◆ GetColumns()

virtual wxArrayString wxOdbcDatabase::GetColumns ( const wxString &  table)
virtual

Retrieve all column names for a table.

Implements wxDatabase.

◆ GetPKColumns()

virtual wxArrayString wxOdbcDatabase::GetPKColumns ( const wxString &  table)
virtual

get Primary keys column names

Implements wxDatabase.

◆ GetTables()

virtual wxArrayString wxOdbcDatabase::GetTables ( )
virtual

Retrieve all table names.

Implements wxDatabase.

◆ GetViews()

virtual wxArrayString wxOdbcDatabase::GetViews ( )
virtual

Retrieve all view names.

Implements wxDatabase.

◆ InterpretErrorCodes()

void wxOdbcDatabase::InterpretErrorCodes ( long  nCode,
void *  stmth_ptr = NULL 
)

◆ IsAvailable()

static bool wxOdbcDatabase::IsAvailable ( )
static

◆ IsOpen()

virtual bool wxOdbcDatabase::IsOpen ( )
virtual

Is the connection to the database open?

Implements wxDatabase.

◆ Open() [1/3]

virtual bool wxOdbcDatabase::Open ( )
virtual

◆ Open() [2/3]

virtual bool wxOdbcDatabase::Open ( const wxString &  strConnection)
virtual

Implements wxDatabase.

◆ Open() [3/3]

virtual bool wxOdbcDatabase::Open ( const wxString &  strDSN,
const wxString &  strUser,
const wxString &  strPassword 
)
virtual

◆ PrepareStatement() [1/2]

virtual wxPreparedStatement* wxOdbcDatabase::PrepareStatement ( const wxString &  strQuery)
virtual

Prepare a SQL statement which can be reused with different parameters.

Implements wxDatabase.

◆ PrepareStatement() [2/2]

virtual wxPreparedStatement* wxOdbcDatabase::PrepareStatement ( const wxString &  strQuery,
bool  bParseQuery 
)
privatevirtual

◆ RollBack()

virtual void wxOdbcDatabase::RollBack ( )
virtual

Rollback the current transaction.

Implements wxDatabase.

◆ RunQuery()

virtual int wxOdbcDatabase::RunQuery ( const wxString &  strQuery,
bool  bParseQueries 
)
virtual

Run an insert, update, or delete query on the database.

Implements wxDatabase.

◆ RunQueryWithResults()

virtual wxDatabaseResultSet* wxOdbcDatabase::RunQueryWithResults ( const wxString &  strQuery)
virtual

Run a select query on the database.

Implements wxDatabase.

◆ TableExists()

virtual bool wxOdbcDatabase::TableExists ( const wxString &  table)
virtual

Check for the existence of a table by name.

Implements wxDatabase.

◆ ViewExists()

virtual bool wxOdbcDatabase::ViewExists ( const wxString &  view)
virtual

Check for the existence of a view by name.

Implements wxDatabase.

Member Data Documentation

◆ m_bIsConnected

bool wxOdbcDatabase::m_bIsConnected
private

Definition at line 75 of file odbc_database.h.

◆ m_pInterface

wxOdbcInterface* wxOdbcDatabase::m_pInterface
private

Definition at line 76 of file odbc_database.h.

◆ m_sqlEnvHandle

void* wxOdbcDatabase::m_sqlEnvHandle
private

Definition at line 61 of file odbc_database.h.

◆ m_sqlHDBC

void* wxOdbcDatabase::m_sqlHDBC
private

Definition at line 63 of file odbc_database.h.

◆ m_strConnection

wxString wxOdbcDatabase::m_strConnection
private

Definition at line 69 of file odbc_database.h.

◆ m_strDSN

wxString wxOdbcDatabase::m_strDSN
private

Definition at line 65 of file odbc_database.h.

◆ m_strPassword

wxString wxOdbcDatabase::m_strPassword
private

Definition at line 67 of file odbc_database.h.

◆ m_strUser

wxString wxOdbcDatabase::m_strUser
private

Definition at line 66 of file odbc_database.h.