## wxDbTable

A wxDbTable instance provides re-usable access to rows of data in a table contained within the associated ODBC data source

Include files

<wx/dbtable.h>
<wx/db.h>

Members Helper classes and data structures

The following classes and structs are defined in dbtable.cpp/.h for use with the wxDbTable class.

        class wxDbColDef     : Bound column definitions for use by a wxDbTable
                               instance

        class wxDbColDataPtr : Pointer to dynamic column definitions for use with
                               a wxDbTable instance

        class wxDbIdxDef     : Used in creation of non-primary indexes

Constants

        wxDB_DEFAULT_CURSOR     Index number of the cursor that each table will use
                                by default.

        wxDB_QUERY_ONLY         Used to indicate whether a table that is opened is
                                for query only, or if insert/update/deletes will
                                be performed on the table.  Less overhead (cursors
                                and memory) are allocated for query only tables, plus
                                read access times are faster with some datasources.

        wxDB_ROWID_LEN          [Oracle specific] - Used when CanUpdateByRowID() is
                                true.  Optimizes updates so they are faster by
                                updating on the Oracle-specific ROWID column rather
                                than some other index.

        wxDB_DISABLE_VIEW       Use to indicate when a database view should not be
                                if a table is normally set up to use a view.
                                [Currently unsupported.]

Remarks

See also

wxDbTable

Members

wxDbTable::wxDbTable
wxDbTable::wxDbTable
wxDbTable::BuildDeleteStmt
wxDbTable::BuildSelectStmt
wxDbTable::BuildUpdateStmt
wxDbTable::BuildWhereStmt
wxDbTable::CanSelectForUpdate
wxDbTable::CanUpdateByROWID
wxDbTable::ClearMemberVars
wxDbTable::CloseCursor
wxDbTable::Count
wxDbTable::CreateIndex
wxDbTable::CreateTable
wxDbTable::DB_STATUS
wxDbTable::IsColNull
wxDbTable::Delete
wxDbTable::DeleteCursor
wxDbTable::DeleteWhere
wxDbTable::DeleteMatching
wxDbTable::DropIndex
wxDbTable::DropTable
wxDbTable::GetColDefs
wxDbTable::GetCursor
wxDbTable::GetDb
wxDbTable::GetFirst
wxDbTable::GetFromClause
wxDbTable::GetLast
wxDbTable::GetNewCursor
wxDbTable::GetNext
wxDbTable::GetNumberOfColumns
wxDbTable::GetOrderByClause
wxDbTable::GetPrev
wxDbTable::GetQueryTableName
wxDbTable::GetRowNum
wxDbTable::GetTableName
wxDbTable::GetTablePath
wxDbTable::GetWhereClause
wxDbTable::Insert
wxDbTable::IsCursorClosedOnCommit
wxDbTable::IsQueryOnly
wxDbTable::Open
wxDbTable::Query
wxDbTable::QueryBySqlStmt
wxDbTable::QueryMatching
wxDbTable::QueryOnKeyFields
wxDbTable::Refresh
wxDbTable::SetColDefs
wxDbTable::SetCursor
wxDbTable::SetFromClause
wxDbTable::SetNull
wxDbTable::SetOrderByClause
wxDbTable::SetQueryTimeout
wxDbTable::SetWhereClause
wxDbTable::Update
wxDbTable::UpdateWhere
wxDbTable::operator ++
wxDbTable::operator --

### wxDbTable::wxDbTable

wxDbTable(wxDb *pwxDb, const char *tblName, const int nCols,const char *qryTblName = 0, boolqryOnly = !wxDB_QUERY_ONLY,const char *tblPath=NULL)

Default constructor.

Parameters

pSqlStmt

typeOfDel

pWhereClause

Default is 0.

### wxDbTable::wxDbTable

virtual ~wxDbTable()

Virtual default destructor.

### wxDbTable::BuildDeleteStmt

void BuildSelectStmt(char *pSqlStmt, int typeOfDel, const char *pWhereClause=0)

Parameters

pSqlStmt

typeOfDel

pWhereClause

Default is 0.

### wxDbTable::BuildSelectStmt

void BuildSelectStmt(char *pSqlStmt, int typeOfSelect, bool distinct)

Parameters

