X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7c5c05ae65b61f93628b0ef41cdf1f68ceefb4e0..281b0186b81a35b3eff658635b083b04a3cfa23c:/src/common/dbtable.cpp diff --git a/src/common/dbtable.cpp b/src/common/dbtable.cpp index d640ddd82c..817c5332bf 100644 --- a/src/common/dbtable.cpp +++ b/src/common/dbtable.cpp @@ -40,9 +40,9 @@ # endif #endif -//#ifdef DBDEBUG_CONSOLE - #include -//#endif +#ifdef DBDEBUG_CONSOLE + #include "wx/ioswrap.h" +#endif #ifdef __BORLANDC__ #pragma hdrstop @@ -55,6 +55,7 @@ #include "wx/list.h" #include "wx/utils.h" #include "wx/msgdlg.h" + #include "wx/log.h" #endif #include "wx/filefn.h" #endif @@ -146,8 +147,8 @@ wxTable::wxTable(wxDB *pwxDB, const char *tblName, const int nCols, s.sprintf("wxTable constructor (%-20s) tableID:[%6lu] pDb:[%p]", tblName,tableID,pDb); #ifdef __WXDEBUG__ - CstructTablesInUse *tableInUse; - tableInUse = new CstructTablesInUse(); + wxTablesInUse *tableInUse; + tableInUse = new wxTablesInUse(); tableInUse->tableName = tblName; tableInUse->tableID = tableID; tableInUse->pDb = pDb; @@ -258,15 +259,15 @@ wxTable::~wxTable() TablesInUse.DeleteContents(TRUE); bool found = FALSE; - wxNode *pNode; + wxNode *pNode; pNode = TablesInUse.First(); while (pNode && !found) { - if (((CstructTablesInUse *)pNode->Data())->tableID == tableID) + if (((wxTablesInUse *)pNode->Data())->tableID == tableID) { found = TRUE; if (!TablesInUse.DeleteNode(pNode)) - wxMessageBox (s.GetData(),"Unable to delete node!"); + wxLogDebug (s.GetData(),"Unable to delete node!"); } else pNode = pNode->Next(); @@ -275,7 +276,7 @@ wxTable::~wxTable() { wxString msg; msg.sprintf("Unable to find the tableID in the linked\nlist of tables in use.\n\n%s",s.GetData()); - wxMessageBox (msg.GetData(),"NOTICE..."); + wxLogDebug (msg.GetData(),"NOTICE..."); } } #endif @@ -582,7 +583,6 @@ bool wxTable::Open(void) return FALSE; int i; -// char sqlStmt[DB_MAX_STATEMENT_LEN]; wxString sqlStmt; // Verify that the table exists in the database @@ -1050,10 +1050,9 @@ bool wxTable::DropTable() { // NOTE: This function returns TRUE if the Table does not exist, but // only for identified databases. Code will need to be added - // below for any other databases when those databases are defined + // below for any other databases when those databases are defined // to handle this situation consistently -// char sqlStmt[DB_MAX_STATEMENT_LEN]; wxString sqlStmt; sqlStmt.sprintf("DROP TABLE %s", tableName); @@ -1095,7 +1094,7 @@ bool wxTable::DropTable() /********** wxTable::CreateIndex() **********/ -bool wxTable::CreateIndex(const char * idxName, bool unique, int noIdxCols, CidxDef *pIdxDefs, bool attemptDrop) +bool wxTable::CreateIndex(const char * idxName, bool unique, int noIdxCols, wxIdxDef *pIdxDefs, bool attemptDrop) { // char sqlStmt[DB_MAX_STATEMENT_LEN]; wxString sqlStmt; @@ -1171,7 +1170,6 @@ bool wxTable::DropIndex(const char * idxName) // below for any other databases when those databases are defined // to handle this situation consistently -// char sqlStmt[DB_MAX_STATEMENT_LEN]; wxString sqlStmt; if (pDb->Dbms() == dbmsACCESS) @@ -1265,7 +1263,7 @@ bool wxTable::Update(void) pDb->WriteSqlLog(sqlStmt); #ifdef DBDEBUG_CONSOLE - cout << endl << sqlStmt.GetData() << endl << endl; + cout << endl << sqlStmt << endl << endl; #endif // Execute the SQL UPDATE statement @@ -1303,7 +1301,7 @@ bool wxTable::UpdateWhere(const char *pWhereClause) pDb->WriteSqlLog(sqlStmt); #ifdef DBDEBUG_CONSOLE - cout << endl << sqlStmt.GetData() << endl << endl; + cout << endl << sqlStmt << endl << endl; #endif // Execute the SQL UPDATE statement @@ -1499,7 +1497,8 @@ void wxTable::GetDeleteStmt(char *pSqlStmt, int typeOfDel, const char *pWhereCla /********** wxTable::GetWhereClause() **********/ -void wxTable::GetWhereClause(char *pWhereClause, int typeOfWhere, const char *qualTableName) +void wxTable::GetWhereClause(char *pWhereClause, int typeOfWhere, + const char *qualTableName, bool useLikeComparison) /* * Note: GetWhereClause() currently ignores timestamp columns. * They are not included as part of the where clause. @@ -1531,7 +1530,10 @@ void wxTable::GetWhereClause(char *pWhereClause, int typeOfWhere, const char *qu wxStrcat(pWhereClause, "."); } wxStrcat(pWhereClause, colDefs[i].ColName); - wxStrcat(pWhereClause, " = "); + if (useLikeComparison && (colDefs[i].SqlCtype == SQL_C_CHAR)) + wxStrcat(pWhereClause, " LIKE "); + else + wxStrcat(pWhereClause, " = "); switch(colDefs[i].SqlCtype) { case SQL_C_CHAR: @@ -1742,8 +1744,6 @@ void wxTable::SetColDefs (int index, const char *fieldName, int dataType, void * /********** wxTable::SetColDef() **********/ -// BJO20000121 : changed prototype in order to return proper pointer on wxColDataPtr's array -//bool wxTable::SetColDefs(wxColInf *pColInfs, ULONG numCols, wxColDataPtr *pColDataPtrs) wxColDataPtr* wxTable::SetColDefs (wxColInf *pColInfs, ULONG numCols) { assert(pColInfs); @@ -1758,44 +1758,15 @@ wxColDataPtr* wxTable::SetColDefs (wxColInf *pColInfs, ULONG numCols) for (index = 0; index < numCols; index++) { -/* - wxString title,msg; - title.sprintf("Catalog: %s, Schema: %s, Table name: %s",pColInfs[index].catalog,pColInfs[index].schema,pColInfs[index].tableName); - msg.sprintf("Column name: %s\nData type: %04d\nType name: %s\nColumn size: %d\nBuffer len: %d\nDecimals:%d\nRadix: %d\nNullable: %d\nRemarks: %s", - pColInfs[index].colName,pColInfs[index].sqlDataType,pColInfs[index].typeName,pColInfs[index].columnSize,pColInfs[index].bufferLength,pColInfs[index].decimalDigits,pColInfs[index].numPrecRadix,pColInfs[index].nullable,pColInfs[index].remarks); - msg += " \nDB_DATA_TYPE: "; - switch(pColInfs[index].dbDataType) - { - case DB_DATA_TYPE_VARCHAR: - msg += pDb->typeInfVarchar.TypeName; break; - case DB_DATA_TYPE_INTEGER: - msg += pDb->typeInfInteger.TypeName; break; - case DB_DATA_TYPE_FLOAT: - msg += pDb->typeInfFloat.TypeName; break; - case DB_DATA_TYPE_DATE: - msg += pDb->typeInfDate.TypeName; break; - } - wxMessageBox(msg.GetData(),title.GetData()); -*/ // Process the fields switch (pColInfs[index].dbDataType) { case DB_DATA_TYPE_VARCHAR: { - - // Be sure to allocate enough memory - if (pColInfs[index].bufferLength >= pColInfs[index].columnSize) - { - pColDataPtrs[index].PtrDataObj = new char[pColInfs[index].bufferLength+1]; - pColDataPtrs[index].SzDataObj = pColInfs[index].bufferLength; - } - else - { - pColDataPtrs[index].PtrDataObj = new char[pColInfs[index].columnSize+1]; - pColDataPtrs[index].SzDataObj = pColInfs[index].columnSize; - } - pColDataPtrs[index].SqlCtype = SQL_C_CHAR; - break; + pColDataPtrs[index].PtrDataObj = new char[pColInfs[index].bufferLength+1]; + pColDataPtrs[index].SzDataObj = pColInfs[index].columnSize; + pColDataPtrs[index].SqlCtype = SQL_C_CHAR; + break; } case DB_DATA_TYPE_INTEGER: { @@ -1862,7 +1833,6 @@ void wxTable::SetCursor(HSTMT *hstmtActivate) ULONG wxTable::Count(const char *args) { ULONG l; -// char sqlStmt[DB_MAX_STATEMENT_LEN]; wxString sqlStmt; SDWORD cb;