#endif
#ifdef DBDEBUG_CONSOLE
-#if wxUSE_IOSTREAMH
- #include <iostream.h>
-#else
- #include <iostream>
-#endif
#include "wx/ioswrap.h"
#endif
#include "wx/dbtable.h"
-#ifdef __UNIX__
-// The HPUX preprocessor lines below were commented out on 8/20/97
-// because macros.h currently redefines DEBUG and is unneeded.
-// # ifdef HPUX
-// # include <macros.h>
-// # endif
-# ifdef LINUX
-# include <sys/minmax.h>
-# endif
-#endif
-
ULONG lastTableID = 0;
#ifdef __WXDEBUG__
+ #include "wx/thread.h"
+
wxList TablesInUse;
+ wxCriticalSection csTablesInUse;
#endif
} // wxDbTable::wxDbTable()
-/***** DEPRECATED: use wxDbTable::wxDbTable() format above *****/
-#if WXWIN_COMPATIBILITY_2_4
-wxDbTable::wxDbTable(wxDb *pwxDb, const wxString &tblName, const UWORD numColumns,
- const wxChar *qryTblName, bool qryOnly, const wxString &tblPath)
-{
- wxString tempQryTblName;
- tempQryTblName = qryTblName;
- if (!initialize(pwxDb, tblName, numColumns, tempQryTblName, qryOnly, tblPath))
- cleanup();
-} // wxDbTable::wxDbTable()
-#endif // WXWIN_COMPATIBILITY_2_4
-
-
/********** wxDbTable::~wxDbTable() **********/
wxDbTable::~wxDbTable()
{
tableInUse->tableName = tblName;
tableInUse->tableID = tableID;
tableInUse->pDb = pDb;
- TablesInUse.Append(tableInUse);
+ {
+ wxCriticalSectionLocker lock(csTablesInUse);
+ TablesInUse.Append(tableInUse);
+ }
#endif
pDb->WriteSqlLog(s);
bool found = false;
wxList::compatibility_iterator pNode;
- pNode = TablesInUse.GetFirst();
- while (pNode && !found)
{
- if (((wxTablesInUse *)pNode->GetData())->tableID == tableID)
+ wxCriticalSectionLocker lock(csTablesInUse);
+ pNode = TablesInUse.GetFirst();
+ while (!found && pNode)
{
- found = true;
- delete (wxTablesInUse *)pNode->GetData();
- TablesInUse.Erase(pNode);
+ if (((wxTablesInUse *)pNode->GetData())->tableID == tableID)
+ {
+ found = true;
+ delete (wxTablesInUse *)pNode->GetData();
+ TablesInUse.Erase(pNode);
+ }
+ else
+ pNode = pNode->GetNext();
}
- else
- pNode = pNode->GetNext();
}
if (!found)
{
/********** wxDbTable::bindCols() **********/
bool wxDbTable::bindCols(HSTMT cursor)
{
- static SQLLEN cb;
-
// Bind each column of the table to a memory address for fetching data
UWORD i;
for (i = 0; i < m_numCols; i++)
{
- cb = colDefs[i].CbValue;
if (SQLBindCol(cursor, (UWORD)(i+1), colDefs[i].SqlCtype, (UCHAR*) colDefs[i].PtrDataObj,
- colDefs[i].SzDataObj, &cb ) != SQL_SUCCESS)
+ colDefs[i].SzDataObj, &colDefs[i].CbValue ) != SQL_SUCCESS)
return (pDb->DispAllErrors(henv, hdbc, cursor));
}
// Completed successfully
return true;
-
} // wxDbTable::bindCols()
case SQL_C_WCHAR:
#endif
//case SQL_C_WXCHAR: SQL_C_WXCHAR is covered by either SQL_C_CHAR or SQL_C_WCHAR
- colValue.Printf(wxT("'%s'"), (UCHAR FAR *) colDefs[colNumber].PtrDataObj);
+ colValue.Printf(wxT("'%s'"), GetDb()->EscapeSqlChars((wxChar *)colDefs[colNumber].PtrDataObj).c_str());
break;
case SQL_C_SHORT:
case SQL_C_SSHORT:
pDt->second = 0;
pDt->fraction = 0;
break;
+ case SQL_C_DATE:
+ DATE_STRUCT *pDtd;
+ pDtd = (DATE_STRUCT *) colDefs[colNumber].PtrDataObj;
+ pDtd->year = 0;
+ pDtd->month = 0;
+ pDtd->day = 0;
+ break;
+ case SQL_C_TIME:
+ TIME_STRUCT *pDtt;
+ pDtt = (TIME_STRUCT *) colDefs[colNumber].PtrDataObj;
+ pDtt->hour = 0;
+ pDtt->minute = 0;
+ pDtt->second = 0;
+ break;
}
if (setToNull)