pSqlStmt

typeOfSelect

distinct

### wxDbTable::BuildUpdateStmt

void BuildSelectStmt(char *pSqlStmt, int typeOfUpd, const char *pWhereClause=0)

Parameters

pSqlStmt

typeOfUpd

pWhereClause

Default is 0.

### wxDbTable::BuildWhereStmt

void BuildSelectStmt(char *pWhereClause, int typeOfWhere, const char *qualTableName=0, const char *useLikeComparison=FALSE)

Parameters

pWhereClause

typeOfWhere

qualTableName

Default is 0.

useLikeComparison

Default is FALSE.

### wxDbTable::CanSelectForUpdate

bool CanSelectForUpdate()

Remarks

### wxDbTable::CanUpdateByROWID

bool CanUpdateByROWID()

Remarks

### wxDbTable::ClearMemberVars

void ClearMemberVars()

Remarks

### wxDbTable::CloseCursor

bool CloseCursor(HSTMTcursor)

Parameters

cursor

Remarks

### wxDbTable::Count

ULONG Count(const char *args="*")

Parameters

args

Default is "*".

Remarks

### wxDbTable::CreateIndex

bool CreateIndex(const char *idxName, boolunique, int noIdxCols, wxDbIdxDef *pIdxDefs, bool attemptDrop=TRUE)

Parameters

idxName

unique

noIdxCols

pIdxDefs

attemptDrop

Default is TRUE.

Remarks

### wxDbTable::CreateTable

bool CreateTable(bool attemptDrop=TRUE)

Parameters

attemptDrop

Default is TRUE.

Remarks

### wxDbTable::DB_STATUS

bool DB_STATUS()

Accessor function for the private member variable DB_STATUS.

### wxDbTable::IsColNull

bool IsColNull(int colNo)

Parameters

colNo

Remarks

### wxDbTable::Delete

bool Delete()

Remarks

### wxDbTable::DeleteCursor

bool DeleteCursor(HSTMT hstmtDel)

Parameters

hstmtDel

Remarks

### wxDbTable::DeleteWhere

bool DeleteWhere(const char *pWhereClause)

Parameters

pWhereClause

Remarks

### wxDbTable::DeleteMatching

bool DeleteMatching()

Remarks

### wxDbTable::DropIndex

bool DropIndex(const char *idxName)

Parameters

idxName

Remarks

### wxDbTable::DropTable

bool DropTable()

Remarks

### wxDbTable::GetColDefs

wxDbColDef * GetColDefs()

Remarks

### wxDbTable::GetCursor

HSTMT GetCursor()

Remarks

### wxDbTable::GetDb

wxDb * GetDb()

Accessor function for the private member variable pDb which is a pointer to the datasource connection that this wxDbTable instance uses.

Remarks

### wxDbTable::GetFirst

bool GetFirst()

Remarks

This function can only be used if the datasource connection used by the wxDbTable instance was created with FwdOnlyCursors set to FALSE. If the connection does not allow backward scrolling cursors, this function will return FALSE, and the data contained in the bound columns will be undefined.

See also

wxDb::FwdOnlyCursors

### wxDbTable::GetFromClause

const char * GetFromClause()

Accessor function that returns the current FROM setting assigned with the wxDbTable::SetFromClause.

### wxDbTable::GetLast

bool GetLast()

Remarks

This function can only be used if the datasource connection used by the wxDbTable instance was created with FwdOnlyCursors set to FALSE. If the connection does not allow backward scrolling cursors, this function will return FALSE, and the data contained in the bound columns will be undefined.

See also

wxDb::FwdOnlyCursors

### wxDbTable::GetNewCursor

HSTMT * GetNewCursor(bool setCursor=FALSE, bool bindColumns=TRUE)

Parameters

setCursor

Default is FALSE.

bindColumns

Default is TRUE.

Remarks

### wxDbTable::GetNext

bool GetNext()

Remarks

### wxDbTable::GetNumberOfColumns

bool GetNumberOfColumns()

Accessor function that returns the number of columns that are statically bound for access by the wxDbTable instance.

### wxDbTable::GetOrderByClause

const char * GetOrderByClause()

Accessor function that returns the current ORDER BY setting assigned with the wxDbTable::SetOrderByClause.

