X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6bcfd974ef26faf6f91a62cac09827e09463fd1..36195a44c32bcd2b14cd819ed675bc80fb2255bd:/include/wx/dbtable.h diff --git a/include/wx/dbtable.h b/include/wx/dbtable.h index 6f7e6866d5..21f633e92d 100644 --- a/include/wx/dbtable.h +++ b/include/wx/dbtable.h @@ -3,6 +3,8 @@ // Purpose: Declaration of the wxDbTable class. // Author: Doug Card // Modified by: George Tasker +// Bart Jourquin +// Mark Johnson // Created: 9.96 // RCS-ID: $Id$ // Copyright: (c) 1996 Remstar International, Inc. @@ -33,7 +35,7 @@ #if wxMAJOR_VERSION == 2 #ifdef __GNUG__ - #pragma interface "dbtable.h" + #pragma interface "dbtable.h" #endif #endif @@ -48,6 +50,10 @@ const int wxDB_DEFAULT_CURSOR = 0; const bool wxDB_QUERY_ONLY = TRUE; const bool wxDB_DISABLE_VIEW = TRUE; +// Used to indicate end of a variable length list of +// column numbers passed to member functions +const int wxDB_NO_MORE_COLUMN_NUMBERS = -1; + // The following class is used to define a column of a table. // The wxDbTable constructor will dynamically allocate as many of // these as there are columns in the table. The class derived @@ -94,20 +100,20 @@ public: class WXDLLEXPORT wxDbTable { private: - ULONG tableID; // Used for debugging. This can help to match up mismatched constructors/destructors + ULONG tableID; // Used for debugging. This can help to match up mismatched constructors/destructors // Private member variables - UDWORD cursorType; - bool insertable; + UDWORD cursorType; + bool insertable; // Private member functions - bool bindInsertParams(void); - bool bindUpdateParams(void); - bool bindCols(HSTMT cursor); - bool getRec(UWORD fetchType); - bool execDelete(const char *pSqlStmt); - bool execUpdate(const char *pSqlStmt); - bool query(int queryType, bool forUpdate, bool distinct, const char *pSqlStmt = 0); + bool bindInsertParams(void); + bool bindUpdateParams(void); + bool bindCols(HSTMT cursor); + bool getRec(UWORD fetchType); + bool execDelete(const char *pSqlStmt); + bool execUpdate(const char *pSqlStmt); + bool query(int queryType, bool forUpdate, bool distinct, const char *pSqlStmt = NULL); #if !wxODBC_BACKWARD_COMPATABILITY // these were public @@ -179,41 +185,48 @@ public: #endif // Public member functions wxDbTable(wxDb *pwxDb, const char *tblName, const int nCols, - const char *qryTblName = 0, bool qryOnly = !wxDB_QUERY_ONLY, const char *tblPath=NULL); + const char *qryTblName = NULL, bool qryOnly = !wxDB_QUERY_ONLY, const char *tblPath=""); virtual ~wxDbTable(); - bool Open(void); + bool Open(bool checkPrivileges=FALSE); bool CreateTable(bool attemptDrop=TRUE); bool DropTable(void); bool CreateIndex(const char * idxName, bool unique, int noIdxCols, wxDbIdxDef *pIdxDefs, bool attemptDrop=TRUE); bool DropIndex(const char * idxName); -// Accessors + // Accessors // The member variables returned by these accessors are all // set when the wxDbTable instance is createand cannot be // changed, hence there is no corresponding SetXxxx function - wxDb *GetDb() { return pDb; } - const char *GetTableName() { return tableName; } - const char *GetQueryTableName() { return queryTableName; } - const char *GetTablePath() { return tablePath; } + wxDb *GetDb() { return pDb; } + const char *GetTableName() { return tableName; } + const char *GetQueryTableName() { return queryTableName; } + const char *GetTablePath() { return tablePath; } - int GetNumberOfColumns() { return noCols; } // number of "defined" columns for this wxDbTable instance + int GetNumberOfColumns() { return noCols; } // number of "defined" columns for this wxDbTable instance - const char *GetFromClause() { return from; } - const char *GetOrderByClause() { return orderBy; } - const char *GetWhereClause() { return where; } + const char *GetFromClause() { return from; } + const char *GetOrderByClause() { return orderBy; } + const char *GetWhereClause() { return where; } - bool IsQueryOnly() { return queryOnly; } + bool IsQueryOnly() { return queryOnly; } #if wxODBC_BACKWARD_COMPATABILITY void SetFromClause(const char *From) { from = (char *)From; } - void SetOrderByClause(const char *OrderBy) { orderBy = (char *)OrderBy; } - void SetWhereClause(const char *Where) { where = (char *)Where; } + void SetOrderByClause(const char *OrderBy) { orderBy = (char *)OrderBy; } + void SetWhereClause(const char *Where) { where = (char *)Where; } #else - void SetFromClause(const wxString& From) { from = From; } - void SetOrderByClause(const wxString& OrderBy) { orderBy = OrderBy; } - void SetWhereClause(const wxString& Where) { where = Where; } + void SetFromClause(const wxString& From) { from = From; } + void SetOrderByClause(const wxString& OrderBy) { orderBy = OrderBy; } + bool SetOrderByColNums(int first, ...); + void SetWhereClause(const wxString& Where) { where = Where; } + void From(const wxString& From) { from = From; } + void OrderBy(const wxString& OrderBy) { orderBy = OrderBy; } + void Where(const wxString& Where) { where = Where; } + const char * Where() { return (const char *)where.c_str(); } + const char * OrderBy() { return (const char *)orderBy.c_str(); } + const char * From() { return (const char *)from.c_str(); } #endif int Insert(void); bool Update(void); @@ -241,24 +254,25 @@ public: UWORD GetRowNum(void); void BuildSelectStmt(char *pSqlStmt, int typeOfSelect, bool distinct); - void BuildDeleteStmt(char *pSqlStmt, int typeOfDel, const char *pWhereClause = 0); - void BuildUpdateStmt(char *pSqlStmt, int typeOfUpd, const char *pWhereClause = 0); - void BuildWhereClause(char *pWhereClause, int typeOfWhere, const char *qualTableName = 0, bool useLikeComparison=FALSE); + void BuildDeleteStmt(char *pSqlStmt, int typeOfDel, const char *pWhereClause = NULL); + void BuildUpdateStmt(char *pSqlStmt, int typeOfUpd, const char *pWhereClause = NULL); + void BuildWhereClause(char *pWhereClause, int typeOfWhere, const char *qualTableName = NULL, bool useLikeComparison=FALSE); #if wxODBC_BACKWARD_COMPATABILITY // The following member functions are deprecated. You should use the BuildXxxxxStmt functions (above) void GetSelectStmt(char *pSqlStmt, int typeOfSelect, bool distinct) { BuildSelectStmt(pSqlStmt,typeOfSelect,distinct); } - void GetDeleteStmt(char *pSqlStmt, int typeOfDel, const char *pWhereClause = 0) + void GetDeleteStmt(char *pSqlStmt, int typeOfDel, const char *pWhereClause = NULL) { BuildDeleteStmt(pSqlStmt,typeOfDel,pWhereClause); } - void GetUpdateStmt(char *pSqlStmt, int typeOfUpd, const char *pWhereClause = 0) + void GetUpdateStmt(char *pSqlStmt, int typeOfUpd, const char *pWhereClause = NULL) { BuildUpdateStmt(pSqlStmt,typeOfUpd,pWhereClause); } void GetWhereClause(char *pWhereClause, int typeOfWhere, - const char *qualTableName = 0, bool useLikeComparison=FALSE) + const char *qualTableName = NULL, bool useLikeComparison=FALSE) { BuildWhereClause(pWhereClause,typeOfWhere,qualTableName,useLikeComparison); } #endif bool CanSelectForUpdate(void); bool CanUpdByROWID(void); - void ClearMemberVars(void); + void ClearMemberVar(int colNo, bool setToNull=FALSE); + void ClearMemberVars(bool setToNull=FALSE); bool SetQueryTimeout(UDWORD nSeconds); wxDbColDef *GetColDefs() { return colDefs; } @@ -281,9 +295,13 @@ public: int DB_STATUS(void) { return(pDb->DB_STATUS); } bool IsColNull(int colNo); - bool SetNull(int colNo); - bool SetNull(const char *colName); - + bool SetColNull(int colNo, bool set=TRUE); + bool SetColNull(const char *colName, bool set=TRUE); +#if wxODBC_BACKWARD_COMPATABILITY +// The following member functions are deprecated. You should use the SetColNull() + bool SetNull(int colNo, bool set=TRUE) { return (SetNull(colNo,set)); } + bool SetNull(const char *colName, bool set=TRUE) { return (SetNull(colName,set)); } +#endif #ifdef __WXDEBUG__ ULONG GetTableID() { return tableID; } #endif