Added #if wxODBC_BACKWARD_COMPATABILITY checking to determine whether deprecated functions/classes/enums/etc are available or not.
Cleaned up various naming conventions. from/orderBy/where are now wxString type if wxODBC_BACKWARD_COMPATABILITY is 0 Accessors added for member variables If wxODBC_BACKWARD_COMPATABILITY is 0, then member variables that have accessors are now defined in the PRIVATE: section of the class, rather than the PUBLIC:. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7138 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -371,7 +371,7 @@ private:
|
||||
bool getDataTypeInfo(SWORD fSqlType, wxDbSqlTypeInfo &structSQLTypeInfo);
|
||||
bool setConnectionOptions(void);
|
||||
void logError(const char *errMsg, const char *SQLState);
|
||||
|
||||
#if !wxODBC_BACKWARD_COMPATABILITY
|
||||
// ODBC handles
|
||||
HENV henv; // ODBC Environment handle
|
||||
HDBC hdbc; // ODBC DB Connection handle
|
||||
@@ -380,7 +380,35 @@ private:
|
||||
//Error reporting mode
|
||||
bool silent;
|
||||
|
||||
// Number of Ctable objects connected to this db object. FOR INTERNAL USE ONLY!!!
|
||||
unsigned int nTables;
|
||||
|
||||
// Information about logical data types VARCHAR, INTEGER, FLOAT and DATE.
|
||||
//
|
||||
// This information is obtained from the ODBC driver by use of the
|
||||
// SQLGetTypeInfo() function. The key piece of information is the
|
||||
// type name the data source uses for each logical data type.
|
||||
// e.g. VARCHAR; Oracle calls it VARCHAR2.
|
||||
wxDbSqlTypeInfo typeInfVarchar;
|
||||
wxDbSqlTypeInfo typeInfInteger;
|
||||
wxDbSqlTypeInfo typeInfFloat;
|
||||
wxDbSqlTypeInfo typeInfDate;
|
||||
#endif
|
||||
|
||||
public:
|
||||
#if wxODBC_BACKWARD_COMPATABILITY
|
||||
// ODBC handles
|
||||
HENV henv; // ODBC Environment handle
|
||||
HDBC hdbc; // ODBC DB Connection handle
|
||||
HSTMT hstmt; // ODBC Statement handle
|
||||
|
||||
//Error reporting mode
|
||||
bool silent;
|
||||
|
||||
// Number of Ctable objects connected to this db object. FOR INTERNAL USE ONLY!!!
|
||||
unsigned int nTables;
|
||||
#endif
|
||||
|
||||
// The following structure contains database information gathered from the
|
||||
// datasource when the datasource is first opened.
|
||||
struct
|
||||
@@ -425,16 +453,18 @@ public:
|
||||
SDWORD nativeError;
|
||||
wxChar sqlState[20];
|
||||
|
||||
// Number of Ctable objects connected to this db object. FOR INTERNAL USE ONLY!!!
|
||||
unsigned int nTables;
|
||||
|
||||
#if wxODBC_BACKWARD_COMPATABILITY
|
||||
// Information about logical data types VARCHAR, INTEGER, FLOAT and DATE.
|
||||
//
|
||||
// This information is obtained from the ODBC driver by use of the
|
||||
// SQLGetTypeInfo() function. The key piece of information is the
|
||||
// type name the data source uses for each logical data type.
|
||||
// e.g. VARCHAR; Oracle calls it VARCHAR2.
|
||||
wxDbSqlTypeInfo typeInfVarchar, typeInfInteger, typeInfFloat, typeInfDate;
|
||||
wxDbSqlTypeInfo typeInfVarchar;
|
||||
wxDbSqlTypeInfo typeInfInteger;
|
||||
wxDbSqlTypeInfo typeInfFloat;
|
||||
wxDbSqlTypeInfo typeInfDate;
|
||||
#endif
|
||||
|
||||
// Public member functions
|
||||
wxDb(HENV &aHenv, bool FwdOnlyCursors=(bool)TRUE);
|
||||
@@ -466,12 +496,25 @@ public:
|
||||
HENV GetHENV(void) {return henv;}
|
||||
HDBC GetHDBC(void) {return hdbc;}
|
||||
HSTMT GetHSTMT(void) {return hstmt;}
|
||||
int GetTableCount() {return nTables;}; // number of tables using this connection
|
||||
wxDbSqlTypeInfo GetTypeInfVarchar(){return typeInfVarchar;}
|
||||
wxDbSqlTypeInfo GetTypeInfInteger(){return typeInfInteger;}
|
||||
wxDbSqlTypeInfo GetTypeInfFloat() {return typeInfFloat;}
|
||||
wxDbSqlTypeInfo GetTypeInfDate() {return typeInfDate;}
|
||||
|
||||
bool TableExists(const char *tableName, const char *userID=NULL, const char *path=NULL); // Table name can refer to a table, view, alias or synonym
|
||||
void LogError(const char *errMsg, const char *SQLState = 0) {logError(errMsg, SQLState);}
|
||||
void SetDebugErrorMessages(bool state) { silent = !state; }
|
||||
bool SetSqlLogging(wxDbSqlLogState state, const wxChar *filename = SQL_LOG_FILENAME, bool append = FALSE);
|
||||
bool WriteSqlLog(const wxChar *logMsg);
|
||||
wxDBMS Dbms(void);
|
||||
bool FwdOnlyCursors(void) {return fwdOnlyCursors;}
|
||||
bool FwdOnlyCursors(void) {return fwdOnlyCursors;}
|
||||
|
||||
// These two functions are provided strictly for use by wxDbTable.
|
||||
// DO NOT USE THESE FUNCTIONS, OR MEMORY LEAKS MAY OCCUR
|
||||
void incrementTableCount() { nTables++; return; }
|
||||
void decrementTableCount() { nTables--; return; }
|
||||
|
||||
}; // wxDb
|
||||
|
||||
|
||||
@@ -528,7 +571,7 @@ bool WXDLLEXPORT wxDbGetDataSource(HENV henv, char *Dsn, SWORD DsnMax, char *DsD
|
||||
|
||||
|
||||
// Change this to 0 to remove use of all deprecated functions
|
||||
#if 1
|
||||
#if wxODBC_BACKWARD_COMPATABILITY
|
||||
//#################################################################################
|
||||
//############### DEPRECATED functions for backward compatability #################
|
||||
//#################################################################################
|
||||
|
@@ -108,106 +108,189 @@ private:
|
||||
bool execUpdate(const char *pSqlStmt);
|
||||
bool query(int queryType, bool forUpdate, bool distinct, const char *pSqlStmt = 0);
|
||||
|
||||
public:
|
||||
// Pointer to the database object this table belongs to
|
||||
wxDb *pDb;
|
||||
#if !wxODBC_BACKWARD_COMPATABILITY
|
||||
// these were public
|
||||
// Where, Order By and From clauses
|
||||
wxString where; // Standard SQL where clause, minus the word WHERE
|
||||
wxString orderBy; // Standard SQL order by clause, minus the ORDER BY
|
||||
wxString from; // Allows for joins in a wxDbTable::Query(). Format: ",tbl,tbl..."
|
||||
|
||||
// ODBC Handles
|
||||
HENV henv; // ODBC Environment handle
|
||||
HDBC hdbc; // ODBC DB Connection handle
|
||||
HSTMT hstmt; // ODBC Statement handle
|
||||
HSTMT *hstmtDefault; // Default cursor
|
||||
HSTMT hstmtInsert; // ODBC Statement handle used specifically for inserts
|
||||
HSTMT hstmtDelete; // ODBC Statement handle used specifically for deletes
|
||||
HSTMT hstmtUpdate; // ODBC Statement handle used specifically for updates
|
||||
HSTMT hstmtInternal; // ODBC Statement handle used internally only
|
||||
HSTMT *hstmtCount; // ODBC Statement handle used by Count() function (No binding of columns)
|
||||
HENV henv; // ODBC Environment handle
|
||||
HDBC hdbc; // ODBC DB Connection handle
|
||||
HSTMT hstmt; // ODBC Statement handle
|
||||
HSTMT *hstmtDefault; // Default cursor
|
||||
HSTMT hstmtInsert; // ODBC Statement handle used specifically for inserts
|
||||
HSTMT hstmtDelete; // ODBC Statement handle used specifically for deletes
|
||||
HSTMT hstmtUpdate; // ODBC Statement handle used specifically for updates
|
||||
HSTMT hstmtInternal; // ODBC Statement handle used internally only
|
||||
HSTMT *hstmtCount; // ODBC Statement handle used by Count() function (No binding of columns)
|
||||
|
||||
// Flags
|
||||
bool selectForUpdate;
|
||||
|
||||
// Pointer to the database object this table belongs to
|
||||
wxDb *pDb;
|
||||
|
||||
// Table Inf.
|
||||
char tableName[DB_MAX_TABLE_NAME_LEN+1]; // Table name
|
||||
char queryTableName[DB_MAX_TABLE_NAME_LEN+1]; // Query Table Name
|
||||
int noCols; // # of columns in the table
|
||||
bool queryOnly; // Query Only, no inserts, updates or deletes
|
||||
|
||||
char tablePath[wxDB_PATH_MAX]; // needed for dBase tables
|
||||
char tablePath[wxDB_PATH_MAX]; // needed for dBase tables
|
||||
char tableName[DB_MAX_TABLE_NAME_LEN+1]; // Table name
|
||||
char queryTableName[DB_MAX_TABLE_NAME_LEN+1]; // Query Table Name
|
||||
int noCols; // # of columns in the table
|
||||
bool queryOnly; // Query Only, no inserts, updates or deletes
|
||||
|
||||
// Column Definitions
|
||||
wxDbColDef *colDefs; // Array of wxDbColDef structures
|
||||
|
||||
#endif
|
||||
public:
|
||||
#if wxODBC_BACKWARD_COMPATABILITY
|
||||
// Where, Order By and From clauses
|
||||
char *where; // Standard SQL where clause, minus the word WHERE
|
||||
char *orderBy; // Standard SQL order by clause, minus the ORDER BY
|
||||
char *from; // Allows for joins in a wxDbTable::Query(). Format: ",tbl,tbl..."
|
||||
char *where; // Standard SQL where clause, minus the word WHERE
|
||||
char *orderBy; // Standard SQL order by clause, minus the ORDER BY
|
||||
char *from; // Allows for joins in a wxDbTable::Query(). Format: ",tbl,tbl..."
|
||||
|
||||
// ODBC Handles
|
||||
HENV henv; // ODBC Environment handle
|
||||
HDBC hdbc; // ODBC DB Connection handle
|
||||
HSTMT hstmt; // ODBC Statement handle
|
||||
HSTMT *hstmtDefault; // Default cursor
|
||||
HSTMT hstmtInsert; // ODBC Statement handle used specifically for inserts
|
||||
HSTMT hstmtDelete; // ODBC Statement handle used specifically for deletes
|
||||
HSTMT hstmtUpdate; // ODBC Statement handle used specifically for updates
|
||||
HSTMT hstmtInternal; // ODBC Statement handle used internally only
|
||||
HSTMT *hstmtCount; // ODBC Statement handle used by Count() function (No binding of columns)
|
||||
|
||||
// Flags
|
||||
bool selectForUpdate;
|
||||
bool selectForUpdate;
|
||||
|
||||
// Pointer to the database object this table belongs to
|
||||
wxDb *pDb;
|
||||
|
||||
// Table Inf.
|
||||
char tablePath[wxDB_PATH_MAX]; // needed for dBase tables
|
||||
char tableName[DB_MAX_TABLE_NAME_LEN+1]; // Table name
|
||||
char queryTableName[DB_MAX_TABLE_NAME_LEN+1]; // Query Table Name
|
||||
int noCols; // # of columns in the table
|
||||
bool queryOnly; // Query Only, no inserts, updates or deletes
|
||||
|
||||
// Column Definitions
|
||||
wxDbColDef *colDefs; // Array of wxDbColDef structures
|
||||
#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 = 0, bool qryOnly = !wxDB_QUERY_ONLY, const char *tblPath=NULL);
|
||||
virtual ~wxDbTable();
|
||||
bool Open(void);
|
||||
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);
|
||||
bool CloseCursor(HSTMT cursor);
|
||||
int Insert(void);
|
||||
bool Update(void);
|
||||
bool Update(const char *pSqlStmt);
|
||||
bool UpdateWhere(const char *pWhereClause);
|
||||
bool Delete(void);
|
||||
bool DeleteWhere(const char *pWhereClause);
|
||||
bool DeleteMatching(void);
|
||||
virtual bool Query(bool forUpdate = FALSE, bool distinct = FALSE);
|
||||
bool QueryBySqlStmt(const char *pSqlStmt);
|
||||
bool QueryMatching(bool forUpdate = FALSE, bool distinct = FALSE);
|
||||
bool QueryOnKeyFields(bool forUpdate = FALSE, bool distinct = FALSE);
|
||||
bool GetNext(void) { return(getRec(SQL_FETCH_NEXT)); }
|
||||
bool operator++(int) { return(getRec(SQL_FETCH_NEXT)); }
|
||||
|
||||
bool Open(void);
|
||||
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
|
||||
|
||||
// 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; }
|
||||
|
||||
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; }
|
||||
|
||||
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; }
|
||||
#else
|
||||
void SetFromClause(const wxString& From) { from = From; }
|
||||
void SetOrderByClause(const wxString& OrderBy) { orderBy = OrderBy; }
|
||||
void SetWhereClause(const wxString& Where) { where = Where; }
|
||||
#endif
|
||||
int Insert(void);
|
||||
bool Update(void);
|
||||
bool Update(const char *pSqlStmt);
|
||||
bool UpdateWhere(const char *pWhereClause);
|
||||
bool Delete(void);
|
||||
bool DeleteWhere(const char *pWhereClause);
|
||||
bool DeleteMatching(void);
|
||||
virtual bool Query(bool forUpdate = FALSE, bool distinct = FALSE);
|
||||
bool QueryBySqlStmt(const char *pSqlStmt);
|
||||
bool QueryMatching(bool forUpdate = FALSE, bool distinct = FALSE);
|
||||
bool QueryOnKeyFields(bool forUpdate = FALSE, bool distinct = FALSE);
|
||||
bool Refresh(void);
|
||||
bool GetNext(void) { return(getRec(SQL_FETCH_NEXT)); }
|
||||
bool operator++(int) { return(getRec(SQL_FETCH_NEXT)); }
|
||||
|
||||
/***** These four functions only work with wxDb instances that are defined *****
|
||||
***** as not being FwdOnlyCursors *****/
|
||||
bool GetPrev(void);
|
||||
bool operator--(int);
|
||||
bool GetFirst(void);
|
||||
bool GetLast(void);
|
||||
bool GetPrev(void);
|
||||
bool operator--(int);
|
||||
bool GetFirst(void);
|
||||
bool GetLast(void);
|
||||
|
||||
bool IsCursorClosedOnCommit(void);
|
||||
bool IsColNull(int colNo);
|
||||
UWORD GetRowNum(void);
|
||||
void GetSelectStmt(char *pSqlStmt, int typeOfSelect, bool distinct);
|
||||
void GetDeleteStmt(char *pSqlStmt, int typeOfDel, const char *pWhereClause = 0);
|
||||
void GetUpdateStmt(char *pSqlStmt, int typeOfUpd, const char *pWhereClause = 0);
|
||||
void GetWhereClause(char *pWhereClause, int typeOfWhere, const char *qualTableName = 0, bool useLikeComparison=FALSE);
|
||||
bool CanSelectForUpdate(void);
|
||||
bool CanUpdByROWID(void);
|
||||
void ClearMemberVars(void);
|
||||
bool SetQueryTimeout(UDWORD nSeconds);
|
||||
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);
|
||||
bool IsCursorClosedOnCommit(void);
|
||||
UWORD GetRowNum(void);
|
||||
|
||||
HSTMT *NewCursor(bool setCursor = FALSE, bool bindColumns = TRUE);
|
||||
bool DeleteCursor(HSTMT *hstmtDel);
|
||||
void SetCursor(HSTMT *hstmtActivate = (void **) wxDB_DEFAULT_CURSOR);
|
||||
HSTMT GetCursor(void) { return(hstmt); }
|
||||
ULONG Count(const char *args="*");
|
||||
int DB_STATUS(void) { return(pDb->DB_STATUS); }
|
||||
bool Refresh(void);
|
||||
bool SetNull(int colNo);
|
||||
bool SetNull(const char *colName);
|
||||
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);
|
||||
#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)
|
||||
{ BuildDeleteStmt(pSqlStmt,typeOfDel,pWhereClause); }
|
||||
void GetUpdateStmt(char *pSqlStmt, int typeOfUpd, const char *pWhereClause = 0)
|
||||
{ BuildUpdateStmt(pSqlStmt,typeOfUpd,pWhereClause); }
|
||||
void GetWhereClause(char *pWhereClause, int typeOfWhere,
|
||||
const char *qualTableName = 0, bool useLikeComparison=FALSE)
|
||||
{ BuildWhereClause(pWhereClause,typeOfWhere,qualTableName,useLikeComparison); }
|
||||
#endif
|
||||
bool CanSelectForUpdate(void);
|
||||
bool CanUpdByROWID(void);
|
||||
void ClearMemberVars(void);
|
||||
bool SetQueryTimeout(UDWORD nSeconds);
|
||||
|
||||
wxDbColDef *GetColDefs() { return colDefs; }
|
||||
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);
|
||||
|
||||
bool CloseCursor(HSTMT cursor);
|
||||
bool DeleteCursor(HSTMT *hstmtDel);
|
||||
void SetCursor(HSTMT *hstmtActivate = (void **) wxDB_DEFAULT_CURSOR);
|
||||
HSTMT GetCursor(void) { return(hstmt); }
|
||||
HSTMT *GetNewCursor(bool setCursor = FALSE, bool bindColumns = TRUE);
|
||||
#if wxODBC_BACKWARD_COMPATABILITY
|
||||
// The following member function is deprecated. You should use the GetNewCursor
|
||||
HSTMT *NewCursor(bool setCursor = FALSE, bool bindColumns = TRUE) { return GetNewCursor(setCursor,bindColumns); }
|
||||
#endif
|
||||
|
||||
ULONG Count(const char *args="*");
|
||||
int DB_STATUS(void) { return(pDb->DB_STATUS); }
|
||||
|
||||
bool IsColNull(int colNo);
|
||||
bool SetNull(int colNo);
|
||||
bool SetNull(const char *colName);
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
ULONG GetTableID() { return tableID; };
|
||||
ULONG GetTableID() { return tableID; }
|
||||
#endif
|
||||
|
||||
}; // wxDbTable
|
||||
|
||||
|
||||
// Change this to 0 to remove use of all deprecated functions
|
||||
#if 1
|
||||
#if wxODBC_BACKWARD_COMPATABILITY
|
||||
//#################################################################################
|
||||
//############### DEPRECATED functions for backward compatability #################
|
||||
//#################################################################################
|
||||
@@ -225,8 +308,6 @@ const int ROWID = wxDB_ROWID_LEN;
|
||||
const int DEFAULT_CURSOR = wxDB_DEFAULT_CURSOR;
|
||||
const bool QUERY_ONLY = wxDB_QUERY_ONLY;
|
||||
const bool DISABLE_VIEW = wxDB_DISABLE_VIEW;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -805,7 +805,7 @@ bool wxDb::getDataTypeInfo(SWORD fSqlType, wxDbSqlTypeInfo &structSQLTypeInfo)
|
||||
* wxDbSqlTypeInfo is a structure that is filled in with data type information,
|
||||
*/
|
||||
RETCODE retcode;
|
||||
SDWORD cbRet;
|
||||
SDWORD cbRet;
|
||||
|
||||
// Get information about the data type specified
|
||||
if (SQLGetTypeInfo(hstmt, fSqlType) != SQL_SUCCESS)
|
||||
@@ -828,12 +828,12 @@ bool wxDb::getDataTypeInfo(SWORD fSqlType, wxDbSqlTypeInfo &structSQLTypeInfo)
|
||||
// BJO 991209
|
||||
if (Dbms() == dbmsMY_SQL)
|
||||
{
|
||||
if (!strcmp(structSQLTypeInfo.TypeName, "middleint")) strcpy(structSQLTypeInfo.TypeName, "mediumint");
|
||||
if (!strcmp(structSQLTypeInfo.TypeName, "middleint unsigned")) strcpy(structSQLTypeInfo.TypeName, "mediumint unsigned");
|
||||
if (!strcmp(structSQLTypeInfo.TypeName, "integer")) strcpy(structSQLTypeInfo.TypeName, "int");
|
||||
if (!strcmp(structSQLTypeInfo.TypeName, "integer unsigned")) strcpy(structSQLTypeInfo.TypeName, "int unsigned");
|
||||
if (!strcmp(structSQLTypeInfo.TypeName, "middleint")) strcpy(structSQLTypeInfo.TypeName, "mediumint");
|
||||
if (!strcmp(structSQLTypeInfo.TypeName, "varchar")) strcpy(structSQLTypeInfo.TypeName, "char");
|
||||
if (!wxStrcmp(structSQLTypeInfo.TypeName, "middleint")) wxStrcpy(structSQLTypeInfo.TypeName, "mediumint");
|
||||
if (!wxStrcmp(structSQLTypeInfo.TypeName, "middleint unsigned")) wxStrcpy(structSQLTypeInfo.TypeName, "mediumint unsigned");
|
||||
if (!wxStrcmp(structSQLTypeInfo.TypeName, "integer")) wxStrcpy(structSQLTypeInfo.TypeName, "int");
|
||||
if (!wxStrcmp(structSQLTypeInfo.TypeName, "integer unsigned")) wxStrcpy(structSQLTypeInfo.TypeName, "int unsigned");
|
||||
if (!wxStrcmp(structSQLTypeInfo.TypeName, "middleint")) wxStrcpy(structSQLTypeInfo.TypeName, "mediumint");
|
||||
if (!wxStrcmp(structSQLTypeInfo.TypeName, "varchar")) wxStrcpy(structSQLTypeInfo.TypeName, "char");
|
||||
}
|
||||
|
||||
if (SQLGetData(hstmt, 3, SQL_C_LONG, (UCHAR*) &structSQLTypeInfo.Precision, 0, &cbRet) != SQL_SUCCESS)
|
||||
@@ -951,20 +951,20 @@ bool wxDb::DispAllErrors(HENV aHenv, HDBC aHdbc, HSTMT aHstmt)
|
||||
while (SQLError(aHenv, aHdbc, aHstmt, (UCHAR FAR *) sqlState, &nativeError, (UCHAR FAR *) errorMsg, SQL_MAX_MESSAGE_LENGTH - 1, &cbErrorMsg) == SQL_SUCCESS)
|
||||
{
|
||||
odbcErrMsg.sprintf("SQL State = %s\nNative Error Code = %li\nError Message = %s\n", sqlState, nativeError, errorMsg);
|
||||
logError(odbcErrMsg.GetData(), sqlState);
|
||||
logError(odbcErrMsg.c_str(), sqlState);
|
||||
if (!silent)
|
||||
{
|
||||
#ifdef DBDEBUG_CONSOLE
|
||||
// When run in console mode, use standard out to display errors.
|
||||
cout << odbcErrMsg.GetData() << endl;
|
||||
cout << odbcErrMsg.c_str() << endl;
|
||||
cout << "Press any key to continue..." << endl;
|
||||
getchar();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
wxLogDebug(odbcErrMsg.GetData(),"DEBUG MESSAGE from DispAllErrors()");
|
||||
wxLogDebug(odbcErrMsg.c_str(),wxT("ODBC DEBUG MESSAGE from DispAllErrors()"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return(FALSE); // This function always returns false.
|
||||
@@ -990,18 +990,23 @@ void wxDb::DispNextError(void)
|
||||
wxString odbcErrMsg;
|
||||
|
||||
odbcErrMsg.sprintf("SQL State = %s\nNative Error Code = %li\nError Message = %s\n", sqlState, nativeError, errorMsg);
|
||||
logError(odbcErrMsg.GetData(), sqlState);
|
||||
logError(odbcErrMsg.c_str(), sqlState);
|
||||
|
||||
if (silent)
|
||||
return;
|
||||
|
||||
#ifdef DBDEBUG_CONSOLE
|
||||
// When run in console mode, use standard out to display errors.
|
||||
cout << odbcErrMsg.GetData() << endl;
|
||||
cout << odbcErrMsg.c_str() << endl;
|
||||
cout << "Press any key to continue..." << endl;
|
||||
getchar();
|
||||
#endif
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
wxLogDebug(odbcErrMsg,wxT("ODBC DEBUG MESSAGE"));
|
||||
#endif // __WXDEBUG__
|
||||
|
||||
|
||||
} // wxDb::DispNextError()
|
||||
|
||||
|
||||
@@ -1265,12 +1270,12 @@ bool wxDb::Grant(int privileges, const char *tableName, const char *userList)
|
||||
sqlStmt += userList;
|
||||
|
||||
#ifdef DBDEBUG_CONSOLE
|
||||
cout << endl << sqlStmt.GetData() << endl;
|
||||
cout << endl << sqlStmt.c_str() << endl;
|
||||
#endif
|
||||
|
||||
WriteSqlLog(sqlStmt.GetData());
|
||||
WriteSqlLog(sqlStmt.c_str());
|
||||
|
||||
return(ExecSql(sqlStmt.GetData()));
|
||||
return(ExecSql(sqlStmt.c_str()));
|
||||
|
||||
} // wxDb::Grant()
|
||||
|
||||
@@ -1299,13 +1304,13 @@ bool wxDb::CreateView(const char *viewName, const char *colList, const char *pSq
|
||||
sqlStmt += " AS ";
|
||||
sqlStmt += pSqlStmt;
|
||||
|
||||
WriteSqlLog(sqlStmt.GetData());
|
||||
WriteSqlLog(sqlStmt.c_str());
|
||||
|
||||
#ifdef DBDEBUG_CONSOLE
|
||||
cout << sqlStmt.GetData() << endl;
|
||||
cout << sqlStmt.c_str() << endl;
|
||||
#endif
|
||||
|
||||
return(ExecSql(sqlStmt.GetData()));
|
||||
return(ExecSql(sqlStmt.c_str()));
|
||||
|
||||
} // wxDb::CreateView()
|
||||
|
||||
@@ -1324,13 +1329,13 @@ bool wxDb::DropView(const char *viewName)
|
||||
|
||||
sqlStmt.sprintf("DROP VIEW %s", viewName);
|
||||
|
||||
WriteSqlLog(sqlStmt.GetData());
|
||||
WriteSqlLog(sqlStmt.c_str());
|
||||
|
||||
#ifdef DBDEBUG_CONSOLE
|
||||
cout << endl << sqlStmt.GetData() << endl;
|
||||
cout << endl << sqlStmt.c_str() << endl;
|
||||
#endif
|
||||
|
||||
if (SQLExecDirect(hstmt, (UCHAR FAR *) sqlStmt.GetData(), SQL_NTS) != SQL_SUCCESS)
|
||||
if (SQLExecDirect(hstmt, (UCHAR FAR *) sqlStmt.c_str(), SQL_NTS) != SQL_SUCCESS)
|
||||
{
|
||||
// Check for "Base table not found" error and ignore
|
||||
GetNextError(henv, hdbc, hstmt);
|
||||
@@ -1490,7 +1495,7 @@ int wxDb::GetKeyFields(char *tableName, wxDbColInf* colInf, int noCols)
|
||||
{
|
||||
for (i=0;i<noCols;i++) // Find the Column name
|
||||
if (!wxStrcmp(colInf[i].colName,szPkCol)) // We have found the Column, store the Information
|
||||
strcpy(colInf[i].PkTableName,Temp0); // Name of the Tables where this Primary Key is used as a Foreign Key
|
||||
wxStrcpy(colInf[i].PkTableName,Temp0.c_str()); // Name of the Tables where this Primary Key is used as a Foreign Key
|
||||
} // if (Temp0 != "")
|
||||
SQLFreeStmt(hstmt, SQL_CLOSE); /* Close the cursor (the hstmt is still allocated). */
|
||||
|
||||
@@ -1525,7 +1530,7 @@ int wxDb::GetKeyFields(char *tableName, wxDbColInf* colInf, int noCols)
|
||||
if (!wxStrcmp(colInf[i].colName,szFkCol)) // We have found the (Foreign Key) Column
|
||||
{
|
||||
colInf[i].FkCol = iKeySeq; // Which Foreign Key is this (first, second usw.) ?
|
||||
strcpy(colInf[i].FkTableName,szPkTable); // Name of the Table where this Foriegn is the Primary Key
|
||||
wxStrcpy(colInf[i].FkTableName,szPkTable); // Name of the Table where this Foriegn is the Primary Key
|
||||
} // if (!wxStrcmp(colInf[i].colName,szFkCol))
|
||||
} // for (i=0;i<noCols;i++)
|
||||
} // if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
|
||||
@@ -1628,14 +1633,14 @@ wxDbColInf *wxDb::GetColumns(char *tableName[], const char *userID)
|
||||
|
||||
// MySQL and Access cannot accept a user name when looking up column names, so we
|
||||
// use the call below that leaves out the user name
|
||||
if (wxStrcmp(UserID.GetData(),wxT("")) &&
|
||||
if (wxStrcmp(UserID.c_str(),wxT("")) &&
|
||||
Dbms() != dbmsMY_SQL &&
|
||||
Dbms() != dbmsACCESS)
|
||||
{
|
||||
retcode = SQLColumns(hstmt,
|
||||
NULL, 0, // All qualifiers
|
||||
(UCHAR *) UserID.GetData(), SQL_NTS, // Owner
|
||||
(UCHAR *) TableName.GetData(), SQL_NTS,
|
||||
(UCHAR *) UserID.c_str(), SQL_NTS, // Owner
|
||||
(UCHAR *) TableName.c_str(), SQL_NTS,
|
||||
NULL, 0); // All columns
|
||||
}
|
||||
else
|
||||
@@ -1643,7 +1648,7 @@ wxDbColInf *wxDb::GetColumns(char *tableName[], const char *userID)
|
||||
retcode = SQLColumns(hstmt,
|
||||
NULL, 0, // All qualifiers
|
||||
NULL, 0, // Owner
|
||||
(UCHAR *) TableName.GetData(), SQL_NTS,
|
||||
(UCHAR *) TableName.c_str(), SQL_NTS,
|
||||
NULL, 0); // All columns
|
||||
}
|
||||
if (retcode != SQL_SUCCESS)
|
||||
@@ -1793,14 +1798,14 @@ wxDbColInf *wxDb::GetColumns(char *tableName, int *numCols, const char *userID)
|
||||
|
||||
// MySQL and Access cannot accept a user name when looking up column names, so we
|
||||
// use the call below that leaves out the user name
|
||||
if (wxStrcmp(UserID.GetData(),wxT("")) &&
|
||||
if (wxStrcmp(UserID.c_str(),wxT("")) &&
|
||||
Dbms() != dbmsMY_SQL &&
|
||||
Dbms() != dbmsACCESS)
|
||||
{
|
||||
retcode = SQLColumns(hstmt,
|
||||
NULL, 0, // All qualifiers
|
||||
(UCHAR *) UserID.GetData(), SQL_NTS, // Owner
|
||||
(UCHAR *) TableName.GetData(), SQL_NTS,
|
||||
(UCHAR *) UserID.c_str(), SQL_NTS, // Owner
|
||||
(UCHAR *) TableName.c_str(), SQL_NTS,
|
||||
NULL, 0); // All columns
|
||||
}
|
||||
else
|
||||
@@ -1808,7 +1813,7 @@ wxDbColInf *wxDb::GetColumns(char *tableName, int *numCols, const char *userID)
|
||||
retcode = SQLColumns(hstmt,
|
||||
NULL, 0, // All qualifiers
|
||||
NULL, 0, // Owner
|
||||
(UCHAR *) TableName.GetData(), SQL_NTS,
|
||||
(UCHAR *) TableName.c_str(), SQL_NTS,
|
||||
NULL, 0); // All columns
|
||||
}
|
||||
if (retcode != SQL_SUCCESS)
|
||||
@@ -1953,14 +1958,14 @@ int wxDb::GetColumnCount(char *tableName, const char *userID)
|
||||
|
||||
// MySQL and Access cannot accept a user name when looking up column names, so we
|
||||
// use the call below that leaves out the user name
|
||||
if (wxStrcmp(UserID.GetData(),wxT("")) &&
|
||||
if (wxStrcmp(UserID.c_str(),wxT("")) &&
|
||||
Dbms() != dbmsMY_SQL &&
|
||||
Dbms() != dbmsACCESS)
|
||||
{
|
||||
retcode = SQLColumns(hstmt,
|
||||
NULL, 0, // All qualifiers
|
||||
(UCHAR *) UserID.GetData(), SQL_NTS, // Owner
|
||||
(UCHAR *) TableName.GetData(), SQL_NTS,
|
||||
(UCHAR *) UserID.c_str(), SQL_NTS, // Owner
|
||||
(UCHAR *) TableName.c_str(), SQL_NTS,
|
||||
NULL, 0); // All columns
|
||||
}
|
||||
else
|
||||
@@ -1968,7 +1973,7 @@ int wxDb::GetColumnCount(char *tableName, const char *userID)
|
||||
retcode = SQLColumns(hstmt,
|
||||
NULL, 0, // All qualifiers
|
||||
NULL, 0, // Owner
|
||||
(UCHAR *) TableName.GetData(), SQL_NTS,
|
||||
(UCHAR *) TableName.c_str(), SQL_NTS,
|
||||
NULL, 0); // All columns
|
||||
}
|
||||
if (retcode != SQL_SUCCESS)
|
||||
@@ -2067,13 +2072,13 @@ wxDbInf *wxDb::GetCatalog(char *userID)
|
||||
SQLFreeStmt(hstmt, SQL_CLOSE); // Close if Open
|
||||
tblNameSave = wxT("");
|
||||
|
||||
if (wxStrcmp(UserID.GetData(),wxT("")) &&
|
||||
if (wxStrcmp(UserID.c_str(),wxT("")) &&
|
||||
Dbms() != dbmsMY_SQL &&
|
||||
Dbms() != dbmsACCESS)
|
||||
{
|
||||
retcode = SQLTables(hstmt,
|
||||
NULL, 0, // All qualifiers
|
||||
(UCHAR *) UserID.GetData(), SQL_NTS, // User specified
|
||||
(UCHAR *) UserID.c_str(), SQL_NTS, // User specified
|
||||
NULL, 0, // All tables
|
||||
NULL, 0); // All columns
|
||||
}
|
||||
@@ -2192,13 +2197,13 @@ bool wxDb::Catalog(const char *userID, const char *fileName)
|
||||
if (Dbms() == dbmsORACLE)
|
||||
UserID = UserID.Upper();
|
||||
|
||||
if (wxStrcmp(UserID.GetData(),wxT("")) &&
|
||||
if (wxStrcmp(UserID.c_str(),wxT("")) &&
|
||||
Dbms() != dbmsMY_SQL &&
|
||||
Dbms() != dbmsACCESS)
|
||||
{
|
||||
retcode = SQLColumns(hstmt,
|
||||
NULL, 0, // All qualifiers
|
||||
(UCHAR *) UserID.GetData(), SQL_NTS, // User specified
|
||||
(UCHAR *) UserID.c_str(), SQL_NTS, // User specified
|
||||
NULL, 0, // All tables
|
||||
NULL, 0); // All columns
|
||||
}
|
||||
@@ -2223,7 +2228,7 @@ bool wxDb::Catalog(const char *userID, const char *fileName)
|
||||
|
||||
while ((retcode = SQLFetch(hstmt)) == SQL_SUCCESS)
|
||||
{
|
||||
if (wxStrcmp(tblName,tblNameSave.GetData()))
|
||||
if (wxStrcmp(tblName,tblNameSave.c_str()))
|
||||
{
|
||||
if (cnt)
|
||||
fputs("\n", fp);
|
||||
@@ -2234,7 +2239,7 @@ bool wxDb::Catalog(const char *userID, const char *fileName)
|
||||
fputs("=========\n", fp);
|
||||
outStr.sprintf(wxT("%-32s %-32s %-21s %9s %9s\n"),
|
||||
wxT("TABLE NAME"), wxT("COLUMN NAME"), wxT("DATA TYPE"), wxT("PRECISION"), wxT("LENGTH"));
|
||||
fputs(outStr.GetData(), fp);
|
||||
fputs(outStr.c_str(), fp);
|
||||
fputs("================================ ", fp);
|
||||
fputs("================================ ", fp);
|
||||
fputs("===================== ", fp);
|
||||
@@ -2252,7 +2257,7 @@ bool wxDb::Catalog(const char *userID, const char *fileName)
|
||||
|
||||
outStr.sprintf("%-32s %-32s (%04d)%-15s %9d %9d\n",
|
||||
tblName, colName, sqlDataType, typeName, precision, length);
|
||||
if (fputs(outStr.GetData(), fp) == EOF)
|
||||
if (fputs(outStr.c_str(), fp) == EOF)
|
||||
{
|
||||
SQLFreeStmt(hstmt, SQL_CLOSE);
|
||||
fclose(fp);
|
||||
@@ -2299,7 +2304,7 @@ bool wxDb::TableExists(const char *tableName, const char *userID, const char *ta
|
||||
dbName.sprintf("%s.dbf",tableName);
|
||||
|
||||
bool exists;
|
||||
exists = wxFileExists(dbName.GetData());
|
||||
exists = wxFileExists(dbName.c_str());
|
||||
return exists;
|
||||
}
|
||||
|
||||
@@ -2335,8 +2340,8 @@ bool wxDb::TableExists(const char *tableName, const char *userID, const char *ta
|
||||
{
|
||||
retcode = SQLTables(hstmt,
|
||||
NULL, 0, // All qualifiers
|
||||
(UCHAR *) UserID.GetData(), SQL_NTS, // All owners
|
||||
(UCHAR FAR *)TableName.GetData(), SQL_NTS,
|
||||
(UCHAR *) UserID.c_str(), SQL_NTS, // All owners
|
||||
(UCHAR FAR *)TableName.c_str(), SQL_NTS,
|
||||
NULL, 0); // All table types
|
||||
}
|
||||
else
|
||||
@@ -2344,7 +2349,7 @@ bool wxDb::TableExists(const char *tableName, const char *userID, const char *ta
|
||||
retcode = SQLTables(hstmt,
|
||||
NULL, 0, // All qualifiers
|
||||
NULL, 0, // All owners
|
||||
(UCHAR FAR *)TableName.GetData(), SQL_NTS,
|
||||
(UCHAR FAR *)TableName.c_str(), SQL_NTS,
|
||||
NULL, 0); // All table types
|
||||
}
|
||||
if (retcode != SQL_SUCCESS)
|
||||
@@ -2670,7 +2675,7 @@ int wxDbCreateDataSource(const char *driverName, const char *dsn, const char *de
|
||||
while (k != wxNOT_FOUND);
|
||||
|
||||
result = SQLConfigDataSource((HWND)parent->GetHWND(), dsnLocation,
|
||||
driverName, setupStr.GetData());
|
||||
driverName, setupStr.c_str());
|
||||
|
||||
if (!result)
|
||||
{
|
||||
@@ -2683,20 +2688,19 @@ int wxDbCreateDataSource(const char *driverName, const char *dsn, const char *de
|
||||
SQLInstallerError(1,&retcode,errMsg,500,&cb);
|
||||
if (retcode)
|
||||
{
|
||||
// logError(errMsg, sqlState);
|
||||
// if (!silent)
|
||||
// {
|
||||
if (!silent)
|
||||
{
|
||||
#ifdef DBDEBUG_CONSOLE
|
||||
// When run in console mode, use standard out to display errors.
|
||||
cout << errMsg << endl;
|
||||
cout << "Press any key to continue..." << endl;
|
||||
getchar();
|
||||
// When run in console mode, use standard out to display errors.
|
||||
cout << errMsg << endl;
|
||||
cout << "Press any key to continue..." << endl;
|
||||
getchar();
|
||||
#endif // DBDEBUG_CONSOLE
|
||||
// }
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
wxLogDebug(errMsg,"DEBUG MESSAGE");
|
||||
wxLogDebug(errMsg,wxT("ODBC DEBUG MESSAGE"));
|
||||
#endif // __WXDEBUG__
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2734,7 +2738,7 @@ bool wxDbGetDataSource(HENV henv, char *Dsn, SWORD DsnMax, char *DsDesc, SWORD D
|
||||
|
||||
|
||||
// Change this to 0 to remove use of all deprecated functions
|
||||
#if 1
|
||||
#if wxODBC_BACKWARD_COMPATABILITY
|
||||
/********************************************************************
|
||||
********************************************************************
|
||||
*
|
||||
@@ -2776,8 +2780,5 @@ int WXDLLEXPORT NumberDbConnectionsInUse(void)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
// wxUSE_ODBC
|
||||
|
@@ -120,9 +120,9 @@ wxDbTable::wxDbTable(wxDb *pwxDb, const char *tblName, const int nCols,
|
||||
colDefs = 0;
|
||||
tableID = 0;
|
||||
noCols = nCols; // No. of cols in the table
|
||||
where = 0; // Where clause
|
||||
orderBy = 0; // Order By clause
|
||||
from = 0; // From clause
|
||||
where = ""; // Where clause
|
||||
orderBy = ""; // Order By clause
|
||||
from = ""; // From clause
|
||||
selectForUpdate = FALSE; // SELECT ... FOR UPDATE; Indicates whether to include the FOR UPDATE phrase
|
||||
queryOnly = qryOnly;
|
||||
|
||||
@@ -140,7 +140,7 @@ wxDbTable::wxDbTable(wxDb *pwxDb, const char *tblName, const int nCols,
|
||||
if (!pDb)
|
||||
return;
|
||||
|
||||
pDb->nTables++;
|
||||
pDb->incrementTableCount();
|
||||
|
||||
wxString s;
|
||||
tableID = ++lastTableID;
|
||||
@@ -155,7 +155,7 @@ wxDbTable::wxDbTable(wxDb *pwxDb, const char *tblName, const int nCols,
|
||||
TablesInUse.Append(tableInUse);
|
||||
#endif
|
||||
|
||||
pDb->WriteSqlLog(s.GetData());
|
||||
pDb->WriteSqlLog(s.c_str());
|
||||
|
||||
// Grab the HENV and HDBC from the wxDb object
|
||||
henv = pDb->GetHENV();
|
||||
@@ -236,7 +236,7 @@ wxDbTable::wxDbTable(wxDb *pwxDb, const char *tblName, const int nCols,
|
||||
}
|
||||
|
||||
// Make the default cursor the active cursor
|
||||
hstmtDefault = NewCursor(FALSE,FALSE);
|
||||
hstmtDefault = GetNewCursor(FALSE,FALSE);
|
||||
assert(hstmtDefault);
|
||||
hstmt = *hstmtDefault;
|
||||
|
||||
@@ -250,7 +250,7 @@ wxDbTable::~wxDbTable()
|
||||
if (pDb)
|
||||
{
|
||||
s.sprintf("wxDbTable destructor (%-20s) tableID:[%6lu] pDb:[%p]", tableName,tableID,pDb);
|
||||
pDb->WriteSqlLog(s.GetData());
|
||||
pDb->WriteSqlLog(s.c_str());
|
||||
}
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
@@ -267,7 +267,7 @@ wxDbTable::~wxDbTable()
|
||||
{
|
||||
found = TRUE;
|
||||
if (!TablesInUse.DeleteNode(pNode))
|
||||
wxLogDebug (s.GetData(),"Unable to delete node!");
|
||||
wxLogDebug (s.c_str(),wxT("Unable to delete node!"));
|
||||
}
|
||||
else
|
||||
pNode = pNode->Next();
|
||||
@@ -275,15 +275,15 @@ wxDbTable::~wxDbTable()
|
||||
if (!found)
|
||||
{
|
||||
wxString msg;
|
||||
msg.sprintf(wxT("Unable to find the tableID in the linked\nlist of tables in use.\n\n%s"),s.GetData());
|
||||
wxLogDebug (msg.GetData(),wxT("NOTICE..."));
|
||||
msg.sprintf(wxT("Unable to find the tableID in the linked\nlist of tables in use.\n\n%s"),s.c_str());
|
||||
wxLogDebug (msg.c_str(),wxT("NOTICE..."));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Decrement the wxDb table count
|
||||
if (pDb)
|
||||
pDb->nTables--;
|
||||
pDb->decrementTableCount();
|
||||
|
||||
// Delete memory allocated for column definitions
|
||||
if (colDefs)
|
||||
@@ -344,21 +344,21 @@ bool wxDbTable::bindInsertParams(void)
|
||||
switch(colDefs[i].DbDataType)
|
||||
{
|
||||
case DB_DATA_TYPE_VARCHAR:
|
||||
fSqlType = pDb->typeInfVarchar.FsqlType;
|
||||
fSqlType = pDb->GetTypeInfVarchar().FsqlType;
|
||||
precision = colDefs[i].SzDataObj;
|
||||
scale = 0;
|
||||
colDefs[i].CbValue = SQL_NTS;
|
||||
break;
|
||||
case DB_DATA_TYPE_INTEGER:
|
||||
fSqlType = pDb->typeInfInteger.FsqlType;
|
||||
precision = pDb->typeInfInteger.Precision;
|
||||
fSqlType = pDb->GetTypeInfInteger().FsqlType;
|
||||
precision = pDb->GetTypeInfInteger().Precision;
|
||||
scale = 0;
|
||||
colDefs[i].CbValue = 0;
|
||||
break;
|
||||
case DB_DATA_TYPE_FLOAT:
|
||||
fSqlType = pDb->typeInfFloat.FsqlType;
|
||||
precision = pDb->typeInfFloat.Precision;
|
||||
scale = pDb->typeInfFloat.MaximumScale;
|
||||
fSqlType = pDb->GetTypeInfFloat().FsqlType;
|
||||
precision = pDb->GetTypeInfFloat().Precision;
|
||||
scale = pDb->GetTypeInfFloat().MaximumScale;
|
||||
// SQL Sybase Anywhere v5.5 returned a negative number for the
|
||||
// MaxScale. This caused ODBC to kick out an error on ibscale.
|
||||
// I check for this here and set the scale = precision.
|
||||
@@ -367,8 +367,8 @@ bool wxDbTable::bindInsertParams(void)
|
||||
colDefs[i].CbValue = 0;
|
||||
break;
|
||||
case DB_DATA_TYPE_DATE:
|
||||
fSqlType = pDb->typeInfDate.FsqlType;
|
||||
precision = pDb->typeInfDate.Precision;
|
||||
fSqlType = pDb->GetTypeInfDate().FsqlType;
|
||||
precision = pDb->GetTypeInfDate().Precision;
|
||||
scale = 0;
|
||||
colDefs[i].CbValue = 0;
|
||||
break;
|
||||
@@ -411,21 +411,21 @@ bool wxDbTable::bindUpdateParams(void)
|
||||
switch(colDefs[i].DbDataType)
|
||||
{
|
||||
case DB_DATA_TYPE_VARCHAR:
|
||||
fSqlType = pDb->typeInfVarchar.FsqlType;
|
||||
fSqlType = pDb->GetTypeInfVarchar().FsqlType;
|
||||
precision = colDefs[i].SzDataObj;
|
||||
scale = 0;
|
||||
colDefs[i].CbValue = SQL_NTS;
|
||||
break;
|
||||
case DB_DATA_TYPE_INTEGER:
|
||||
fSqlType = pDb->typeInfInteger.FsqlType;
|
||||
precision = pDb->typeInfInteger.Precision;
|
||||
fSqlType = pDb->GetTypeInfInteger().FsqlType;
|
||||
precision = pDb->GetTypeInfInteger().Precision;
|
||||
scale = 0;
|
||||
colDefs[i].CbValue = 0;
|
||||
break;
|
||||
case DB_DATA_TYPE_FLOAT:
|
||||
fSqlType = pDb->typeInfFloat.FsqlType;
|
||||
precision = pDb->typeInfFloat.Precision;
|
||||
scale = pDb->typeInfFloat.MaximumScale;
|
||||
fSqlType = pDb->GetTypeInfFloat().FsqlType;
|
||||
precision = pDb->GetTypeInfFloat().Precision;
|
||||
scale = pDb->GetTypeInfFloat().MaximumScale;
|
||||
// SQL Sybase Anywhere v5.5 returned a negative number for the
|
||||
// MaxScale. This caused ODBC to kick out an error on ibscale.
|
||||
// I check for this here and set the scale = precision.
|
||||
@@ -434,8 +434,8 @@ bool wxDbTable::bindUpdateParams(void)
|
||||
colDefs[i].CbValue = 0;
|
||||
break;
|
||||
case DB_DATA_TYPE_DATE:
|
||||
fSqlType = pDb->typeInfDate.FsqlType;
|
||||
precision = pDb->typeInfDate.Precision;
|
||||
fSqlType = pDb->GetTypeInfDate().FsqlType;
|
||||
precision = pDb->GetTypeInfDate().Precision;
|
||||
scale = 0;
|
||||
colDefs[i].CbValue = 0;
|
||||
break;
|
||||
@@ -550,7 +550,7 @@ bool wxDbTable::query(int queryType, bool forUpdate, bool distinct, const char *
|
||||
// Set the SQL SELECT string
|
||||
if (queryType != DB_SELECT_STATEMENT) // A select statement was not passed in,
|
||||
{ // so generate a select statement.
|
||||
GetSelectStmt(sqlStmt, queryType, distinct);
|
||||
BuildSelectStmt(sqlStmt, queryType, distinct);
|
||||
pDb->WriteSqlLog(sqlStmt);
|
||||
}
|
||||
|
||||
@@ -595,7 +595,7 @@ bool wxDbTable::Open(void)
|
||||
s += wxT("Table/view does not exist in the database.\n");
|
||||
else
|
||||
s += wxT("Current logged in user does not have sufficient privileges to access this table.\n");
|
||||
pDb->LogError(s.GetData());
|
||||
pDb->LogError(s.c_str());
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
@@ -646,7 +646,7 @@ bool wxDbTable::Open(void)
|
||||
// pDb->WriteSqlLog(sqlStmt);
|
||||
|
||||
// Prepare the insert statement for execution
|
||||
if (SQLPrepare(hstmtInsert, (UCHAR FAR *) sqlStmt.GetData(), SQL_NTS) != SQL_SUCCESS)
|
||||
if (SQLPrepare(hstmtInsert, (UCHAR FAR *) sqlStmt.c_str(), SQL_NTS) != SQL_SUCCESS)
|
||||
return(pDb->DispAllErrors(henv, hdbc, hstmtInsert));
|
||||
}
|
||||
|
||||
@@ -745,8 +745,8 @@ bool wxDbTable::GetLast(void)
|
||||
} // wxDbTable::GetLast()
|
||||
|
||||
|
||||
/********** wxDbTable::GetSelectStmt() **********/
|
||||
void wxDbTable::GetSelectStmt(char *pSqlStmt, int typeOfSelect, bool distinct)
|
||||
/********** wxDbTable::BuildSelectStmt() **********/
|
||||
void wxDbTable::BuildSelectStmt(char *pSqlStmt, int typeOfSelect, bool distinct)
|
||||
{
|
||||
char whereClause[DB_MAX_WHERE_CLAUSE_LEN];
|
||||
|
||||
@@ -762,8 +762,13 @@ void wxDbTable::GetSelectStmt(char *pSqlStmt, int typeOfSelect, bool distinct)
|
||||
// Was a FROM clause specified to join tables to the base table?
|
||||
// Available for ::Query() only!!!
|
||||
bool appendFromClause = FALSE;
|
||||
#if wxODBC_BACKWARD_COMPATABILITY
|
||||
if (typeOfSelect == DB_SELECT_WHERE && from && wxStrlen(from))
|
||||
appendFromClause = TRUE;
|
||||
#else
|
||||
if (typeOfSelect == DB_SELECT_WHERE && from.Length())
|
||||
appendFromClause = TRUE;
|
||||
#endif
|
||||
|
||||
// Add the column list
|
||||
int i;
|
||||
@@ -815,14 +820,18 @@ void wxDbTable::GetSelectStmt(char *pSqlStmt, int typeOfSelect, bool distinct)
|
||||
switch(typeOfSelect)
|
||||
{
|
||||
case DB_SELECT_WHERE:
|
||||
#if wxODBC_BACKWARD_COMPATABILITY
|
||||
if (where && wxStrlen(where)) // May not want a where clause!!!
|
||||
#else
|
||||
if (where.Length()) // May not want a where clause!!!
|
||||
#endif
|
||||
{
|
||||
wxStrcat(pSqlStmt, " WHERE ");
|
||||
wxStrcat(pSqlStmt, where);
|
||||
}
|
||||
break;
|
||||
case DB_SELECT_KEYFIELDS:
|
||||
GetWhereClause(whereClause, DB_WHERE_KEYFIELDS);
|
||||
BuildWhereClause(whereClause, DB_WHERE_KEYFIELDS);
|
||||
if (wxStrlen(whereClause))
|
||||
{
|
||||
wxStrcat(pSqlStmt, " WHERE ");
|
||||
@@ -830,7 +839,7 @@ void wxDbTable::GetSelectStmt(char *pSqlStmt, int typeOfSelect, bool distinct)
|
||||
}
|
||||
break;
|
||||
case DB_SELECT_MATCHING:
|
||||
GetWhereClause(whereClause, DB_WHERE_MATCHING);
|
||||
BuildWhereClause(whereClause, DB_WHERE_MATCHING);
|
||||
if (wxStrlen(whereClause))
|
||||
{
|
||||
wxStrcat(pSqlStmt, " WHERE ");
|
||||
@@ -840,7 +849,11 @@ void wxDbTable::GetSelectStmt(char *pSqlStmt, int typeOfSelect, bool distinct)
|
||||
}
|
||||
|
||||
// Append the ORDER BY clause
|
||||
#if wxODBC_BACKWARD_COMPATABILITY
|
||||
if (orderBy && wxStrlen(orderBy))
|
||||
#else
|
||||
if (orderBy.Length())
|
||||
#endif
|
||||
{
|
||||
wxStrcat(pSqlStmt, " ORDER BY ");
|
||||
wxStrcat(pSqlStmt, orderBy);
|
||||
@@ -852,7 +865,7 @@ void wxDbTable::GetSelectStmt(char *pSqlStmt, int typeOfSelect, bool distinct)
|
||||
if (selectForUpdate && CanSelectForUpdate())
|
||||
wxStrcat(pSqlStmt, " FOR UPDATE");
|
||||
|
||||
} // wxDbTable::GetSelectStmt()
|
||||
} // wxDbTable::BuildSelectStmt()
|
||||
|
||||
|
||||
/********** wxDbTable::GetRowNum() **********/
|
||||
@@ -948,13 +961,13 @@ bool wxDbTable::CreateTable(bool attemptDrop)
|
||||
switch(colDefs[i].DbDataType)
|
||||
{
|
||||
case DB_DATA_TYPE_VARCHAR:
|
||||
sqlStmt += pDb->typeInfVarchar.TypeName; break;
|
||||
sqlStmt += pDb->GetTypeInfVarchar().TypeName; break;
|
||||
case DB_DATA_TYPE_INTEGER:
|
||||
sqlStmt += pDb->typeInfInteger.TypeName; break;
|
||||
sqlStmt += pDb->GetTypeInfInteger().TypeName; break;
|
||||
case DB_DATA_TYPE_FLOAT:
|
||||
sqlStmt += pDb->typeInfFloat.TypeName; break;
|
||||
sqlStmt += pDb->GetTypeInfFloat().TypeName; break;
|
||||
case DB_DATA_TYPE_DATE:
|
||||
sqlStmt += pDb->typeInfDate.TypeName; break;
|
||||
sqlStmt += pDb->GetTypeInfDate().TypeName; break;
|
||||
}
|
||||
// For varchars, append the size of the string
|
||||
if (colDefs[i].DbDataType == DB_DATA_TYPE_VARCHAR)
|
||||
@@ -964,7 +977,7 @@ bool wxDbTable::CreateTable(bool attemptDrop)
|
||||
// wxStrcat(sqlStmt, itoa(colDefs[i].SzDataObj, s, 10));
|
||||
// wxStrcat(sqlStmt, ")");
|
||||
s.sprintf("(%d)", colDefs[i].SzDataObj);
|
||||
sqlStmt += s.GetData();
|
||||
sqlStmt += s.c_str();
|
||||
}
|
||||
|
||||
if (pDb->Dbms() == dbmsSYBASE_ASE || pDb->Dbms() == dbmsMY_SQL)
|
||||
@@ -1015,14 +1028,14 @@ bool wxDbTable::CreateTable(bool attemptDrop)
|
||||
// Append the closing parentheses for the create table statement
|
||||
sqlStmt += ")";
|
||||
|
||||
pDb->WriteSqlLog(sqlStmt.GetData());
|
||||
pDb->WriteSqlLog(sqlStmt.c_str());
|
||||
|
||||
#ifdef DBDEBUG_CONSOLE
|
||||
cout << endl << sqlStmt.GetData() << endl;
|
||||
cout << endl << sqlStmt.c_str() << endl;
|
||||
#endif
|
||||
|
||||
// Execute the CREATE TABLE statement
|
||||
RETCODE retcode = SQLExecDirect(hstmt, (UCHAR FAR *) sqlStmt.GetData(), SQL_NTS);
|
||||
RETCODE retcode = SQLExecDirect(hstmt, (UCHAR FAR *) sqlStmt.c_str(), SQL_NTS);
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO)
|
||||
{
|
||||
pDb->DispAllErrors(henv, hdbc, hstmt);
|
||||
@@ -1055,13 +1068,13 @@ bool wxDbTable::DropTable()
|
||||
|
||||
sqlStmt.sprintf("DROP TABLE %s", tableName);
|
||||
|
||||
pDb->WriteSqlLog(sqlStmt.GetData());
|
||||
pDb->WriteSqlLog(sqlStmt.c_str());
|
||||
|
||||
#ifdef DBDEBUG_CONSOLE
|
||||
cout << endl << sqlStmt.GetData() << endl;
|
||||
cout << endl << sqlStmt.c_str() << endl;
|
||||
#endif
|
||||
|
||||
if (SQLExecDirect(hstmt, (UCHAR FAR *) sqlStmt.GetData(), SQL_NTS) != SQL_SUCCESS)
|
||||
if (SQLExecDirect(hstmt, (UCHAR FAR *) sqlStmt.c_str(), SQL_NTS) != SQL_SUCCESS)
|
||||
{
|
||||
// Check for "Base table not found" error and ignore
|
||||
pDb->GetNextError(henv, hdbc, hstmt);
|
||||
@@ -1133,14 +1146,14 @@ bool wxDbTable::CreateIndex(const char * idxName, bool unique, int noIdxCols, wx
|
||||
// Append closing parentheses
|
||||
sqlStmt += ")";
|
||||
|
||||
pDb->WriteSqlLog(sqlStmt.GetData());
|
||||
pDb->WriteSqlLog(sqlStmt.c_str());
|
||||
|
||||
#ifdef DBDEBUG_CONSOLE
|
||||
cout << endl << sqlStmt.GetData() << endl << endl;
|
||||
cout << endl << sqlStmt.c_str() << endl << endl;
|
||||
#endif
|
||||
|
||||
// Execute the CREATE INDEX statement
|
||||
if (SQLExecDirect(hstmt, (UCHAR FAR *) sqlStmt.GetData(), SQL_NTS) != SQL_SUCCESS)
|
||||
if (SQLExecDirect(hstmt, (UCHAR FAR *) sqlStmt.c_str(), SQL_NTS) != SQL_SUCCESS)
|
||||
{
|
||||
pDb->DispAllErrors(henv, hdbc, hstmt);
|
||||
pDb->RollbackTrans();
|
||||
@@ -1177,13 +1190,13 @@ bool wxDbTable::DropIndex(const char * idxName)
|
||||
else
|
||||
sqlStmt.sprintf("DROP INDEX %s",idxName);
|
||||
|
||||
pDb->WriteSqlLog(sqlStmt.GetData());
|
||||
pDb->WriteSqlLog(sqlStmt.c_str());
|
||||
|
||||
#ifdef DBDEBUG_CONSOLE
|
||||
cout << endl << sqlStmt.GetData() << endl;
|
||||
cout << endl << sqlStmt.c_str() << endl;
|
||||
#endif
|
||||
|
||||
if (SQLExecDirect(hstmt, (UCHAR FAR *) sqlStmt.GetData(), SQL_NTS) != SQL_SUCCESS)
|
||||
if (SQLExecDirect(hstmt, (UCHAR FAR *) sqlStmt.c_str(), SQL_NTS) != SQL_SUCCESS)
|
||||
{
|
||||
// Check for "Index not found" error and ignore
|
||||
pDb->GetNextError(henv, hdbc, hstmt);
|
||||
@@ -1256,7 +1269,7 @@ bool wxDbTable::Update(void)
|
||||
char sqlStmt[DB_MAX_STATEMENT_LEN];
|
||||
|
||||
// Build the SQL UPDATE statement
|
||||
GetUpdateStmt(sqlStmt, DB_UPD_KEYFIELDS);
|
||||
BuildUpdateStmt(sqlStmt, DB_UPD_KEYFIELDS);
|
||||
|
||||
pDb->WriteSqlLog(sqlStmt);
|
||||
|
||||
@@ -1294,7 +1307,7 @@ bool wxDbTable::UpdateWhere(const char *pWhereClause)
|
||||
char sqlStmt[DB_MAX_STATEMENT_LEN];
|
||||
|
||||
// Build the SQL UPDATE statement
|
||||
GetUpdateStmt(sqlStmt, DB_UPD_WHERE, pWhereClause);
|
||||
BuildUpdateStmt(sqlStmt, DB_UPD_WHERE, pWhereClause);
|
||||
|
||||
pDb->WriteSqlLog(sqlStmt);
|
||||
|
||||
@@ -1318,7 +1331,7 @@ bool wxDbTable::Delete(void)
|
||||
char sqlStmt[DB_MAX_STATEMENT_LEN];
|
||||
|
||||
// Build the SQL DELETE statement
|
||||
GetDeleteStmt(sqlStmt, DB_DEL_KEYFIELDS);
|
||||
BuildDeleteStmt(sqlStmt, DB_DEL_KEYFIELDS);
|
||||
|
||||
pDb->WriteSqlLog(sqlStmt);
|
||||
|
||||
@@ -1338,7 +1351,7 @@ bool wxDbTable::DeleteWhere(const char *pWhereClause)
|
||||
char sqlStmt[DB_MAX_STATEMENT_LEN];
|
||||
|
||||
// Build the SQL DELETE statement
|
||||
GetDeleteStmt(sqlStmt, DB_DEL_WHERE, pWhereClause);
|
||||
BuildDeleteStmt(sqlStmt, DB_DEL_WHERE, pWhereClause);
|
||||
|
||||
pDb->WriteSqlLog(sqlStmt);
|
||||
|
||||
@@ -1358,7 +1371,7 @@ bool wxDbTable::DeleteMatching(void)
|
||||
char sqlStmt[DB_MAX_STATEMENT_LEN];
|
||||
|
||||
// Build the SQL DELETE statement
|
||||
GetDeleteStmt(sqlStmt, DB_DEL_MATCHING);
|
||||
BuildDeleteStmt(sqlStmt, DB_DEL_MATCHING);
|
||||
|
||||
pDb->WriteSqlLog(sqlStmt);
|
||||
|
||||
@@ -1368,8 +1381,8 @@ bool wxDbTable::DeleteMatching(void)
|
||||
} // wxDbTable::DeleteMatching()
|
||||
|
||||
|
||||
/********** wxDbTable::GetUpdateStmt() **********/
|
||||
void wxDbTable::GetUpdateStmt(char *pSqlStmt, int typeOfUpd, const char *pWhereClause)
|
||||
/********** wxDbTable::BuildUpdateStmt() **********/
|
||||
void wxDbTable::BuildUpdateStmt(char *pSqlStmt, int typeOfUpd, const char *pWhereClause)
|
||||
{
|
||||
assert(!queryOnly);
|
||||
if (queryOnly)
|
||||
@@ -1423,18 +1436,18 @@ void wxDbTable::GetUpdateStmt(char *pSqlStmt, int typeOfUpd, const char *pWhereC
|
||||
}
|
||||
// Unable to delete by ROWID, so build a WHERE
|
||||
// clause based on the keyfields.
|
||||
GetWhereClause(whereClause, DB_WHERE_KEYFIELDS);
|
||||
BuildWhereClause(whereClause, DB_WHERE_KEYFIELDS);
|
||||
wxStrcat(pSqlStmt, whereClause);
|
||||
break;
|
||||
case DB_UPD_WHERE:
|
||||
wxStrcat(pSqlStmt, pWhereClause);
|
||||
break;
|
||||
}
|
||||
} // GetUpdateStmt()
|
||||
} // BuildUpdateStmt()
|
||||
|
||||
|
||||
/********** wxDbTable::GetDeleteStmt() **********/
|
||||
void wxDbTable::GetDeleteStmt(char *pSqlStmt, int typeOfDel, const char *pWhereClause)
|
||||
/********** wxDbTable::BuildDeleteStmt() **********/
|
||||
void wxDbTable::BuildDeleteStmt(char *pSqlStmt, int typeOfDel, const char *pWhereClause)
|
||||
{
|
||||
assert(!queryOnly);
|
||||
if (queryOnly)
|
||||
@@ -1479,26 +1492,26 @@ void wxDbTable::GetDeleteStmt(char *pSqlStmt, int typeOfDel, const char *pWhereC
|
||||
}
|
||||
// Unable to delete by ROWID, so build a WHERE
|
||||
// clause based on the keyfields.
|
||||
GetWhereClause(whereClause, DB_WHERE_KEYFIELDS);
|
||||
BuildWhereClause(whereClause, DB_WHERE_KEYFIELDS);
|
||||
wxStrcat(pSqlStmt, whereClause);
|
||||
break;
|
||||
case DB_DEL_WHERE:
|
||||
wxStrcat(pSqlStmt, pWhereClause);
|
||||
break;
|
||||
case DB_DEL_MATCHING:
|
||||
GetWhereClause(whereClause, DB_WHERE_MATCHING);
|
||||
BuildWhereClause(whereClause, DB_WHERE_MATCHING);
|
||||
wxStrcat(pSqlStmt, whereClause);
|
||||
break;
|
||||
}
|
||||
|
||||
} // GetDeleteStmt()
|
||||
} // BuildDeleteStmt()
|
||||
|
||||
|
||||
/********** wxDbTable::GetWhereClause() **********/
|
||||
void wxDbTable::GetWhereClause(char *pWhereClause, int typeOfWhere,
|
||||
const char *qualTableName, bool useLikeComparison)
|
||||
/********** wxDbTable::BuildWhereClause() **********/
|
||||
void wxDbTable::BuildWhereClause(char *pWhereClause, int typeOfWhere,
|
||||
const char *qualTableName, bool useLikeComparison)
|
||||
/*
|
||||
* Note: GetWhereClause() currently ignores timestamp columns.
|
||||
* Note: BuildWhereClause() currently ignores timestamp columns.
|
||||
* They are not included as part of the where clause.
|
||||
*/
|
||||
{
|
||||
@@ -1559,7 +1572,7 @@ void wxDbTable::GetWhereClause(char *pWhereClause, int typeOfWhere,
|
||||
wxStrcat(pWhereClause, colValue);
|
||||
}
|
||||
}
|
||||
} // wxDbTable::GetWhereClause()
|
||||
} // wxDbTable::BuildWhereClause()
|
||||
|
||||
|
||||
/********** wxDbTable::IsColNull() **********/
|
||||
@@ -1839,30 +1852,37 @@ ULONG wxDbTable::Count(const char *args)
|
||||
sqlStmt += args;
|
||||
sqlStmt += ") FROM ";
|
||||
sqlStmt += queryTableName;
|
||||
|
||||
#if wxODBC_BACKWARD_COMPATABILITY
|
||||
if (from && wxStrlen(from))
|
||||
#else
|
||||
if (from.Length())
|
||||
#endif
|
||||
sqlStmt += from;
|
||||
|
||||
// Add the where clause if one is provided
|
||||
#if wxODBC_BACKWARD_COMPATABILITY
|
||||
if (where && wxStrlen(where))
|
||||
#else
|
||||
if (where.Length())
|
||||
#endif
|
||||
{
|
||||
sqlStmt += " WHERE ";
|
||||
sqlStmt += where;
|
||||
}
|
||||
|
||||
pDb->WriteSqlLog(sqlStmt.GetData());
|
||||
pDb->WriteSqlLog(sqlStmt.c_str());
|
||||
|
||||
// Initialize the Count cursor if it's not already initialized
|
||||
if (!hstmtCount)
|
||||
{
|
||||
hstmtCount = NewCursor(FALSE,FALSE);
|
||||
hstmtCount = GetNewCursor(FALSE,FALSE);
|
||||
assert(hstmtCount);
|
||||
if (!hstmtCount)
|
||||
return(0);
|
||||
}
|
||||
|
||||
// Execute the SQL statement
|
||||
if (SQLExecDirect(*hstmtCount, (UCHAR FAR *) sqlStmt.GetData(), SQL_NTS) != SQL_SUCCESS)
|
||||
if (SQLExecDirect(*hstmtCount, (UCHAR FAR *) sqlStmt.c_str(), SQL_NTS) != SQL_SUCCESS)
|
||||
{
|
||||
pDb->DispAllErrors(henv, hdbc, *hstmtCount);
|
||||
return(0);
|
||||
@@ -1900,11 +1920,14 @@ bool wxDbTable::Refresh(void)
|
||||
// Switch to the internal cursor so any active cursors are not corrupted
|
||||
HSTMT currCursor = GetCursor();
|
||||
hstmt = hstmtInternal;
|
||||
|
||||
#if wxODBC_BACKWARD_COMPATABILITY
|
||||
// Save the where and order by clauses
|
||||
char *saveWhere = where;
|
||||
char *saveOrderBy = orderBy;
|
||||
|
||||
#else
|
||||
wxString saveWhere = where;
|
||||
wxString saveOrderBy = orderBy;
|
||||
#endif
|
||||
// Build a where clause to refetch the record with. Try and use the
|
||||
// ROWID if it's available, ow use the key fields.
|
||||
char whereClause[DB_MAX_WHERE_CLAUSE_LEN+1];
|
||||
@@ -1928,11 +1951,11 @@ bool wxDbTable::Refresh(void)
|
||||
|
||||
// If unable to use the ROWID, build a where clause from the keyfields
|
||||
if (wxStrlen(whereClause) == 0)
|
||||
GetWhereClause(whereClause, DB_WHERE_KEYFIELDS, queryTableName);
|
||||
BuildWhereClause(whereClause, DB_WHERE_KEYFIELDS, queryTableName);
|
||||
|
||||
// Requery the record
|
||||
where = whereClause;
|
||||
orderBy = 0;
|
||||
orderBy = "";
|
||||
if (!Query())
|
||||
result = FALSE;
|
||||
|
||||
@@ -1984,8 +2007,8 @@ bool wxDbTable::SetNull(const char *colName)
|
||||
} // wxDbTable::SetNull(char *colName)
|
||||
|
||||
|
||||
/********** wxDbTable::NewCursor() **********/
|
||||
HSTMT *wxDbTable::NewCursor(bool setCursor, bool bindColumns)
|
||||
/********** wxDbTable::GetNewCursor() **********/
|
||||
HSTMT *wxDbTable::GetNewCursor(bool setCursor, bool bindColumns)
|
||||
{
|
||||
HSTMT *newHSTMT = new HSTMT;
|
||||
assert(newHSTMT);
|
||||
@@ -2020,7 +2043,7 @@ HSTMT *wxDbTable::NewCursor(bool setCursor, bool bindColumns)
|
||||
|
||||
return(newHSTMT);
|
||||
|
||||
} // wxDbTable::NewCursor()
|
||||
} // wxDbTable::GetNewCursor()
|
||||
|
||||
|
||||
/********** wxDbTable::DeleteCursor() **********/
|
||||
|
Reference in New Issue
Block a user