### wxDbTable::GetPrev

bool GetPrev()

Remarks

This function can only be used if the datasource connection used by the wxDbTable instance was created with FwdOnlyCursors set to FALSE. If the connection does not allow backward scrolling cursors, this function will return FALSE, and the data contained in the bound columns will be undefined.

See also

wxDb::FwdOnlyCursors

### wxDbTable::GetQueryTableName

const char * GetQueryTableName()

Remarks

### wxDbTable::GetRowNum

UWORD GetRowNum()

Remarks

### wxDbTable::GetTableName

const char * GetTableName()

Remarks

### wxDbTable::GetTablePath

const char * GetTablePath()

Remarks

### wxDbTable::GetWhereClause

const char * GetWhereClause()

Accessor function that returns the current WHERE setting assigned with the wxDbTable::SetWhereClause

### wxDbTable::Insert

int Insert()

Remarks

### wxDbTable::IsCursorClosedOnCommit

bool IsCursorClosedOnCommit()

Remarks

### wxDbTable::IsQueryOnly

bool IsQueryOnly()

Accessor function that returns a value indicating if this wxDbTable instance was created to allow only queries to be performed on the bound columns. If this function returns TRUE, then no actions may be performed using this wxDbTable instance that would modify (insert/delete/update) the table's data.

### wxDbTable::Open

bool Open()

Remarks

### wxDbTable::Query

virtual bool Query(boolforUpdate=FALSE, booldistinct=FALSE)

Parameters

forUpdate

Default is FALSE.

distinct

Default is FALSE.

Remarks

### wxDbTable::QueryBySqlStmt

bool QueryBySqlStmt(const char *pSqlStmt)

Parameters

pSqlStmt

Remarks

### wxDbTable::QueryMatching

virtual bool QueryMatching(boolforUpdate=FALSE, booldistinct=FALSE)

Parameters

forUpdate

Default is FALSE.

distinct

Default is FALSE.

Remarks

### wxDbTable::QueryOnKeyFields

bool QueryOnKeyFields(boolforUpdate=FALSE, booldistinct=FALSE)

Parameters

forUpdate

Default is FALSE.

distinct

Default is FALSE.

Remarks

### wxDbTable::Refresh

bool Refresh()

Remarks

### wxDbTable::SetColDefs

void SetColDefs(int index, const char *fieldName, int dataType, void *pData, int cType, int size, bool keyField = FALSE, bool upd = TRUE, bool insAllow = TRUE, bool derivedCol = FALSE)

wxDbColDataPtr * SetColDefs(wxDbColInf *colInfs, ULONG numCols)

Parameters

index

fieldName

dataType

pData

cType

size

keyField

Default is FALSE.

upd

Default is TRUE.

insAllow

Default is TRUE.

derivedCol

Default is FALSE.

colInfs

numCols

Remarks

### wxDbTable::SetCursor

bool Open(HSTMT *hstmtActivate = (void **) wxDB_DEFAULT_CURSOR)

Parameters

hstmtActivate

Default is wxDB_DEFAULT_CURSOR.

Remarks

### wxDbTable::SetFromClause

void SetFromClause(const wxString&From)

Parameters

From

### wxDbTable::SetNull

bool SetNull(int colNo)

bool SetNull(const char *colName)

Parameters

colNo

colName

Remarks

### wxDbTable::SetOrderByClause

void SetOrderByClause(const wxString&OrderBy)

Parameters

OrderBy

### wxDbTable::SetQueryTimeout

bool SetQueryTimeout(UDWORD nSeconds)

Parameters

nSeconds

Remarks

### wxDbTable::SetWhereClause

void SetWhereClause(const wxString&Where)

Parameters

Where

### wxDbTable::Update

bool Update()

bool Update(const char *pSqlStmt)

Parameters

pSqlStmt

Remarks

### wxDbTable::UpdateWhere

bool UpdateWhere(const char *pWhereClause)

Parameters

pWhereClause

Remarks

### wxDbTable::operator ++

bool operator ++()

Same as wxDbTable::GetNext

See also

wxDbTable::GetNext

### wxDbTable::operator --

bool operator --()

Same as wxDbTable::GetPrev

See also

wxDbTable::GetPrev