Updated the Remstar ODBC files, got the db sample compiling; added Freq and SubString
to wxString git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1283 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Binary file not shown.
@@ -5,6 +5,8 @@
|
|||||||
// source such as opening and closing the data source.
|
// source such as opening and closing the data source.
|
||||||
// Author: Doug Card
|
// Author: Doug Card
|
||||||
// Modified by:
|
// Modified by:
|
||||||
|
// Mods: Dec, 1998: Added support for SQL statement logging and database
|
||||||
|
// cataloging
|
||||||
// Created: 9.96
|
// Created: 9.96
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) 1996 Remstar International, Inc.
|
// Copyright: (c) 1996 Remstar International, Inc.
|
||||||
@@ -18,6 +20,7 @@
|
|||||||
// 3) These classes may not be distributed as part of any other class library,
|
// 3) These classes may not be distributed as part of any other class library,
|
||||||
// DLL, text (written or electronic), other than a complete distribution of
|
// DLL, text (written or electronic), other than a complete distribution of
|
||||||
// the wxWindows GUI development toolkit.
|
// the wxWindows GUI development toolkit.
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -27,12 +30,12 @@
|
|||||||
|
|
||||||
#ifndef DB_DOT_H
|
#ifndef DB_DOT_H
|
||||||
#define DB_DOT_H
|
#define DB_DOT_H
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface "db.h"
|
#pragma interface "db.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(wx_msw) || defined(WIN32)
|
#if defined(__WXMSW__) || defined(WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -45,20 +48,6 @@ enum enumDummy {enumDum1};
|
|||||||
#define SQL_C_BOOLEAN (sizeof(int) == 2 ? SQL_C_USHORT : SQL_C_ULONG)
|
#define SQL_C_BOOLEAN (sizeof(int) == 2 ? SQL_C_USHORT : SQL_C_ULONG)
|
||||||
#define SQL_C_ENUM (sizeof(enumDummy) == 2 ? SQL_C_USHORT : SQL_C_ULONG) //glt 2-21-97
|
#define SQL_C_ENUM (sizeof(enumDummy) == 2 ? SQL_C_USHORT : SQL_C_ULONG) //glt 2-21-97
|
||||||
|
|
||||||
/*
|
|
||||||
#ifndef Bool
|
|
||||||
#define Bool int
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TRUE
|
|
||||||
#define TRUE 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FALSE
|
|
||||||
#define FALSE 0
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Database Globals
|
// Database Globals
|
||||||
const DB_TYPE_NAME_LEN = 40;
|
const DB_TYPE_NAME_LEN = 40;
|
||||||
const DB_MAX_STATEMENT_LEN = 2048;
|
const DB_MAX_STATEMENT_LEN = 2048;
|
||||||
@@ -224,15 +213,23 @@ public:
|
|||||||
int sqlDataType;
|
int sqlDataType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum sqlLog
|
||||||
|
{
|
||||||
|
sqlLogOFF,
|
||||||
|
sqlLogON
|
||||||
|
};
|
||||||
|
|
||||||
class wxDB
|
class wxDB
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Private data
|
// Private data
|
||||||
bool dbIsOpen;
|
bool dbIsOpen;
|
||||||
char *dsn; // Data source name
|
char *dsn; // Data source name
|
||||||
char *uid; // User ID
|
char *uid; // User ID
|
||||||
char *authStr; // Authorization string (password)
|
char *authStr; // Authorization string (password)
|
||||||
|
FILE *fpSqlLog; // Sql Log file pointer
|
||||||
|
enum sqlLog sqlLogState; // On or Off
|
||||||
|
|
||||||
// Private member functions
|
// Private member functions
|
||||||
bool getDbInfo(void);
|
bool getDbInfo(void);
|
||||||
@@ -303,28 +300,31 @@ public:
|
|||||||
|
|
||||||
// Public member functions
|
// Public member functions
|
||||||
wxDB(HENV &aHenv);
|
wxDB(HENV &aHenv);
|
||||||
bool Open(char *Dsn, char *Uid, char *AuthStr); // Data Source Name, User ID, Password
|
bool Open(char *Dsn, char *Uid, char *AuthStr); // Data Source Name, User ID, Password
|
||||||
void Close(void);
|
void Close(void);
|
||||||
bool CommitTrans(void);
|
bool CommitTrans(void);
|
||||||
bool RollbackTrans(void);
|
bool RollbackTrans(void);
|
||||||
bool DispAllErrors(HENV aHenv, HDBC aHdbc = SQL_NULL_HDBC, HSTMT aHstmt = SQL_NULL_HSTMT);
|
bool DispAllErrors(HENV aHenv, HDBC aHdbc = SQL_NULL_HDBC, HSTMT aHstmt = SQL_NULL_HSTMT);
|
||||||
bool GetNextError(HENV aHenv, HDBC aHdbc = SQL_NULL_HDBC, HSTMT aHstmt = SQL_NULL_HSTMT);
|
bool GetNextError(HENV aHenv, HDBC aHdbc = SQL_NULL_HDBC, HSTMT aHstmt = SQL_NULL_HSTMT);
|
||||||
void DispNextError(void);
|
void DispNextError(void);
|
||||||
bool CreateView(char *viewName, char *colList, char *pSqlStmt);
|
bool CreateView(char *viewName, char *colList, char *pSqlStmt);
|
||||||
bool ExecSql(char *pSqlStmt);
|
bool ExecSql(char *pSqlStmt);
|
||||||
bool Grant(int privileges, char *tableName, char *userList = "PUBLIC");
|
bool Grant(int privileges, char *tableName, char *userList = "PUBLIC");
|
||||||
int TranslateSqlState(char *SQLState);
|
int TranslateSqlState(char *SQLState);
|
||||||
CcolInf *GetColumns(char *tableName[]);
|
bool Catalog(char *userID, char *fileName = "Catalog.txt");
|
||||||
char *GetDatabaseName(void) {return dbInf.dbmsName;}
|
CcolInf *GetColumns(char *tableName[]);
|
||||||
char *GetDataSource(void) {return dsn;}
|
char *GetDatabaseName(void) {return dbInf.dbmsName;}
|
||||||
char *GetUsername(void) {return uid;}
|
char *GetDataSource(void) {return dsn;}
|
||||||
char *GetPassword(void) {return authStr;}
|
char *GetUsername(void) {return uid;}
|
||||||
bool IsOpen(void) {return dbIsOpen;}
|
char *GetPassword(void) {return authStr;}
|
||||||
HENV GetHENV(void) {return henv;}
|
bool IsOpen(void) {return dbIsOpen;}
|
||||||
HDBC GetHDBC(void) {return hdbc;}
|
HENV GetHENV(void) {return henv;}
|
||||||
HSTMT GetHSTMT(void) {return hstmt;}
|
HDBC GetHDBC(void) {return hdbc;}
|
||||||
bool TableExists(char *tableName); // Table name can refer to a table, view, alias or synonym
|
HSTMT GetHSTMT(void) {return hstmt;}
|
||||||
void LogError(char *errMsg, char *SQLState = 0) {logError(errMsg, SQLState);}
|
bool TableExists(char *tableName); // Table name can refer to a table, view, alias or synonym
|
||||||
|
void LogError(char *errMsg, char *SQLState = 0) {logError(errMsg, SQLState);}
|
||||||
|
bool SqlLog(enum sqlLog state, char *filename = "sqllog.txt", bool append = FALSE);
|
||||||
|
bool WriteSqlLog(char *logMsg);
|
||||||
|
|
||||||
}; // wxDB
|
}; // wxDB
|
||||||
|
|
||||||
@@ -359,4 +359,3 @@ bool GetDataSource(HENV henv, char *Dsn, SWORD DsnMax, char *DsDesc, SWORD DsDes
|
|||||||
UWORD direction = SQL_FETCH_NEXT);
|
UWORD direction = SQL_FETCH_NEXT);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -46,24 +46,24 @@ const ROWID_LEN = 24; // 18 is the max, 24 is in case it gets larger
|
|||||||
class CcolDef
|
class CcolDef
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
char ColName[DB_MAX_COLUMN_NAME_LEN+1]; // Column Name glt 4/19/97 added one for the null terminator
|
char ColName[DB_MAX_COLUMN_NAME_LEN+1]; // Column Name glt 4/19/97 added one for the null terminator
|
||||||
int DbDataType; // Logical Data Type; e.g. DB_DATA_TYPE_INTEGER
|
int DbDataType; // Logical Data Type; e.g. DB_DATA_TYPE_INTEGER
|
||||||
int SqlCtype; // C data type; e.g. SQL_C_LONG
|
int SqlCtype; // C data type; e.g. SQL_C_LONG
|
||||||
void *PtrDataObj; // Address of the data object
|
void *PtrDataObj; // Address of the data object
|
||||||
int SzDataObj; // Size, in bytes, of the data object
|
int SzDataObj; // Size, in bytes, of the data object
|
||||||
bool KeyField; // TRUE if this column is part of the PRIMARY KEY to the table; Date fields should NOT be KeyFields.
|
bool KeyField; // TRUE if this column is part of the PRIMARY KEY to the table; Date fields should NOT be KeyFields.
|
||||||
bool Updateable; // Specifies whether this column is updateable
|
bool Updateable; // Specifies whether this column is updateable
|
||||||
bool InsertAllowed; // Specifies whether this column should be included in an INSERT statement
|
bool InsertAllowed; // Specifies whether this column should be included in an INSERT statement
|
||||||
bool DerivedCol; // Specifies whether this column is a derived value
|
bool DerivedCol; // Specifies whether this column is a derived value
|
||||||
SDWORD CbValue; // Internal use only!!!
|
SDWORD CbValue; // Internal use only!!!
|
||||||
}; // CcolDef
|
}; // CcolDef
|
||||||
|
|
||||||
// This structure is used when creating secondary indexes.
|
// This structure is used when creating secondary indexes.
|
||||||
class CidxDef
|
class CidxDef
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
char ColName[DB_MAX_COLUMN_NAME_LEN+1]; // Column Name glt 4/19/97 added one for the null terminator
|
char ColName[DB_MAX_COLUMN_NAME_LEN+1]; // Column Name glt 4/19/97 added one for the null terminator
|
||||||
bool Ascending;
|
bool Ascending;
|
||||||
}; // CidxDef
|
}; // CidxDef
|
||||||
|
|
||||||
class wxTable
|
class wxTable
|
||||||
@@ -106,9 +106,10 @@ public:
|
|||||||
// Column Definitions
|
// Column Definitions
|
||||||
CcolDef *colDefs; // Array of CcolDef structures
|
CcolDef *colDefs; // Array of CcolDef structures
|
||||||
|
|
||||||
// Where and Order By clauses
|
// Where, Order By and From clauses
|
||||||
char *where; // Standard SQL where clause, minus the word WHERE
|
char *where; // Standard SQL where clause, minus the word WHERE
|
||||||
char *orderBy; // Standard SQL order by clause, minus the ORDER BY
|
char *orderBy; // Standard SQL order by clause, minus the ORDER BY
|
||||||
|
char *from; // Allows for joins in a Ctable::Query(). Format: ",tbl,tbl..."
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
bool selectForUpdate;
|
bool selectForUpdate;
|
||||||
@@ -116,50 +117,49 @@ public:
|
|||||||
// Public member functions
|
// Public member functions
|
||||||
wxTable(wxDB *pwxDB, const char *tblName, const int nCols, const char *qryTblName = 0);
|
wxTable(wxDB *pwxDB, const char *tblName, const int nCols, const char *qryTblName = 0);
|
||||||
~wxTable();
|
~wxTable();
|
||||||
bool Open(void);
|
bool Open(void);
|
||||||
bool CreateTable(void);
|
bool CreateTable(void);
|
||||||
bool CreateIndex(char * idxName, bool unique, int noIdxCols, CidxDef *pIdxDefs);
|
bool CreateIndex(char * idxName, bool unique, int noIdxCols, CidxDef *pIdxDefs);
|
||||||
bool CloseCursor(HSTMT cursor);
|
bool CloseCursor(HSTMT cursor);
|
||||||
int Insert(void);
|
int Insert(void);
|
||||||
bool Update(void);
|
bool Update(void);
|
||||||
bool Update(char *pSqlStmt);
|
bool Update(char *pSqlStmt);
|
||||||
bool UpdateWhere(char *pWhereClause);
|
bool UpdateWhere(char *pWhereClause);
|
||||||
bool Delete(void);
|
bool Delete(void);
|
||||||
bool DeleteWhere(char *pWhereClause);
|
bool DeleteWhere(char *pWhereClause);
|
||||||
bool DeleteMatching(void);
|
bool DeleteMatching(void);
|
||||||
bool Query(bool forUpdate = FALSE, bool distinct = FALSE);
|
virtual bool Query(bool forUpdate = FALSE, bool distinct = FALSE);
|
||||||
bool QueryBySqlStmt(char *pSqlStmt);
|
bool QueryBySqlStmt(char *pSqlStmt);
|
||||||
bool QueryMatching(bool forUpdate = FALSE, bool distinct = FALSE);
|
bool QueryMatching(bool forUpdate = FALSE, bool distinct = FALSE);
|
||||||
bool QueryOnKeyFields(bool forUpdate = FALSE, bool distinct = FALSE);
|
bool QueryOnKeyFields(bool forUpdate = FALSE, bool distinct = FALSE);
|
||||||
bool GetNext(void) { return(getRec(SQL_FETCH_NEXT)); }
|
bool GetNext(void) { return(getRec(SQL_FETCH_NEXT)); }
|
||||||
bool operator++(int) { return(getRec(SQL_FETCH_NEXT)); }
|
bool operator++(int) { return(getRec(SQL_FETCH_NEXT)); }
|
||||||
#ifndef FWD_ONLY_CURSORS
|
#ifndef FWD_ONLY_CURSORS
|
||||||
bool GetPrev(void) { return(getRec(SQL_FETCH_PRIOR)); }
|
bool GetPrev(void) { return(getRec(SQL_FETCH_PRIOR)); }
|
||||||
bool operator--(int) { return(getRec(SQL_FETCH_PRIOR)); }
|
bool operator--(int) { return(getRec(SQL_FETCH_PRIOR)); }
|
||||||
bool GetFirst(void) { return(getRec(SQL_FETCH_FIRST)); }
|
bool GetFirst(void) { return(getRec(SQL_FETCH_FIRST)); }
|
||||||
bool GetLast(void) { return(getRec(SQL_FETCH_LAST)); }
|
bool GetLast(void) { return(getRec(SQL_FETCH_LAST)); }
|
||||||
#endif
|
#endif
|
||||||
bool IsCursorClosedOnCommit(void);
|
bool IsCursorClosedOnCommit(void);
|
||||||
bool IsColNull(int colNo);
|
bool IsColNull(int colNo);
|
||||||
UWORD GetRowNum(void);
|
UWORD GetRowNum(void);
|
||||||
void GetSelectStmt(char *pSqlStmt, int typeOfSelect, bool distinct);
|
void GetSelectStmt(char *pSqlStmt, int typeOfSelect, bool distinct);
|
||||||
void GetDeleteStmt(char *pSqlStmt, int typeOfDel, char *pWhereClause = 0);
|
void GetDeleteStmt(char *pSqlStmt, int typeOfDel, char *pWhereClause = 0);
|
||||||
void GetUpdateStmt(char *pSqlStmt, int typeOfUpd, char *pWhereClause = 0);
|
void GetUpdateStmt(char *pSqlStmt, int typeOfUpd, char *pWhereClause = 0);
|
||||||
void GetWhereClause(char *pWhereClause, int typeOfWhere);
|
void GetWhereClause(char *pWhereClause, int typeOfWhere, char *qualTableName = 0);
|
||||||
bool CanSelectForUpdate(void);
|
bool CanSelectForUpdate(void);
|
||||||
bool CanUpdByROWID(void);
|
bool CanUpdByROWID(void);
|
||||||
void ClearMemberVars(void);
|
void ClearMemberVars(void);
|
||||||
bool SetQueryTimeout(UDWORD nSeconds);
|
bool SetQueryTimeout(UDWORD nSeconds);
|
||||||
void SetColDefs (int index, char *fieldName, int dataType, void *pData, int cType,
|
void SetColDefs (int index, char *fieldName, int dataType, void *pData, int cType,
|
||||||
int size, bool keyField = FALSE, bool upd = TRUE,
|
int size, bool keyField = FALSE, bool upd = TRUE,
|
||||||
bool insAllow = TRUE, bool derivedCol = FALSE);
|
bool insAllow = TRUE, bool derivedCol = FALSE);
|
||||||
bool SetCursor(int cursorNo = DB_CURSOR0);
|
bool SetCursor(int cursorNo = DB_CURSOR0);
|
||||||
int GetCursor(void) { return(currCursorNo); }
|
int GetCursor(void) { return(currCursorNo); }
|
||||||
ULONG Count(void);
|
ULONG Count(void);
|
||||||
int DB_STATUS(void) { return(pDb->DB_STATUS); }
|
int DB_STATUS(void) { return(pDb->DB_STATUS); }
|
||||||
bool Refresh(void);
|
bool Refresh(void);
|
||||||
|
|
||||||
}; // wxTable
|
}; // wxTable
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -433,6 +433,11 @@ public:
|
|||||||
nCount (or till the end if nCount = default value)
|
nCount (or till the end if nCount = default value)
|
||||||
*/
|
*/
|
||||||
wxString Mid(size_t nFirst, size_t nCount = STRING_MAXLEN) const;
|
wxString Mid(size_t nFirst, size_t nCount = STRING_MAXLEN) const;
|
||||||
|
/// Compatibility with wxWindows 1.xx
|
||||||
|
wxString SubString(size_t from, size_t to) const
|
||||||
|
{
|
||||||
|
return Mid(from, (to - from + 1));
|
||||||
|
}
|
||||||
/// get first nCount characters
|
/// get first nCount characters
|
||||||
wxString Left(size_t nCount) const;
|
wxString Left(size_t nCount) const;
|
||||||
/// get all characters before the first occurence of ch
|
/// get all characters before the first occurence of ch
|
||||||
@@ -547,6 +552,8 @@ public:
|
|||||||
{ *this = str + *this; return *this; }
|
{ *this = str + *this; return *this; }
|
||||||
/// same as Len
|
/// same as Len
|
||||||
size_t Length() const { return Len(); }
|
size_t Length() const { return Len(); }
|
||||||
|
/// Count the number of characters
|
||||||
|
int Freq(char ch) const;
|
||||||
/// same as MakeLower
|
/// same as MakeLower
|
||||||
void LowerCase() { MakeLower(); }
|
void LowerCase() { MakeLower(); }
|
||||||
/// same as MakeUpper
|
/// same as MakeUpper
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,9 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
#pragma interface "dbtest.h"
|
#pragma interface "dbtest.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
#include <wx/dbtable.h>
|
#include <wx/dbtable.h>
|
||||||
@@ -104,7 +106,7 @@ class DatabaseDemoApp: public wxApp
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Cparameters params;
|
Cparameters params;
|
||||||
wxFrame *OnInit(void);
|
bool OnInit();
|
||||||
}; // DatabaseDemoApp
|
}; // DatabaseDemoApp
|
||||||
|
|
||||||
DECLARE_APP(DatabaseDemoApp)
|
DECLARE_APP(DatabaseDemoApp)
|
||||||
@@ -117,14 +119,19 @@ class DatabaseDemoFrame: public wxFrame
|
|||||||
CparameterDlg *pParamDlg;
|
CparameterDlg *pParamDlg;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DatabaseDemoFrame(wxFrame *frame, char *title, int x, int y, int w, int h);
|
DatabaseDemoFrame(wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& sz);
|
||||||
|
|
||||||
void OnMenuCommand(int id);
|
void OnCloseWindow(wxCloseEvent& event);
|
||||||
bool OnClose(void);
|
void OnCreate(wxCommandEvent& event);
|
||||||
|
void OnExit(wxCommandEvent& event);
|
||||||
|
void OnEditParameters(wxCommandEvent& event);
|
||||||
|
void OnAbout(wxCommandEvent& event);
|
||||||
|
|
||||||
void CreateDataTable();
|
void CreateDataTable();
|
||||||
void BuildEditorDialog();
|
void BuildEditorDialog();
|
||||||
void BuildParameterDialog(wxWindow *parent);
|
void BuildParameterDialog(wxWindow *parent);
|
||||||
|
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
}; // DatabaseDemoFrame
|
}; // DatabaseDemoFrame
|
||||||
|
|
||||||
|
|
||||||
@@ -141,13 +148,13 @@ class CeditorDlg : public wxPanel
|
|||||||
wxButton *pCreateBtn, *pEditBtn, *pDeleteBtn, *pCopyBtn, *pSaveBtn, *pCancelBtn;
|
wxButton *pCreateBtn, *pEditBtn, *pDeleteBtn, *pCopyBtn, *pSaveBtn, *pCancelBtn;
|
||||||
wxButton *pPrevBtn, *pNextBtn, *pQueryBtn, *pResetBtn, *pDoneBtn, *pHelpBtn;
|
wxButton *pPrevBtn, *pNextBtn, *pQueryBtn, *pResetBtn, *pDoneBtn, *pHelpBtn;
|
||||||
wxButton *pNameListBtn;
|
wxButton *pNameListBtn;
|
||||||
wxText *pNameTxt, *pAddress1Txt, *pAddress2Txt,*pCityTxt, *pStateTxt, *pCountryTxt,*pPostalCodeTxt;
|
wxTextCtrl *pNameTxt, *pAddress1Txt, *pAddress2Txt,*pCityTxt, *pStateTxt, *pCountryTxt,*pPostalCodeTxt;
|
||||||
wxMessage *pNameMsg, *pAddress1Msg, *pAddress2Msg,*pCityMsg, *pStateMsg, *pCountryMsg,*pPostalCodeMsg;
|
wxStaticText *pNameMsg, *pAddress1Msg, *pAddress2Msg,*pCityMsg, *pStateMsg, *pCountryMsg,*pPostalCodeMsg;
|
||||||
wxText *pJoinDateTxt,*pContribTxt, *pLinesTxt;
|
wxTextCtrl *pJoinDateTxt,*pContribTxt, *pLinesTxt;
|
||||||
wxMessage *pJoinDateMsg,*pContribMsg, *pLinesMsg;
|
wxStaticText *pJoinDateMsg,*pContribMsg, *pLinesMsg;
|
||||||
wxRadioBox *pDeveloperRadio;
|
wxRadioBox *pDeveloperRadio;
|
||||||
wxChoice *pNativeLangChoice;
|
wxChoice *pNativeLangChoice;
|
||||||
wxMessage *pNativeLangMsg;
|
wxStaticText *pNativeLangMsg;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum DialogModes mode;
|
enum DialogModes mode;
|
||||||
@@ -168,10 +175,51 @@ class CeditorDlg : public wxPanel
|
|||||||
bool GetRec(char *whereStr);
|
bool GetRec(char *whereStr);
|
||||||
}; // CeditorDlg
|
}; // CeditorDlg
|
||||||
|
|
||||||
|
#define EDITOR_DIALOG 199
|
||||||
|
|
||||||
|
// Editor dialog control ids
|
||||||
|
#define EDITOR_DIALOG_FN_GROUP 200
|
||||||
|
#define EDITOR_DIALOG_SEARCH_GROUP 201
|
||||||
|
#define EDITOR_DIALOG_CREATE 202
|
||||||
|
#define EDITOR_DIALOG_EDIT 203
|
||||||
|
#define EDITOR_DIALOG_DELETE 204
|
||||||
|
#define EDITOR_DIALOG_COPY 205
|
||||||
|
#define EDITOR_DIALOG_SAVE 206
|
||||||
|
#define EDITOR_DIALOG_CANCEL 207
|
||||||
|
#define EDITOR_DIALOG_PREV 208
|
||||||
|
#define EDITOR_DIALOG_NEXT 209
|
||||||
|
#define EDITOR_DIALOG_QUERY 211
|
||||||
|
#define EDITOR_DIALOG_RESET 212
|
||||||
|
#define EDITOR_DIALOG_NAME_MSG 213
|
||||||
|
#define EDITOR_DIALOG_NAME_TEXT 214
|
||||||
|
#define EDITOR_DIALOG_LOOKUP 215
|
||||||
|
#define EDITOR_DIALOG_ADDRESS1_MSG 216
|
||||||
|
#define EDITOR_DIALOG_ADDRESS1_TEXT 217
|
||||||
|
#define EDITOR_DIALOG_ADDRESS2_MSG 218
|
||||||
|
#define EDITOR_DIALOG_ADDRESS2_TEXT 219
|
||||||
|
#define EDITOR_DIALOG_CITY_MSG 220
|
||||||
|
#define EDITOR_DIALOG_CITY_TEXT 221
|
||||||
|
#define EDITOR_DIALOG_COUNTRY_MSG 222
|
||||||
|
#define EDITOR_DIALOG_COUNTRY_TEXT 223
|
||||||
|
#define EDITOR_DIALOG_POSTAL_MSG 224
|
||||||
|
#define EDITOR_DIALOG_POSTAL_TEXT 225
|
||||||
|
#define EDITOR_DIALOG_LANG_MSG 226
|
||||||
|
#define EDITOR_DIALOG_LANG_CHOICE 227
|
||||||
|
#define EDITOR_DIALOG_DATE_MSG 228
|
||||||
|
#define EDITOR_DIALOG_DATE_TEXT 229
|
||||||
|
#define EDITOR_DIALOG_CONTRIB_MSG 230
|
||||||
|
#define EDITOR_DIALOG_CONTRIB_TEXT 231
|
||||||
|
#define EDITOR_DIALOG_LINES_MSG 232
|
||||||
|
#define EDITOR_DIALOG_LINES_TEXT 233
|
||||||
|
#define EDITOR_DIALOG_STATE_MSG 234
|
||||||
|
#define EDITOR_DIALOG_STATE_TEXT 235
|
||||||
|
#define EDITOR_DIALOG_DEVELOPER 236
|
||||||
|
#define EDITOR_DIALOG_JOIN_MSG 237
|
||||||
|
#define EDITOR_DIALOG_JOIN_TEXT 238
|
||||||
|
|
||||||
// *************************** CparameterDlg ***************************
|
// *************************** CparameterDlg ***************************
|
||||||
|
|
||||||
class CparameterDlg : public wxDialogBox
|
class CparameterDlg : public wxDialog
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bool widgetPtrsSet;
|
bool widgetPtrsSet;
|
||||||
@@ -180,10 +228,10 @@ class CparameterDlg : public wxDialogBox
|
|||||||
Cparameters savedParamSettings;
|
Cparameters savedParamSettings;
|
||||||
|
|
||||||
// Pointers to all widgets on the dialog
|
// Pointers to all widgets on the dialog
|
||||||
wxMessage *pParamODBCSourceMsg;
|
wxStaticText *pParamODBCSourceMsg;
|
||||||
wxListBox *pParamODBCSourceList;
|
wxListBox *pParamODBCSourceList;
|
||||||
wxMessage *pParamUserNameMsg, *pParamPasswordMsg;
|
wxStaticText *pParamUserNameMsg, *pParamPasswordMsg;
|
||||||
wxText *pParamUserNameTxt, *pParamPasswordTxt;
|
wxTextCtrl *pParamUserNameTxt, *pParamPasswordTxt;
|
||||||
wxButton *pParamSaveBtn, *pParamCancelBtn;
|
wxButton *pParamSaveBtn, *pParamCancelBtn;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -199,6 +247,17 @@ class CparameterDlg : public wxDialogBox
|
|||||||
|
|
||||||
}; // CparameterDlg
|
}; // CparameterDlg
|
||||||
|
|
||||||
|
#define PARAMETER_DIALOG 400
|
||||||
|
|
||||||
|
// Parameter dialog control ids
|
||||||
|
#define PARAMETER_DIALOG_SOURCE_MSG 401
|
||||||
|
#define PARAMETER_DIALOG_SOURCE_LISTBOX 402
|
||||||
|
#define PARAMETER_DIALOG_NAME_MSG 403
|
||||||
|
#define PARAMETER_DIALOG_NAME_TEXT 404
|
||||||
|
#define PARAMETER_DIALOG_PASSWORD_MSG 405
|
||||||
|
#define PARAMETER_DIALOG_PASSWORD_TEXT 406
|
||||||
|
#define PARAMETER_DIALOG_SAVE 407
|
||||||
|
#define PARAMETER_DIALOG_CANCEL 408
|
||||||
|
|
||||||
// *************************** CqueryDlg ***************************
|
// *************************** CqueryDlg ***************************
|
||||||
|
|
||||||
@@ -230,7 +289,7 @@ char * const langQRY_LIKE = "% matches 0 or more of any char; _ matches
|
|||||||
char * const langQRY_BETWEEN = "column BETWEEN value AND value";
|
char * const langQRY_BETWEEN = "column BETWEEN value AND value";
|
||||||
|
|
||||||
|
|
||||||
class CqueryDlg : public wxDialogBox
|
class CqueryDlg : public wxDialog
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
CcolInf *colInf; // Column inf. returned by db->GetColumns()
|
CcolInf *colInf; // Column inf. returned by db->GetColumns()
|
||||||
@@ -243,20 +302,20 @@ class CqueryDlg : public wxDialogBox
|
|||||||
bool widgetPtrsSet;
|
bool widgetPtrsSet;
|
||||||
|
|
||||||
// Widget pointers
|
// Widget pointers
|
||||||
wxMessage *pQueryCol1Msg;
|
wxStaticText *pQueryCol1Msg;
|
||||||
wxChoice *pQueryCol1Choice;
|
wxChoice *pQueryCol1Choice;
|
||||||
wxMessage *pQueryNotMsg;
|
wxStaticText *pQueryNotMsg;
|
||||||
wxCheckBox *pQueryNotCheck;
|
wxCheckBox *pQueryNotCheck;
|
||||||
wxMessage *pQueryOperatorMsg;
|
wxStaticText *pQueryOperatorMsg;
|
||||||
wxChoice *pQueryOperatorChoice;
|
wxChoice *pQueryOperatorChoice;
|
||||||
wxMessage *pQueryCol2Msg;
|
wxStaticText *pQueryCol2Msg;
|
||||||
wxChoice *pQueryCol2Choice;
|
wxChoice *pQueryCol2Choice;
|
||||||
wxMessage *pQueryValue1Msg;
|
wxStaticText *pQueryValue1Msg;
|
||||||
wxText *pQueryValue1Txt;
|
wxTextCtrl *pQueryValue1Txt;
|
||||||
wxMessage *pQueryValue2Msg;
|
wxStaticText *pQueryValue2Msg;
|
||||||
wxText *pQueryValue2Txt;
|
wxTextCtrl *pQueryValue2Txt;
|
||||||
wxMessage *pQuerySqlWhereMsg;
|
wxStaticText *pQuerySqlWhereMsg;
|
||||||
wxMultiText *pQuerySqlWhereMtxt;
|
wxTextCtrl *pQuerySqlWhereMtxt;
|
||||||
wxButton *pQueryAddBtn;
|
wxButton *pQueryAddBtn;
|
||||||
wxButton *pQueryAndBtn;
|
wxButton *pQueryAndBtn;
|
||||||
wxButton *pQueryOrBtn;
|
wxButton *pQueryOrBtn;
|
||||||
@@ -266,10 +325,10 @@ class CqueryDlg : public wxDialogBox
|
|||||||
wxButton *pQueryClearBtn;
|
wxButton *pQueryClearBtn;
|
||||||
wxButton *pQueryCountBtn;
|
wxButton *pQueryCountBtn;
|
||||||
wxButton *pQueryHelpBtn;
|
wxButton *pQueryHelpBtn;
|
||||||
wxGroupBox *pQueryHintGrp;
|
wxStaticBox *pQueryHintGrp;
|
||||||
wxMessage *pQueryHintMsg;
|
wxStaticText *pQueryHintMsg;
|
||||||
|
|
||||||
wxText *pFocusTxt;
|
wxTextCtrl *pFocusTxt;
|
||||||
|
|
||||||
CqueryDlg(wxWindow *parent, wxDB *pDb, char *tblName[], char *pWhereArg);
|
CqueryDlg(wxWindow *parent, wxDB *pDb, char *tblName[], char *pWhereArg);
|
||||||
|
|
||||||
@@ -284,3 +343,32 @@ class CqueryDlg : public wxDialogBox
|
|||||||
bool ValidateWhereClause();
|
bool ValidateWhereClause();
|
||||||
|
|
||||||
}; // CqueryDlg
|
}; // CqueryDlg
|
||||||
|
|
||||||
|
#define QUERY_DIALOG 300
|
||||||
|
|
||||||
|
// Parameter dialog control ids
|
||||||
|
#define QUERY_DIALOG_COL_MSG 301
|
||||||
|
#define QUERY_DIALOG_COL_CHOICE 302
|
||||||
|
#define QUERY_DIALOG_NOT_MSG 303
|
||||||
|
#define QUERY_DIALOG_NOT_CHECKBOX 304
|
||||||
|
#define QUERY_DIALOG_OP_MSG 305
|
||||||
|
#define QUERY_DIALOG_OP_CHOICE 306
|
||||||
|
#define QUERY_DIALOG_COL2_MSG 307
|
||||||
|
#define QUERY_DIALOG_COL2_CHOICE 308
|
||||||
|
#define QUERY_DIALOG_WHERE_MSG 309
|
||||||
|
#define QUERY_DIALOG_WHERE_TEXT 310
|
||||||
|
#define QUERY_DIALOG_ADD 311
|
||||||
|
#define QUERY_DIALOG_AND 312
|
||||||
|
#define QUERY_DIALOG_OR 313
|
||||||
|
#define QUERY_DIALOG_LPAREN 314
|
||||||
|
#define QUERY_DIALOG_RPAREN 315
|
||||||
|
#define QUERY_DIALOG_DONE 316
|
||||||
|
#define QUERY_DIALOG_CLEAR 317
|
||||||
|
#define QUERY_DIALOG_COUNT 318
|
||||||
|
#define QUERY_DIALOG_VALUE1_MSG 319
|
||||||
|
#define QUERY_DIALOG_VALUE1_TEXT 320
|
||||||
|
#define QUERY_DIALOG_VALUE2_MSG 321
|
||||||
|
#define QUERY_DIALOG_VALUE2_TEXT 322
|
||||||
|
#define QUERY_DIALOG_HINT_GROUP 323
|
||||||
|
#define QUERY_DIALOG_HINT_MSG 324
|
||||||
|
|
||||||
|
@@ -103,7 +103,7 @@ Clookup2::Clookup2(char *tblName, char *colName1, char *colName2, wxDB *pDb)
|
|||||||
|
|
||||||
// This is a generic lookup constructor that will work with any table and any column
|
// This is a generic lookup constructor that will work with any table and any column
|
||||||
ClookUpDlg::ClookUpDlg(wxWindow *parent, char *windowTitle, char *tableName, char *colName,
|
ClookUpDlg::ClookUpDlg(wxWindow *parent, char *windowTitle, char *tableName, char *colName,
|
||||||
char *where, char *orderBy) : wxDialogBox (parent, "Select...", 1, -1, -1, 400, 290)
|
char *where, char *orderBy) : wxDialog (parent, LOOKUP_DIALOG, "Select...", wxPoint(-1, -1), wxSize(400, 290))
|
||||||
{
|
{
|
||||||
wxBeginBusyCursor();
|
wxBeginBusyCursor();
|
||||||
|
|
||||||
@@ -114,19 +114,9 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, char *windowTitle, char *tableName, cha
|
|||||||
noDisplayCols = 1;
|
noDisplayCols = 1;
|
||||||
col1Len = 0;
|
col1Len = 0;
|
||||||
|
|
||||||
// Build the dialog
|
pLookUpSelectList = new wxListBox(this, LOOKUP_DIALOG_SELECT, wxPoint(5, 15), wxSize(384, 195), 0, 0, wxLB_SINGLE|wxLB_ALWAYS_SB, wxDefaultValidator, "LookUpSelectList");
|
||||||
SetLabelPosition(wxVERTICAL);
|
pLookUpOkBtn = new wxButton(this, LOOKUP_DIALOG_OK, "&Ok", wxPoint(113, 222), wxSize(70, 35), 0, wxDefaultValidator, "LookUpOkBtn");
|
||||||
|
pLookUpCancelBtn = new wxButton(this, LOOKUP_DIALOG_CANCEL, "C&ancel", wxPoint(212, 222), wxSize(70, 35), 0, wxDefaultValidator, "LookUpCancelBtn");
|
||||||
wxFont *ButtonFont = new wxFont(12,wxSWISS,wxNORMAL,wxBOLD);
|
|
||||||
wxFont *TextFont = new wxFont(12,wxSWISS,wxNORMAL,wxNORMAL);
|
|
||||||
|
|
||||||
SetButtonFont(ButtonFont);
|
|
||||||
SetLabelFont(TextFont);
|
|
||||||
SetLabelPosition(wxVERTICAL);
|
|
||||||
|
|
||||||
pLookUpSelectList = new wxListBox(this, NULL, "", wxSINGLE|wxALWAYS_SB, 5, 15, 384, 195, 0, 0, 0, "LookUpSelectList");
|
|
||||||
pLookUpOkBtn = new wxButton(this, NULL, "&Ok", 113, 222, 70, 35, 0, "LookUpOkBtn");
|
|
||||||
pLookUpCancelBtn = new wxButton(this, NULL, "C&ancel", 212, 222, 70, 35, 0, "LookUpCancelBtn");
|
|
||||||
|
|
||||||
widgetPtrsSet = TRUE;
|
widgetPtrsSet = TRUE;
|
||||||
|
|
||||||
@@ -141,8 +131,8 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, char *windowTitle, char *tableName, cha
|
|||||||
if (!lookup->Open())
|
if (!lookup->Open())
|
||||||
{
|
{
|
||||||
wxString tStr;
|
wxString tStr;
|
||||||
tStr.sprintf("Unable to open the table '%s'.",tableName);
|
tStr.Printf("Unable to open the table '%s'.",tableName);
|
||||||
wxMessageBox(tStr.GetData(),"ODBC Error...");
|
wxMessageBox(tStr,"ODBC Error...");
|
||||||
Close();
|
Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -176,7 +166,7 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, char *windowTitle, char *tableName, cha
|
|||||||
SetTitle(windowTitle);
|
SetTitle(windowTitle);
|
||||||
Centre(wxBOTH);
|
Centre(wxBOTH);
|
||||||
wxEndBusyCursor();
|
wxEndBusyCursor();
|
||||||
Show(TRUE);
|
ShowModal();
|
||||||
|
|
||||||
} // Generic lookup constructor
|
} // Generic lookup constructor
|
||||||
|
|
||||||
@@ -207,7 +197,7 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, char *windowTitle, char *tableName, cha
|
|||||||
//
|
//
|
||||||
ClookUpDlg::ClookUpDlg(wxWindow *parent, char *windowTitle, char *tableName,
|
ClookUpDlg::ClookUpDlg(wxWindow *parent, char *windowTitle, char *tableName,
|
||||||
char *dispCol1, char *dispCol2, char *where, char *orderBy, bool distinctValues,
|
char *dispCol1, char *dispCol2, char *where, char *orderBy, bool distinctValues,
|
||||||
char *selectStmt, int maxLenCol1, wxDB *pDb, bool allowOk) : wxDialogBox (parent, "Select...", 1, -1, -1, 400, 290)
|
char *selectStmt, int maxLenCol1, wxDB *pDb, bool allowOk) : wxDialog (parent, LOOKUP_DIALOG, "Select...", wxPoint(-1, -1), wxSize(400, 290))
|
||||||
{
|
{
|
||||||
wxBeginBusyCursor();
|
wxBeginBusyCursor();
|
||||||
|
|
||||||
@@ -219,24 +209,16 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, char *windowTitle, char *tableName,
|
|||||||
noDisplayCols = (strlen(dispCol2) ? 2 : 1);
|
noDisplayCols = (strlen(dispCol2) ? 2 : 1);
|
||||||
col1Len = 0;
|
col1Len = 0;
|
||||||
|
|
||||||
// Build the dialog
|
wxFont fixedFont(12,wxMODERN,wxNORMAL,wxNORMAL);
|
||||||
SetLabelPosition(wxVERTICAL);
|
|
||||||
|
|
||||||
wxFont *ButtonFont = new wxFont(12,wxSWISS,wxNORMAL,wxBOLD);
|
|
||||||
wxFont *TextFont = new wxFont(12,wxSWISS,wxNORMAL,wxNORMAL);
|
|
||||||
wxFont *FixedFont = new wxFont(12,wxMODERN,wxNORMAL,wxNORMAL);
|
|
||||||
|
|
||||||
SetButtonFont(ButtonFont);
|
|
||||||
SetLabelFont(TextFont);
|
|
||||||
SetLabelPosition(wxVERTICAL);
|
|
||||||
|
|
||||||
// this is done with fixed font so that the second column (if any) will be left
|
// this is done with fixed font so that the second column (if any) will be left
|
||||||
// justified in the second column
|
// justified in the second column
|
||||||
SetButtonFont(FixedFont);
|
pLookUpSelectList = new wxListBox(this, LOOKUP_DIALOG_SELECT, wxPoint(5, 15), wxSize(384, 195), 0, 0, wxLB_SINGLE|wxLB_ALWAYS_SB, wxDefaultValidator, "LookUpSelectList");
|
||||||
pLookUpSelectList = new wxListBox(this, NULL, "", wxSINGLE|wxALWAYS_SB, 5, 15, 384, 195, 0, 0, 0, "LookUpSelectList");
|
|
||||||
SetButtonFont(ButtonFont);
|
pLookUpSelectList->SetFont(fixedFont);
|
||||||
pLookUpOkBtn = new wxButton(this, NULL, "&Ok", 113, 222, 70, 35, 0, "LookUpOkBtn");
|
|
||||||
pLookUpCancelBtn = new wxButton(this, NULL, "C&ancel", 212, 222, 70, 35, 0, "LookUpCancelBtn");
|
pLookUpOkBtn = new wxButton(this, LOOKUP_DIALOG_OK, "&Ok", wxPoint(113, 222), wxSize(70, 35), 0, wxDefaultValidator, "LookUpOkBtn");
|
||||||
|
pLookUpCancelBtn = new wxButton(this, LOOKUP_DIALOG_CANCEL, "C&ancel", wxPoint(212, 222), wxSize(70, 35), 0, wxDefaultValidator, "LookUpCancelBtn");
|
||||||
|
|
||||||
widgetPtrsSet = TRUE;
|
widgetPtrsSet = TRUE;
|
||||||
|
|
||||||
@@ -251,8 +233,8 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, char *windowTitle, char *tableName,
|
|||||||
if (!lookup2->Open())
|
if (!lookup2->Open())
|
||||||
{
|
{
|
||||||
wxString tStr;
|
wxString tStr;
|
||||||
tStr.sprintf("Unable to open the table '%s'.",tableName);
|
tStr.Printf("Unable to open the table '%s'.",tableName);
|
||||||
wxMessageBox(tStr.GetData(),"ODBC Error...");
|
wxMessageBox(tStr,"ODBC Error...");
|
||||||
Close();
|
Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -276,7 +258,7 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, char *windowTitle, char *tableName,
|
|||||||
q += " WHERE ";
|
q += " WHERE ";
|
||||||
q += where;
|
q += where;
|
||||||
}
|
}
|
||||||
if (!lookup2->QueryBySqlStmt(q.GetData()))
|
if (!lookup2->QueryBySqlStmt((char*) (const char*) q))
|
||||||
{
|
{
|
||||||
wxMessageBox("ODBC error during QueryBySqlStmt()","ODBC Error...");
|
wxMessageBox("ODBC error during QueryBySqlStmt()","ODBC Error...");
|
||||||
Close();
|
Close();
|
||||||
@@ -321,7 +303,7 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, char *windowTitle, char *tableName,
|
|||||||
s.Append(' ', (maxColLen + LISTDB_NO_SPACES_BETWEEN_COLS - strlen(lookup2->lookupCol1)));
|
s.Append(' ', (maxColLen + LISTDB_NO_SPACES_BETWEEN_COLS - strlen(lookup2->lookupCol1)));
|
||||||
s.Append(lookup2->lookupCol2);
|
s.Append(lookup2->lookupCol2);
|
||||||
}
|
}
|
||||||
pLookUpSelectList->Append(s.GetData());
|
pLookUpSelectList->Append(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Highlight the first list item
|
// Highlight the first list item
|
||||||
@@ -342,7 +324,7 @@ ClookUpDlg::ClookUpDlg(wxWindow *parent, char *windowTitle, char *tableName,
|
|||||||
SetTitle(windowTitle);
|
SetTitle(windowTitle);
|
||||||
Centre(wxBOTH);
|
Centre(wxBOTH);
|
||||||
wxEndBusyCursor();
|
wxEndBusyCursor();
|
||||||
Show(TRUE);
|
ShowModal();
|
||||||
|
|
||||||
} // Generic lookup constructor 2
|
} // Generic lookup constructor 2
|
||||||
|
|
||||||
@@ -382,12 +364,12 @@ void ClookUpDlg::OnCommand(wxWindow& win, wxCommandEvent& event)
|
|||||||
// Column 1
|
// Column 1
|
||||||
s = s.SubString(0, col1Len-1);
|
s = s.SubString(0, col1Len-1);
|
||||||
s = s.Strip();
|
s = s.Strip();
|
||||||
strcpy(ListDB_Selection, s.GetData());
|
strcpy(ListDB_Selection, s);
|
||||||
// Column 2
|
// Column 2
|
||||||
s = pLookUpSelectList->GetStringSelection();
|
s = pLookUpSelectList->GetStringSelection();
|
||||||
s = s.From(col1Len + LISTDB_NO_SPACES_BETWEEN_COLS);
|
s = s.Mid(col1Len + LISTDB_NO_SPACES_BETWEEN_COLS);
|
||||||
s = s.Strip();
|
s = s.Strip();
|
||||||
strcpy(ListDB_Selection2, s.GetData());
|
strcpy(ListDB_Selection2, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -9,7 +9,9 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
#pragma interface "listdb.h"
|
#pragma interface "listdb.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
/*
|
/*
|
||||||
@@ -54,7 +56,7 @@ class Clookup2 : public wxTable
|
|||||||
|
|
||||||
}; // Clookup2
|
}; // Clookup2
|
||||||
|
|
||||||
class ClookUpDlg : public wxDialogBox
|
class ClookUpDlg : public wxDialog
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bool widgetPtrsSet;
|
bool widgetPtrsSet;
|
||||||
@@ -120,6 +122,12 @@ class ClookUpDlg : public wxDialogBox
|
|||||||
void OnActivate(bool) {}; // necessary for hot keys
|
void OnActivate(bool) {}; // necessary for hot keys
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define LOOKUP_DIALOG 500
|
||||||
|
|
||||||
|
#define LOOKUP_DIALOG_SELECT 501
|
||||||
|
#define LOOKUP_DIALOG_OK 502
|
||||||
|
#define LOOKUP_DIALOG_CANCEL 503
|
||||||
|
|
||||||
#endif // LISTDB_DOT_H
|
#endif // LISTDB_DOT_H
|
||||||
|
|
||||||
// ************************************ listdb.h *********************************
|
// ************************************ listdb.h *********************************
|
||||||
|
@@ -1,53 +1,31 @@
|
|||||||
#
|
#
|
||||||
# File: makefile.nt
|
# File: makefile.nt
|
||||||
# Author: George Tasker
|
# Author: Julian Smart
|
||||||
# Created: 1998
|
# Created: 1993
|
||||||
# Updated:
|
# Updated:
|
||||||
|
# Copyright: (c) 1993, AIAI, University of Edinburgh
|
||||||
#
|
#
|
||||||
# "%W% %G%"
|
# "%W% %G%"
|
||||||
#
|
#
|
||||||
# Makefile : Builds database example (MS VC++).
|
# Makefile : Builds db example (MS VC++).
|
||||||
|
# Use FINAL=1 argument to nmake to build final version with no debugging
|
||||||
!if "$(FINAL)" == ""
|
# info
|
||||||
FINAL=0
|
|
||||||
!endif
|
|
||||||
|
|
||||||
|
|
||||||
!if "$(MSVCDIR)" == ""
|
|
||||||
MSVCDIR=c:\devstudio\vc
|
|
||||||
!endif
|
|
||||||
|
|
||||||
# Set WXDIR for your system
|
# Set WXDIR for your system
|
||||||
WXDIR = $(WXWIN)
|
WXDIR = $(WXWIN)
|
||||||
THISDIR = $(WXDIR)\samples\database
|
|
||||||
WXODBCDIR = $(WXDIR)\utils\wxodbc
|
|
||||||
|
|
||||||
!if "$(MSVCDIR)" == ""
|
WXUSINGDLL=0
|
||||||
DBLIBS=$(MSDEVDIR)\lib\odbc32.lib
|
|
||||||
!else
|
|
||||||
DBLIBS=$(MSVCDIR)\lib\odbc32.lib
|
|
||||||
!endif
|
|
||||||
|
|
||||||
EXTRAINC = -I$(WXODBCDIR)\src
|
|
||||||
EXTRALIBS = $(DBLIBS) $(WXODBCDIR)\lib\wxodbc.lib
|
|
||||||
|
|
||||||
!include $(WXDIR)\src\ntwxwin.mak
|
!include $(WXDIR)\src\ntwxwin.mak
|
||||||
|
|
||||||
PROGRAM=database
|
THISDIR = $(WXDIR)\samples\db
|
||||||
|
PROGRAM=dbtest
|
||||||
|
|
||||||
OBJECTS = $(PROGRAM).$(OBJSUFF) listdb.$(OBJSUFF)
|
OBJECTS = $(PROGRAM).obj listdb.obj
|
||||||
|
|
||||||
all: wxodbc $(PROGRAM).exe
|
|
||||||
|
|
||||||
$(PROGRAM): $(PROGRAM).exe
|
$(PROGRAM): $(PROGRAM).exe
|
||||||
|
|
||||||
gt:
|
all: wx $(PROGRAM).exe
|
||||||
cd $(CPPFLAGS)
|
|
||||||
|
|
||||||
wxodbc:
|
|
||||||
cd $(WXODBCDIR)\src
|
|
||||||
nmake -f makefile.nt FINAL=$(FINAL)
|
|
||||||
cd $(THISDIR)
|
|
||||||
|
|
||||||
wx:
|
wx:
|
||||||
cd $(WXDIR)\src\msw
|
cd $(WXDIR)\src\msw
|
||||||
@@ -58,12 +36,8 @@ wxclean:
|
|||||||
cd $(WXDIR)\src\msw
|
cd $(WXDIR)\src\msw
|
||||||
nmake -f makefile.nt clean
|
nmake -f makefile.nt clean
|
||||||
cd $(THISDIR)
|
cd $(THISDIR)
|
||||||
cd $(WXODBCDIR)\src
|
|
||||||
nmake -f makefile.nt clean
|
|
||||||
cd $(THISDIR)
|
|
||||||
|
|
||||||
|
$(PROGRAM).exe: $(DUMMYOBJ) $(WXLIB) $(OBJECTS) $(PROGRAM).res
|
||||||
$(PROGRAM).exe: $(DUMMYOBJ) $(OBJECTS) $(PROGRAM).res
|
|
||||||
$(link) @<<
|
$(link) @<<
|
||||||
-out:$(PROGRAM).exe
|
-out:$(PROGRAM).exe
|
||||||
$(LINKFLAGS)
|
$(LINKFLAGS)
|
||||||
@@ -72,19 +46,17 @@ $(LIBS)
|
|||||||
<<
|
<<
|
||||||
|
|
||||||
|
|
||||||
listdb.$(OBJSUFF): $(*B).$(SRCSUFF) $(*B).h
|
$(PROGRAM).obj: $(PROGRAM).$(SRCSUFF) $(DUMMYOBJ)
|
||||||
$(cc) @<<
|
$(cc) @<<
|
||||||
$(CPPFLAGS) /c /Fo$(*B).$(OBJSUFF) /Tp $(*B).$(SRCSUFF)
|
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||||
<<
|
<<
|
||||||
|
|
||||||
|
listdb.obj: listdb.cpp $(DUMMYOBJ)
|
||||||
$(PROGRAM).$(OBJSUFF): $(PROGRAM).$(SRCSUFF) $(PROGRAM).h listdb.h
|
$(cc) @<<
|
||||||
$(cc) @<<
|
$(CPPFLAGS) /c /Tp $*.$(SRCSUFF)
|
||||||
$(CPPFLAGS) /c /Fo$(*B).$(OBJSUFF) /Tp $(*B).$(SRCSUFF)
|
|
||||||
<<
|
<<
|
||||||
|
|
||||||
|
$(PROGRAM).res : $(PROGRAM).rc $(WXDIR)\include\wx\msw\wx.rc
|
||||||
$(PROGRAM).res: $(PROGRAM).rc $(WXDIR)\include\wx\msw\wx.rc
|
|
||||||
$(rc) -r /i$(WXDIR)\include -fo$@ $(PROGRAM).rc
|
$(rc) -r /i$(WXDIR)\include -fo$@ $(PROGRAM).rc
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,71 +1,17 @@
|
|||||||
#
|
#
|
||||||
# File: makefile.unx
|
# File: makefile.unx
|
||||||
# Author: Terry Tompkins
|
# Author: Julian Smart
|
||||||
# Created: 1998
|
# Created: 1998
|
||||||
# Updated:
|
# Updated:
|
||||||
# Copyright: (c) 1998, Remstar International
|
# Copyright: (c) 1998 Julian Smart
|
||||||
#
|
#
|
||||||
# Makefile for wxDB (UNIX).
|
# "%W% %G%"
|
||||||
|
#
|
||||||
|
# Makefile for dbtest example (UNIX).
|
||||||
|
|
||||||
OBJDIR=database
|
PROGRAM=dbtest
|
||||||
OBJSUFF=.o
|
|
||||||
SRCSUFF=.cpp
|
|
||||||
WXDIR = $(WXWIN)
|
|
||||||
|
|
||||||
# All common UNIX compiler flags and options are now in
|
OBJECTS=$(PROGRAM).o listdb.o
|
||||||
# this central makefile.
|
|
||||||
include $(WXDIR)/src/make.env
|
|
||||||
|
|
||||||
PROGRAM=database
|
include ../../src/makeprog.env
|
||||||
|
|
||||||
OBJECTS = $(OBJDIR)/$(PROGRAM).$(OBJSUFF) $(OBJDIR)/table.$(OBJSUFF) $(OBJDIR)/db.$(OBJSUFF) $(OBJDIR)/listdb.$(OBJSUFF)
|
|
||||||
|
|
||||||
.SUFFIXES:
|
|
||||||
|
|
||||||
all: $(OBJDIR) $(PROGRAM)$(GUISUFFIX)
|
|
||||||
|
|
||||||
wx:
|
|
||||||
|
|
||||||
|
|
||||||
motif:
|
|
||||||
$(MAKE) -f makefile.unx GUISUFFIX=_motif GUI=-Dwx_motif GUISUFFIX=_motif OPT='$(OPT)' LDLIBS='$(MOTIFLDLIBS)' WXLIB=$(WXDIR)/lib/libwx_motif.a OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)' XVIEW_LINK=
|
|
||||||
|
|
||||||
xview:
|
|
||||||
cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx xview
|
|
||||||
$(MAKE) -f makefile.unx GUI=-Dwx_xview GUISUFFIX=_ol CC=$(CC) OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)'
|
|
||||||
|
|
||||||
hp:
|
|
||||||
cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx hp
|
|
||||||
$(MAKE) -f makefile.unx GUI=-Dwx_motif GUISUFFIX=_hp CC=CC DEBUG='$(DEBUG)' WARN='-w' \
|
|
||||||
XINCLUDE='$(HPXINCLUDE)' XLIB='$(HPXLIB)' XVIEW_LINK='' LDLIBS='$(HPLDLIBS)'
|
|
||||||
|
|
||||||
$(OBJDIR):
|
|
||||||
mkdir $(OBJDIR)
|
|
||||||
|
|
||||||
$(PROGRAM)$(GUISUFFIX): $(DUMMYOBJ) $(DBLIBS) $(OBJECTS) $(WXLIB)
|
|
||||||
$(CC) $(LDFLAGS) -o $(PROGRAM)$(GUISUFFIX) $(OBJECTS) $(XVIEW_LINK) $(LDLIBS)
|
|
||||||
|
|
||||||
$(OBJDIR)/$(PROGRAM).$(OBJSUFF): $(PROGRAM).$(SRCSUFF)
|
|
||||||
$(CC) -c $(CPPFLAGS) -o $@ $(PROGRAM).$(SRCSUFF)
|
|
||||||
|
|
||||||
$(OBJDIR)/table.$(OBJSUFF): table.$(SRCSUFF)
|
|
||||||
$(CC) -c $(CPPFLAGS) -o $@ table.$(SRCSUFF)
|
|
||||||
|
|
||||||
$(OBJDIR)/db.$(OBJSUFF): db.$(SRCSUFF)
|
|
||||||
$(CC) -c $(CPPFLAGS) -o $@ db.$(SRCSUFF)
|
|
||||||
|
|
||||||
$(OBJDIR)/listdb.$(OBJSUFF): listdb.$(SRCSUFF)
|
|
||||||
$(CC) -c $(CPPFLAGS) -o $@ listdb.$(SRCSUFF)
|
|
||||||
|
|
||||||
clean_motif:
|
|
||||||
$(MAKE) -f makefile.unx GUISUFFIX=_motif cleanany
|
|
||||||
|
|
||||||
clean_ol:
|
|
||||||
$(MAKE) -f makefile.unx GUISUFFIX=_ol cleanany
|
|
||||||
|
|
||||||
clean_hp:
|
|
||||||
$(MAKE) -f makefile.unx GUISUFFIX=_hp cleanany
|
|
||||||
|
|
||||||
cleanany:
|
|
||||||
rm -f $(OBJECTS) $(PROGRAM)$(GUISUFFIX) core
|
|
||||||
|
|
||||||
|
@@ -5,6 +5,8 @@
|
|||||||
// source such as opening and closing the data source.
|
// source such as opening and closing the data source.
|
||||||
// Author: Doug Card
|
// Author: Doug Card
|
||||||
// Modified by:
|
// Modified by:
|
||||||
|
// Mods: Dec, 1998: Added support for SQL statement logging and database
|
||||||
|
// cataloging
|
||||||
// Created: 9.96
|
// Created: 9.96
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) 1996 Remstar International, Inc.
|
// Copyright: (c) 1996 Remstar International, Inc.
|
||||||
@@ -20,17 +22,17 @@
|
|||||||
// the wxWindows GUI development toolkit.
|
// the wxWindows GUI development toolkit.
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*
|
|
||||||
// SYNOPSIS START
|
|
||||||
// SYNOPSIS STOP
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "db.h"
|
#pragma implementation "db.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#ifdef _CONSOLE
|
// SYNOPSIS START
|
||||||
|
// SYNOPSIS STOP
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
#ifdef DBDEBUG_CONSOLE
|
||||||
#include <iostream.h>
|
#include <iostream.h>
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
@@ -47,11 +49,10 @@
|
|||||||
|
|
||||||
#if wxUSE_ODBC
|
#if wxUSE_ODBC
|
||||||
|
|
||||||
#include <wx/db.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include "wx/db.h"
|
||||||
|
|
||||||
DbList *PtrBegDbList = 0;
|
DbList *PtrBegDbList = 0;
|
||||||
|
|
||||||
@@ -59,6 +60,9 @@ DbList *PtrBegDbList = 0;
|
|||||||
wxDB::wxDB(HENV &aHenv)
|
wxDB::wxDB(HENV &aHenv)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
fpSqlLog = 0; // Sql Log file pointer
|
||||||
|
sqlLogState = sqlLogOFF; // By default, logging is turned off
|
||||||
|
|
||||||
strcpy(sqlState,"");
|
strcpy(sqlState,"");
|
||||||
strcpy(errorMsg,"");
|
strcpy(errorMsg,"");
|
||||||
@@ -112,7 +116,7 @@ wxDB::wxDB(HENV &aHenv)
|
|||||||
/********** wxDB::Open() **********/
|
/********** wxDB::Open() **********/
|
||||||
bool wxDB::Open(char *Dsn, char *Uid, char *AuthStr)
|
bool wxDB::Open(char *Dsn, char *Uid, char *AuthStr)
|
||||||
{
|
{
|
||||||
assert(Dsn);
|
assert(Dsn && strlen(Dsn));
|
||||||
dsn = Dsn;
|
dsn = Dsn;
|
||||||
uid = Uid;
|
uid = Uid;
|
||||||
authStr = AuthStr;
|
authStr = AuthStr;
|
||||||
@@ -125,7 +129,7 @@ bool wxDB::Open(char *Dsn, char *Uid, char *AuthStr)
|
|||||||
// specified before the connection is made.
|
// specified before the connection is made.
|
||||||
retcode = SQLSetConnectOption(hdbc, SQL_ODBC_CURSORS, SQL_CUR_USE_IF_NEEDED);
|
retcode = SQLSetConnectOption(hdbc, SQL_ODBC_CURSORS, SQL_CUR_USE_IF_NEEDED);
|
||||||
|
|
||||||
#ifdef _CONSOLE
|
#ifdef DBDEBUG_CONSOLE
|
||||||
if (retcode == SQL_SUCCESS)
|
if (retcode == SQL_SUCCESS)
|
||||||
cout << "SQLSetConnectOption(CURSOR_LIB) successful" << endl;
|
cout << "SQLSetConnectOption(CURSOR_LIB) successful" << endl;
|
||||||
else
|
else
|
||||||
@@ -240,7 +244,7 @@ bool wxDB::Open(char *Dsn, char *Uid, char *AuthStr)
|
|||||||
else
|
else
|
||||||
typeInfDate.FsqlType = SQL_TIMESTAMP;
|
typeInfDate.FsqlType = SQL_TIMESTAMP;
|
||||||
|
|
||||||
#ifdef _CONSOLE
|
#ifdef DBDEBUG_CONSOLE
|
||||||
cout << "VARCHAR DATA TYPE: " << typeInfVarchar.TypeName << endl;
|
cout << "VARCHAR DATA TYPE: " << typeInfVarchar.TypeName << endl;
|
||||||
cout << "INTEGER DATA TYPE: " << typeInfInteger.TypeName << endl;
|
cout << "INTEGER DATA TYPE: " << typeInfInteger.TypeName << endl;
|
||||||
cout << "FLOAT DATA TYPE: " << typeInfFloat.TypeName << endl;
|
cout << "FLOAT DATA TYPE: " << typeInfFloat.TypeName << endl;
|
||||||
@@ -262,7 +266,7 @@ bool wxDB::setConnectionOptions(void)
|
|||||||
SQLSetConnectOption(hdbc, SQL_OPT_TRACE, SQL_OPT_TRACE_OFF);
|
SQLSetConnectOption(hdbc, SQL_OPT_TRACE, SQL_OPT_TRACE_OFF);
|
||||||
|
|
||||||
// Display the connection options to verify them
|
// Display the connection options to verify them
|
||||||
#ifdef _CONSOLE
|
#ifdef DBDEBUG_CONSOLE
|
||||||
long l;
|
long l;
|
||||||
cout << ">>>>> CONNECTION OPTIONS <<<<<<" << endl;
|
cout << ">>>>> CONNECTION OPTIONS <<<<<<" << endl;
|
||||||
|
|
||||||
@@ -394,7 +398,7 @@ bool wxDB::getDbInfo(void)
|
|||||||
if (SQLGetInfo(hdbc, SQL_LOGIN_TIMEOUT, &dbInf.loginTimeout, sizeof(dbInf.loginTimeout), &cb) != SQL_SUCCESS)
|
if (SQLGetInfo(hdbc, SQL_LOGIN_TIMEOUT, &dbInf.loginTimeout, sizeof(dbInf.loginTimeout), &cb) != SQL_SUCCESS)
|
||||||
return(DispAllErrors(henv, hdbc));
|
return(DispAllErrors(henv, hdbc));
|
||||||
|
|
||||||
#ifdef _CONSOLE
|
#ifdef DBDEBUG_CONSOLE
|
||||||
cout << ">>>>> DATA SOURCE INFORMATION <<<<<" << endl;
|
cout << ">>>>> DATA SOURCE INFORMATION <<<<<" << endl;
|
||||||
cout << "SERVER Name: " << dbInf.serverName << endl;
|
cout << "SERVER Name: " << dbInf.serverName << endl;
|
||||||
cout << "DBMS Name: " << dbInf.dbmsName << "; DBMS Version: " << dbInf.dbmsVer << endl;
|
cout << "DBMS Name: " << dbInf.dbmsName << "; DBMS Version: " << dbInf.dbmsVer << endl;
|
||||||
@@ -612,7 +616,7 @@ bool wxDB::getDataTypeInfo(SWORD fSqlType, SqlTypeInfo &structSQLTypeInfo)
|
|||||||
// Fetch the record
|
// Fetch the record
|
||||||
if ((retcode = SQLFetch(hstmt)) != SQL_SUCCESS)
|
if ((retcode = SQLFetch(hstmt)) != SQL_SUCCESS)
|
||||||
{
|
{
|
||||||
#ifdef _CONSOLE
|
#ifdef DBDEBUG_CONSOLE
|
||||||
if (retcode == SQL_NO_DATA_FOUND)
|
if (retcode == SQL_NO_DATA_FOUND)
|
||||||
cout << "SQL_NO_DATA_FOUND fetching inf. about data type." << endl;
|
cout << "SQL_NO_DATA_FOUND fetching inf. about data type." << endl;
|
||||||
#endif
|
#endif
|
||||||
@@ -647,6 +651,13 @@ bool wxDB::getDataTypeInfo(SWORD fSqlType, SqlTypeInfo &structSQLTypeInfo)
|
|||||||
/********** wxDB::Close() **********/
|
/********** wxDB::Close() **********/
|
||||||
void wxDB::Close(void)
|
void wxDB::Close(void)
|
||||||
{
|
{
|
||||||
|
// Close the Sql Log file
|
||||||
|
if (fpSqlLog)
|
||||||
|
{
|
||||||
|
fclose(fpSqlLog);
|
||||||
|
fpSqlLog = 0; //glt
|
||||||
|
}
|
||||||
|
|
||||||
// Free statement handle
|
// Free statement handle
|
||||||
if (dbIsOpen)
|
if (dbIsOpen)
|
||||||
{
|
{
|
||||||
@@ -699,7 +710,7 @@ bool wxDB::DispAllErrors(HENV aHenv, HDBC aHdbc, HSTMT aHstmt)
|
|||||||
logError(odbcErrMsg, sqlState);
|
logError(odbcErrMsg, sqlState);
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
#ifdef _CONSOLE
|
#ifdef DBDEBUG_CONSOLE
|
||||||
// When run in console mode, use standard out to display errors.
|
// When run in console mode, use standard out to display errors.
|
||||||
cout << odbcErrMsg << endl;
|
cout << odbcErrMsg << endl;
|
||||||
cout << "Press any key to continue..." << endl;
|
cout << "Press any key to continue..." << endl;
|
||||||
@@ -733,7 +744,7 @@ void wxDB::DispNextError(void)
|
|||||||
if (silent)
|
if (silent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef _CONSOLE
|
#ifdef DBDEBUG_CONSOLE
|
||||||
// When run in console mode, use standard out to display errors.
|
// When run in console mode, use standard out to display errors.
|
||||||
cout << odbcErrMsg << endl;
|
cout << odbcErrMsg << endl;
|
||||||
cout << "Press any key to continue..." << endl;
|
cout << "Press any key to continue..." << endl;
|
||||||
@@ -994,10 +1005,12 @@ bool wxDB::Grant(int privileges, char *tableName, char *userList)
|
|||||||
strcat(sqlStmt, " TO ");
|
strcat(sqlStmt, " TO ");
|
||||||
strcat(sqlStmt, userList);
|
strcat(sqlStmt, userList);
|
||||||
|
|
||||||
#ifdef _CONSOLE
|
#ifdef DBDEBUG_CONSOLE
|
||||||
cout << endl << sqlStmt << endl;
|
cout << endl << sqlStmt << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
WriteSqlLog(sqlStmt);
|
||||||
|
|
||||||
return(ExecSql(sqlStmt));
|
return(ExecSql(sqlStmt));
|
||||||
|
|
||||||
} // wxDB::Grant()
|
} // wxDB::Grant()
|
||||||
@@ -1025,7 +1038,9 @@ bool wxDB::CreateView(char *viewName, char *colList, char *pSqlStmt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _CONSOLE
|
WriteSqlLog(sqlStmt);
|
||||||
|
|
||||||
|
#ifdef DBDEBUG_CONSOLE
|
||||||
cout << endl << sqlStmt << endl;
|
cout << endl << sqlStmt << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1043,7 +1058,9 @@ bool wxDB::CreateView(char *viewName, char *colList, char *pSqlStmt)
|
|||||||
strcat(sqlStmt, " AS ");
|
strcat(sqlStmt, " AS ");
|
||||||
strcat(sqlStmt, pSqlStmt);
|
strcat(sqlStmt, pSqlStmt);
|
||||||
|
|
||||||
#ifdef _CONSOLE
|
WriteSqlLog(sqlStmt);
|
||||||
|
|
||||||
|
#ifdef DBDEBUG_CONSOLE
|
||||||
cout << sqlStmt << endl;
|
cout << sqlStmt << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1161,6 +1178,101 @@ CcolInf *wxDB::GetColumns(char *tableName[])
|
|||||||
} // wxDB::GetColumns()
|
} // wxDB::GetColumns()
|
||||||
|
|
||||||
|
|
||||||
|
/********** wxDB::Catalog() **********/
|
||||||
|
bool wxDB::Catalog(char *userID, char *fileName)
|
||||||
|
{
|
||||||
|
assert(userID && strlen(userID));
|
||||||
|
assert(fileName && strlen(fileName));
|
||||||
|
|
||||||
|
RETCODE retcode;
|
||||||
|
SDWORD cb;
|
||||||
|
char tblName[DB_MAX_TABLE_NAME_LEN+1];
|
||||||
|
char tblNameSave[DB_MAX_TABLE_NAME_LEN+1];
|
||||||
|
char colName[DB_MAX_COLUMN_NAME_LEN+1];
|
||||||
|
SWORD sqlDataType;
|
||||||
|
char typeName[16];
|
||||||
|
SWORD precision, length;
|
||||||
|
|
||||||
|
FILE *fp = fopen(fileName,"wt");
|
||||||
|
if (fp == NULL)
|
||||||
|
return(FALSE);
|
||||||
|
|
||||||
|
SQLFreeStmt(hstmt, SQL_CLOSE);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
char userIdUC[81];
|
||||||
|
for (char *p = userID; *p; p++)
|
||||||
|
userIdUC[i++] = toupper(*p);
|
||||||
|
userIdUC[i] = 0;
|
||||||
|
|
||||||
|
retcode = SQLColumns(hstmt,
|
||||||
|
NULL, 0, // All qualifiers
|
||||||
|
(UCHAR *) userIdUC, SQL_NTS, // User specified
|
||||||
|
NULL, 0, // All tables
|
||||||
|
NULL, 0); // All columns
|
||||||
|
if (retcode != SQL_SUCCESS)
|
||||||
|
{
|
||||||
|
DispAllErrors(henv, hdbc, hstmt);
|
||||||
|
fclose(fp);
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
SQLBindCol(hstmt, 3, SQL_C_CHAR, tblName, DB_MAX_TABLE_NAME_LEN+1, &cb);
|
||||||
|
SQLBindCol(hstmt, 4, SQL_C_CHAR, colName, DB_MAX_COLUMN_NAME_LEN+1, &cb);
|
||||||
|
SQLBindCol(hstmt, 5, SQL_C_SSHORT, &sqlDataType, 0, &cb);
|
||||||
|
SQLBindCol(hstmt, 6, SQL_C_CHAR, typeName, 16, &cb);
|
||||||
|
SQLBindCol(hstmt, 7, SQL_C_SSHORT, &precision, 0, &cb);
|
||||||
|
SQLBindCol(hstmt, 8, SQL_C_SSHORT, &length, 0, &cb);
|
||||||
|
|
||||||
|
char outStr[256];
|
||||||
|
strcpy(tblNameSave,"");
|
||||||
|
int cnt = 0;
|
||||||
|
|
||||||
|
while ((retcode = SQLFetch(hstmt)) == SQL_SUCCESS)
|
||||||
|
{
|
||||||
|
if (strcmp(tblName,tblNameSave))
|
||||||
|
{
|
||||||
|
if (cnt)
|
||||||
|
fputs("\n", fp);
|
||||||
|
fputs("================================ ", fp);
|
||||||
|
fputs("================================ ", fp);
|
||||||
|
fputs("===================== ", fp);
|
||||||
|
fputs("========= ", fp);
|
||||||
|
fputs("=========\n", fp);
|
||||||
|
sprintf(outStr, "%-32s %-32s %-21s %9s %9s\n",
|
||||||
|
"TABLE NAME", "COLUMN NAME", "DATA TYPE", "PRECISION", "LENGTH");
|
||||||
|
fputs(outStr, fp);
|
||||||
|
fputs("================================ ", fp);
|
||||||
|
fputs("================================ ", fp);
|
||||||
|
fputs("===================== ", fp);
|
||||||
|
fputs("========= ", fp);
|
||||||
|
fputs("=========\n", fp);
|
||||||
|
strcpy(tblNameSave,tblName);
|
||||||
|
}
|
||||||
|
sprintf(outStr, "%-32s %-32s (%04d)%-15s %9d %9d\n",
|
||||||
|
tblName, colName, sqlDataType, typeName, precision, length);
|
||||||
|
if (fputs(outStr, fp) == EOF)
|
||||||
|
{
|
||||||
|
fclose(fp);
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
cnt++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (retcode != SQL_NO_DATA_FOUND)
|
||||||
|
{
|
||||||
|
DispAllErrors(henv, hdbc, hstmt);
|
||||||
|
fclose(fp);
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
SQLFreeStmt(hstmt, SQL_CLOSE);
|
||||||
|
fclose(fp);
|
||||||
|
return(TRUE);
|
||||||
|
|
||||||
|
} // wxDB::Catalog()
|
||||||
|
|
||||||
|
|
||||||
// Table name can refer to a table, view, alias or synonym. Returns true
|
// Table name can refer to a table, view, alias or synonym. Returns true
|
||||||
// if the object exists in the database. This function does not indicate
|
// if the object exists in the database. This function does not indicate
|
||||||
// whether or not the user has privleges to query or perform other functions
|
// whether or not the user has privleges to query or perform other functions
|
||||||
@@ -1190,6 +1302,54 @@ bool wxDB::TableExists(char *tableName)
|
|||||||
} // wxDB::TableExists()
|
} // wxDB::TableExists()
|
||||||
|
|
||||||
|
|
||||||
|
/********** wxDB::SqlLog() **********/
|
||||||
|
bool wxDB::SqlLog(enum sqlLog state, char *filename, bool append)
|
||||||
|
{
|
||||||
|
assert(state == sqlLogON || state == sqlLogOFF);
|
||||||
|
assert(state == sqlLogOFF || filename);
|
||||||
|
|
||||||
|
if (state == sqlLogON)
|
||||||
|
{
|
||||||
|
if (fpSqlLog == 0)
|
||||||
|
{
|
||||||
|
fpSqlLog = fopen(filename, (append ? "at" : "wt"));
|
||||||
|
if (fpSqlLog == NULL)
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // sqlLogOFF
|
||||||
|
{
|
||||||
|
if (fpSqlLog)
|
||||||
|
{
|
||||||
|
if (fclose(fpSqlLog))
|
||||||
|
return(FALSE);
|
||||||
|
fpSqlLog = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlLogState = state;
|
||||||
|
return(TRUE);
|
||||||
|
|
||||||
|
} // wxDB::SqlLog()
|
||||||
|
|
||||||
|
|
||||||
|
/********** wxDB::WriteSqlLog() **********/
|
||||||
|
bool wxDB::WriteSqlLog(char *logMsg)
|
||||||
|
{
|
||||||
|
assert(logMsg);
|
||||||
|
|
||||||
|
if (fpSqlLog == 0 || sqlLogState == sqlLogOFF)
|
||||||
|
return(FALSE);
|
||||||
|
|
||||||
|
if (fputs("\n", fpSqlLog) == EOF) return(FALSE);
|
||||||
|
if (fputs(logMsg, fpSqlLog) == EOF) return(FALSE);
|
||||||
|
if (fputs("\n", fpSqlLog) == EOF) return(FALSE);
|
||||||
|
|
||||||
|
return(TRUE);
|
||||||
|
|
||||||
|
} // wxDB::WriteSqlLog()
|
||||||
|
|
||||||
|
|
||||||
/********** GetDbConnection() **********/
|
/********** GetDbConnection() **********/
|
||||||
wxDB *GetDbConnection(DbStuff *pDbStuff)
|
wxDB *GetDbConnection(DbStuff *pDbStuff)
|
||||||
{
|
{
|
||||||
@@ -1319,4 +1479,5 @@ bool GetDataSource(HENV henv, char *Dsn, SWORD DsnMax, char *DsDesc, SWORD DsDes
|
|||||||
} // GetDataSource()
|
} // GetDataSource()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// wxUSE_ODBC
|
// wxUSE_ODBC
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: table.cpp
|
// Name: dbtable.cpp
|
||||||
// Purpose: Implementation of the wxTable class.
|
// Purpose: Implementation of the wxTable class.
|
||||||
// Author: Doug Card
|
// Author: Doug Card
|
||||||
// Modified by:
|
// Modified by:
|
||||||
@@ -18,6 +18,10 @@
|
|||||||
// the wxWindows GUI development toolkit.
|
// the wxWindows GUI development toolkit.
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation "dbtable.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// SYNOPSIS START
|
// SYNOPSIS START
|
||||||
// SYNOPSIS STOP
|
// SYNOPSIS STOP
|
||||||
@@ -46,14 +50,15 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#ifdef __WXUNIX__
|
#ifdef __UNIX__
|
||||||
// The HPUX preprocessor lines below were commented out on 8/20/97
|
// The HPUX preprocessor lines below were commented out on 8/20/97
|
||||||
// because macros.h currently redefines DEBUG and is unneeded.
|
// because macros.h currently redefines DEBUG and is unneeded.
|
||||||
// # ifdef HPUX
|
// # ifdef HPUX
|
||||||
// # include <macros.h>
|
// # include <macros.h>
|
||||||
// # endif
|
// # endif
|
||||||
# ifdef __WXLINUX__
|
# ifdef LINUX
|
||||||
# include <sys/minmax.h>
|
# include <sys/minmax.h>
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
@@ -63,16 +68,22 @@ wxTable::wxTable(wxDB *pwxDB, const char *tblName, const int nCols, const char *
|
|||||||
{
|
{
|
||||||
// Assign member variables
|
// Assign member variables
|
||||||
pDb = pwxDB; // Pointer to the wxDB object
|
pDb = pwxDB; // Pointer to the wxDB object
|
||||||
|
|
||||||
strcpy(tableName, tblName); // Table Name
|
strcpy(tableName, tblName); // Table Name
|
||||||
if (qryTblName) // Name of the table/view to query
|
if (qryTblName) // Name of the table/view to query
|
||||||
strcpy(queryTableName, qryTblName);
|
strcpy(queryTableName, qryTblName);
|
||||||
else
|
else
|
||||||
strcpy(queryTableName, tblName);
|
strcpy(queryTableName, tblName);
|
||||||
|
|
||||||
noCols = nCols; // No. of cols in the table
|
assert(pDb); // Assert is placed after table name is assigned for error reporting reasons
|
||||||
where = 0; // Where clause
|
if (!pDb)
|
||||||
orderBy = 0; // Order By clause
|
return;
|
||||||
selectForUpdate = FALSE; // SELECT ... FOR UPDATE; Indicates whether to include the FOR UPDATE phrase
|
|
||||||
|
noCols = nCols; // No. of cols in the table
|
||||||
|
where = 0; // Where clause
|
||||||
|
orderBy = 0; // Order By clause
|
||||||
|
from = 0; // From clause
|
||||||
|
selectForUpdate = FALSE; // SELECT ... FOR UPDATE; Indicates whether to include the FOR UPDATE phrase
|
||||||
|
|
||||||
// Grab the HENV and HDBC from the wxDB object
|
// Grab the HENV and HDBC from the wxDB object
|
||||||
henv = pDb->henv;
|
henv = pDb->henv;
|
||||||
@@ -214,15 +225,18 @@ wxTable::~wxTable()
|
|||||||
/********** wxTable::Open() **********/
|
/********** wxTable::Open() **********/
|
||||||
bool wxTable::Open(void)
|
bool wxTable::Open(void)
|
||||||
{
|
{
|
||||||
|
if (!pDb)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
char sqlStmt[DB_MAX_STATEMENT_LEN];
|
char sqlStmt[DB_MAX_STATEMENT_LEN];
|
||||||
|
|
||||||
// Verify that the table exists in the database
|
// Verify that the table exists in the database
|
||||||
if (!pDb->TableExists(tableName))
|
if (!pDb->TableExists(tableName))
|
||||||
{
|
{
|
||||||
wxString s;
|
char s[128];
|
||||||
s.Printf("Error opening '%s', table/view does not exist in the database.", tableName);
|
sprintf(s, "Error opening '%s', table/view does not exist in the database.", tableName);
|
||||||
pDb->LogError(WXSTRINGCAST(s));
|
pDb->LogError(s);
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,6 +286,8 @@ bool wxTable::Open(void)
|
|||||||
}
|
}
|
||||||
strcat(sqlStmt, ")");
|
strcat(sqlStmt, ")");
|
||||||
|
|
||||||
|
pDb->WriteSqlLog(sqlStmt);
|
||||||
|
|
||||||
// Prepare the insert statement for execution
|
// Prepare the insert statement for execution
|
||||||
if (SQLPrepare(hstmtInsert, (UCHAR FAR *) sqlStmt, SQL_NTS) != SQL_SUCCESS)
|
if (SQLPrepare(hstmtInsert, (UCHAR FAR *) sqlStmt, SQL_NTS) != SQL_SUCCESS)
|
||||||
return(pDb->DispAllErrors(henv, hdbc, hstmtInsert));
|
return(pDb->DispAllErrors(henv, hdbc, hstmtInsert));
|
||||||
@@ -293,6 +309,7 @@ bool wxTable::Query(bool forUpdate, bool distinct)
|
|||||||
/********** wxTable::QueryBySqlStmt() **********/
|
/********** wxTable::QueryBySqlStmt() **********/
|
||||||
bool wxTable::QueryBySqlStmt(char *pSqlStmt)
|
bool wxTable::QueryBySqlStmt(char *pSqlStmt)
|
||||||
{
|
{
|
||||||
|
pDb->WriteSqlLog(pSqlStmt);
|
||||||
|
|
||||||
return(query(DB_SELECT_STATEMENT, FALSE, FALSE, pSqlStmt));
|
return(query(DB_SELECT_STATEMENT, FALSE, FALSE, pSqlStmt));
|
||||||
|
|
||||||
@@ -328,7 +345,10 @@ bool wxTable::query(int queryType, bool forUpdate, bool distinct, char *pSqlStmt
|
|||||||
|
|
||||||
// Set the SQL SELECT string
|
// Set the SQL SELECT string
|
||||||
if (queryType != DB_SELECT_STATEMENT) // A select statement was not passed in,
|
if (queryType != DB_SELECT_STATEMENT) // A select statement was not passed in,
|
||||||
GetSelectStmt(sqlStmt, queryType, distinct); // so generate a select statement.
|
{ // so generate a select statement.
|
||||||
|
GetSelectStmt(sqlStmt, queryType, distinct);
|
||||||
|
pDb->WriteSqlLog(sqlStmt);
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure the cursor is closed first
|
// Make sure the cursor is closed first
|
||||||
if (! CloseCursor(hstmt))
|
if (! CloseCursor(hstmt))
|
||||||
@@ -358,9 +378,21 @@ void wxTable::GetSelectStmt(char *pSqlStmt, int typeOfSelect, bool distinct)
|
|||||||
if (distinct)
|
if (distinct)
|
||||||
strcat(pSqlStmt, "DISTINCT ");
|
strcat(pSqlStmt, "DISTINCT ");
|
||||||
|
|
||||||
|
// Was a FROM clause specified to join tables to the base table?
|
||||||
|
// Available for ::Query() only!!!
|
||||||
|
bool appendFromClause = FALSE;
|
||||||
|
if (typeOfSelect == DB_SELECT_WHERE && from && strlen(from))
|
||||||
|
appendFromClause = TRUE;
|
||||||
|
|
||||||
// Add the column list
|
// Add the column list
|
||||||
for (int i = 0; i < noCols; i++)
|
for (int i = 0; i < noCols; i++)
|
||||||
{
|
{
|
||||||
|
// If joining tables, the base table column names must be qualified to avoid ambiguity
|
||||||
|
if (appendFromClause)
|
||||||
|
{
|
||||||
|
strcat(pSqlStmt, queryTableName);
|
||||||
|
strcat(pSqlStmt, ".");
|
||||||
|
}
|
||||||
strcat(pSqlStmt, colDefs[i].ColName);
|
strcat(pSqlStmt, colDefs[i].ColName);
|
||||||
if (i + 1 < noCols)
|
if (i + 1 < noCols)
|
||||||
strcat(pSqlStmt, ",");
|
strcat(pSqlStmt, ",");
|
||||||
@@ -369,11 +401,23 @@ void wxTable::GetSelectStmt(char *pSqlStmt, int typeOfSelect, bool distinct)
|
|||||||
// If the datasource supports ROWID, get this column as well. Exception: Don't retrieve
|
// If the datasource supports ROWID, get this column as well. Exception: Don't retrieve
|
||||||
// the ROWID if querying distinct records. The rowid will always be unique.
|
// the ROWID if querying distinct records. The rowid will always be unique.
|
||||||
if (!distinct && CanUpdByROWID())
|
if (!distinct && CanUpdByROWID())
|
||||||
strcat(pSqlStmt, ",ROWID");
|
{
|
||||||
|
// If joining tables, the base table column names must be qualified to avoid ambiguity
|
||||||
|
if (appendFromClause)
|
||||||
|
{
|
||||||
|
strcat(pSqlStmt, ",");
|
||||||
|
strcat(pSqlStmt, queryTableName);
|
||||||
|
strcat(pSqlStmt, ".ROWID");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strcat(pSqlStmt, ",ROWID");
|
||||||
|
}
|
||||||
|
|
||||||
// Append the FROM tablename portion
|
// Append the FROM tablename portion
|
||||||
strcat(pSqlStmt, " FROM ");
|
strcat(pSqlStmt, " FROM ");
|
||||||
strcat(pSqlStmt, queryTableName);
|
strcat(pSqlStmt, queryTableName);
|
||||||
|
if (appendFromClause)
|
||||||
|
strcat(pSqlStmt, from);
|
||||||
|
|
||||||
// Append the WHERE clause. Either append the where clause for the class
|
// Append the WHERE clause. Either append the where clause for the class
|
||||||
// or build a where clause. The typeOfSelect determines this.
|
// or build a where clause. The typeOfSelect determines this.
|
||||||
@@ -468,12 +512,9 @@ bool wxTable::bindInsertParams(void)
|
|||||||
UDWORD precision;
|
UDWORD precision;
|
||||||
SWORD scale;
|
SWORD scale;
|
||||||
|
|
||||||
//glt CcolDef *tColDef;
|
|
||||||
|
|
||||||
// Bind each column (that can be inserted) of the table to a parameter marker
|
// Bind each column (that can be inserted) of the table to a parameter marker
|
||||||
for (int i = 0; i < noCols; i++)
|
for (int i = 0; i < noCols; i++)
|
||||||
{
|
{
|
||||||
//glt tColDef = &colDefs[i];
|
|
||||||
if (! colDefs[i].InsertAllowed)
|
if (! colDefs[i].InsertAllowed)
|
||||||
continue;
|
continue;
|
||||||
switch(colDefs[i].DbDataType)
|
switch(colDefs[i].DbDataType)
|
||||||
@@ -606,6 +647,9 @@ bool wxTable::CloseCursor(HSTMT cursor)
|
|||||||
/********** wxTable::CreateTable() **********/
|
/********** wxTable::CreateTable() **********/
|
||||||
bool wxTable::CreateTable(void)
|
bool wxTable::CreateTable(void)
|
||||||
{
|
{
|
||||||
|
if (!pDb)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
int i, j;
|
int i, j;
|
||||||
char sqlStmt[DB_MAX_STATEMENT_LEN];
|
char sqlStmt[DB_MAX_STATEMENT_LEN];
|
||||||
|
|
||||||
@@ -632,6 +676,8 @@ bool wxTable::CreateTable(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pDb->WriteSqlLog(sqlStmt);
|
||||||
|
|
||||||
// Commit the transaction and close the cursor
|
// Commit the transaction and close the cursor
|
||||||
if (! pDb->CommitTrans())
|
if (! pDb->CommitTrans())
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
@@ -694,11 +740,11 @@ bool wxTable::CreateTable(void)
|
|||||||
// For varchars, append the size of the string
|
// For varchars, append the size of the string
|
||||||
if (colDefs[i].DbDataType == DB_DATA_TYPE_VARCHAR)
|
if (colDefs[i].DbDataType == DB_DATA_TYPE_VARCHAR)
|
||||||
{
|
{
|
||||||
|
char s[10];
|
||||||
// strcat(sqlStmt, "(");
|
// strcat(sqlStmt, "(");
|
||||||
// strcat(sqlStmt, itoa(colDefs[i].SzDataObj, s, 10));
|
// strcat(sqlStmt, itoa(colDefs[i].SzDataObj, s, 10));
|
||||||
// strcat(sqlStmt, ")");
|
// strcat(sqlStmt, ")");
|
||||||
wxString s;
|
sprintf(s, "(%d)", colDefs[i].SzDataObj);
|
||||||
s.Printf("(%d)", colDefs[i].SzDataObj);
|
|
||||||
strcat(sqlStmt, s);
|
strcat(sqlStmt, s);
|
||||||
}
|
}
|
||||||
needComma = TRUE;
|
needComma = TRUE;
|
||||||
@@ -732,6 +778,8 @@ bool wxTable::CreateTable(void)
|
|||||||
// Append the closing parentheses for the create table statement
|
// Append the closing parentheses for the create table statement
|
||||||
strcat(sqlStmt, ")");
|
strcat(sqlStmt, ")");
|
||||||
|
|
||||||
|
pDb->WriteSqlLog(sqlStmt);
|
||||||
|
|
||||||
#ifdef _CONSOLE
|
#ifdef _CONSOLE
|
||||||
cout << endl << sqlStmt << endl;
|
cout << endl << sqlStmt << endl;
|
||||||
#endif
|
#endif
|
||||||
@@ -787,6 +835,8 @@ bool wxTable::CreateIndex(char * idxName, bool unique, int noIdxCols, CidxDef *p
|
|||||||
// Append closing parentheses
|
// Append closing parentheses
|
||||||
strcat(sqlStmt, ")");
|
strcat(sqlStmt, ")");
|
||||||
|
|
||||||
|
pDb->WriteSqlLog(sqlStmt);
|
||||||
|
|
||||||
#ifdef _CONSOLE
|
#ifdef _CONSOLE
|
||||||
cout << endl << sqlStmt << endl << endl;
|
cout << endl << sqlStmt << endl << endl;
|
||||||
#endif
|
#endif
|
||||||
@@ -837,6 +887,7 @@ int wxTable::Insert(void)
|
|||||||
/********** wxTable::Update(pSqlStmt) **********/
|
/********** wxTable::Update(pSqlStmt) **********/
|
||||||
bool wxTable::Update(char *pSqlStmt)
|
bool wxTable::Update(char *pSqlStmt)
|
||||||
{
|
{
|
||||||
|
pDb->WriteSqlLog(pSqlStmt);
|
||||||
|
|
||||||
return(execUpdate(pSqlStmt));
|
return(execUpdate(pSqlStmt));
|
||||||
|
|
||||||
@@ -850,6 +901,8 @@ bool wxTable::Update(void)
|
|||||||
// Build the SQL UPDATE statement
|
// Build the SQL UPDATE statement
|
||||||
GetUpdateStmt(sqlStmt, DB_UPD_KEYFIELDS);
|
GetUpdateStmt(sqlStmt, DB_UPD_KEYFIELDS);
|
||||||
|
|
||||||
|
pDb->WriteSqlLog(sqlStmt);
|
||||||
|
|
||||||
#ifdef _CONSOLE
|
#ifdef _CONSOLE
|
||||||
cout << endl << sqlStmt << endl << endl;
|
cout << endl << sqlStmt << endl << endl;
|
||||||
#endif
|
#endif
|
||||||
@@ -867,6 +920,8 @@ bool wxTable::UpdateWhere(char *pWhereClause)
|
|||||||
// Build the SQL UPDATE statement
|
// Build the SQL UPDATE statement
|
||||||
GetUpdateStmt(sqlStmt, DB_UPD_WHERE, pWhereClause);
|
GetUpdateStmt(sqlStmt, DB_UPD_WHERE, pWhereClause);
|
||||||
|
|
||||||
|
pDb->WriteSqlLog(sqlStmt);
|
||||||
|
|
||||||
#ifdef _CONSOLE
|
#ifdef _CONSOLE
|
||||||
cout << endl << sqlStmt << endl << endl;
|
cout << endl << sqlStmt << endl << endl;
|
||||||
#endif
|
#endif
|
||||||
@@ -884,6 +939,8 @@ bool wxTable::Delete(void)
|
|||||||
// Build the SQL DELETE statement
|
// Build the SQL DELETE statement
|
||||||
GetDeleteStmt(sqlStmt, DB_DEL_KEYFIELDS);
|
GetDeleteStmt(sqlStmt, DB_DEL_KEYFIELDS);
|
||||||
|
|
||||||
|
pDb->WriteSqlLog(sqlStmt);
|
||||||
|
|
||||||
// Execute the SQL DELETE statement
|
// Execute the SQL DELETE statement
|
||||||
return(execDelete(sqlStmt));
|
return(execDelete(sqlStmt));
|
||||||
|
|
||||||
@@ -897,6 +954,8 @@ bool wxTable::DeleteWhere(char *pWhereClause)
|
|||||||
// Build the SQL DELETE statement
|
// Build the SQL DELETE statement
|
||||||
GetDeleteStmt(sqlStmt, DB_DEL_WHERE, pWhereClause);
|
GetDeleteStmt(sqlStmt, DB_DEL_WHERE, pWhereClause);
|
||||||
|
|
||||||
|
pDb->WriteSqlLog(sqlStmt);
|
||||||
|
|
||||||
// Execute the SQL DELETE statement
|
// Execute the SQL DELETE statement
|
||||||
return(execDelete(sqlStmt));
|
return(execDelete(sqlStmt));
|
||||||
|
|
||||||
@@ -910,6 +969,8 @@ bool wxTable::DeleteMatching(void)
|
|||||||
// Build the SQL DELETE statement
|
// Build the SQL DELETE statement
|
||||||
GetDeleteStmt(sqlStmt, DB_DEL_MATCHING);
|
GetDeleteStmt(sqlStmt, DB_DEL_MATCHING);
|
||||||
|
|
||||||
|
pDb->WriteSqlLog(sqlStmt);
|
||||||
|
|
||||||
// Execute the SQL DELETE statement
|
// Execute the SQL DELETE statement
|
||||||
return(execDelete(sqlStmt));
|
return(execDelete(sqlStmt));
|
||||||
|
|
||||||
@@ -1061,10 +1122,10 @@ void wxTable::GetDeleteStmt(char *pSqlStmt, int typeOfDel, char *pWhereClause)
|
|||||||
* They are not included as part of the where clause.
|
* They are not included as part of the where clause.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void wxTable::GetWhereClause(char *pWhereClause, int typeOfWhere)
|
void wxTable::GetWhereClause(char *pWhereClause, int typeOfWhere, char *qualTableName)
|
||||||
{
|
{
|
||||||
bool moreThanOneColumn = FALSE;
|
bool moreThanOneColumn = FALSE;
|
||||||
wxString colValue;
|
char colValue[255];
|
||||||
|
|
||||||
// Loop through the columns building a where clause as you go
|
// Loop through the columns building a where clause as you go
|
||||||
for (int i = 0; i < noCols; i++)
|
for (int i = 0; i < noCols; i++)
|
||||||
@@ -1082,30 +1143,35 @@ void wxTable::GetWhereClause(char *pWhereClause, int typeOfWhere)
|
|||||||
else
|
else
|
||||||
moreThanOneColumn = TRUE;
|
moreThanOneColumn = TRUE;
|
||||||
// Concatenate where phrase for the column
|
// Concatenate where phrase for the column
|
||||||
|
if (qualTableName && strlen(qualTableName))
|
||||||
|
{
|
||||||
|
strcat(pWhereClause, qualTableName);
|
||||||
|
strcat(pWhereClause, ".");
|
||||||
|
}
|
||||||
strcat(pWhereClause, colDefs[i].ColName);
|
strcat(pWhereClause, colDefs[i].ColName);
|
||||||
strcat(pWhereClause, " = ");
|
strcat(pWhereClause, " = ");
|
||||||
switch(colDefs[i].SqlCtype)
|
switch(colDefs[i].SqlCtype)
|
||||||
{
|
{
|
||||||
case SQL_C_CHAR:
|
case SQL_C_CHAR:
|
||||||
colValue.Printf("'%s'", (UCHAR FAR *) colDefs[i].PtrDataObj);
|
sprintf(colValue, "'%s'", (UCHAR FAR *) colDefs[i].PtrDataObj);
|
||||||
break;
|
break;
|
||||||
case SQL_C_SSHORT:
|
case SQL_C_SSHORT:
|
||||||
colValue.Printf("%hi", *((SWORD *) colDefs[i].PtrDataObj));
|
sprintf(colValue, "%hi", *((SWORD *) colDefs[i].PtrDataObj));
|
||||||
break;
|
break;
|
||||||
case SQL_C_USHORT:
|
case SQL_C_USHORT:
|
||||||
colValue.Printf("%hu", *((UWORD *) colDefs[i].PtrDataObj));
|
sprintf(colValue, "%hu", *((UWORD *) colDefs[i].PtrDataObj));
|
||||||
break;
|
break;
|
||||||
case SQL_C_SLONG:
|
case SQL_C_SLONG:
|
||||||
colValue.Printf("%li", *((SDWORD *) colDefs[i].PtrDataObj));
|
sprintf(colValue, "%li", *((SDWORD *) colDefs[i].PtrDataObj));
|
||||||
break;
|
break;
|
||||||
case SQL_C_ULONG:
|
case SQL_C_ULONG:
|
||||||
colValue.Printf("%lu", *((UDWORD *) colDefs[i].PtrDataObj));
|
sprintf(colValue, "%lu", *((UDWORD *) colDefs[i].PtrDataObj));
|
||||||
break;
|
break;
|
||||||
case SQL_C_FLOAT:
|
case SQL_C_FLOAT:
|
||||||
colValue.Printf("%.6f", *((SFLOAT *) colDefs[i].PtrDataObj));
|
sprintf(colValue, "%.6f", *((SFLOAT *) colDefs[i].PtrDataObj));
|
||||||
break;
|
break;
|
||||||
case SQL_C_DOUBLE:
|
case SQL_C_DOUBLE:
|
||||||
colValue.Printf("%.6f", *((SDOUBLE *) colDefs[i].PtrDataObj));
|
sprintf(colValue, "%.6f", *((SDOUBLE *) colDefs[i].PtrDataObj));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
strcat(pWhereClause, colValue);
|
strcat(pWhereClause, colValue);
|
||||||
@@ -1161,7 +1227,8 @@ bool wxTable::CanSelectForUpdate(void)
|
|||||||
bool wxTable::CanUpdByROWID(void)
|
bool wxTable::CanUpdByROWID(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
//@@@@@@glt - returning FALSE for testing purposes, as the ROWID is not getting updated correctly
|
//NOTE: Returning FALSE for now until this can be debugged,
|
||||||
|
// as the ROWID is not getting updated correctly
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if ((! strcmp(pDb->dbInf.dbmsName, "Oracle")) || (! strcmp(pDb->dbInf.dbmsName, "ORACLE")))
|
if ((! strcmp(pDb->dbInf.dbmsName, "Oracle")) || (! strcmp(pDb->dbInf.dbmsName, "ORACLE")))
|
||||||
@@ -1345,6 +1412,9 @@ ULONG wxTable::Count(void)
|
|||||||
strcpy(sqlStmt, "SELECT COUNT(*) FROM ");
|
strcpy(sqlStmt, "SELECT COUNT(*) FROM ");
|
||||||
strcat(sqlStmt, queryTableName);
|
strcat(sqlStmt, queryTableName);
|
||||||
|
|
||||||
|
if (from && strlen(from))
|
||||||
|
strcat(sqlStmt, from);
|
||||||
|
|
||||||
// Add the where clause if one is provided
|
// Add the where clause if one is provided
|
||||||
if (where && strlen(where))
|
if (where && strlen(where))
|
||||||
{
|
{
|
||||||
@@ -1352,6 +1422,8 @@ ULONG wxTable::Count(void)
|
|||||||
strcat(sqlStmt, where);
|
strcat(sqlStmt, where);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pDb->WriteSqlLog(sqlStmt);
|
||||||
|
|
||||||
// Execute the SQL statement
|
// Execute the SQL statement
|
||||||
if (SQLExecDirect(hstmtCount, (UCHAR FAR *) sqlStmt, SQL_NTS) != SQL_SUCCESS)
|
if (SQLExecDirect(hstmtCount, (UCHAR FAR *) sqlStmt, SQL_NTS) != SQL_SUCCESS)
|
||||||
{
|
{
|
||||||
@@ -1410,7 +1482,8 @@ bool wxTable::Refresh(void)
|
|||||||
// based on the key fields.
|
// based on the key fields.
|
||||||
if (SQLGetData(hstmt, noCols+1, SQL_C_CHAR, rowid, ROWID_LEN, &cb) == SQL_SUCCESS)
|
if (SQLGetData(hstmt, noCols+1, SQL_C_CHAR, rowid, ROWID_LEN, &cb) == SQL_SUCCESS)
|
||||||
{
|
{
|
||||||
strcat(whereClause, "ROWID = '");
|
strcat(whereClause, queryTableName);
|
||||||
|
strcat(whereClause, ".ROWID = '");
|
||||||
strcat(whereClause, rowid);
|
strcat(whereClause, rowid);
|
||||||
strcat(whereClause, "'");
|
strcat(whereClause, "'");
|
||||||
}
|
}
|
||||||
@@ -1418,7 +1491,7 @@ bool wxTable::Refresh(void)
|
|||||||
|
|
||||||
// If unable to use the ROWID, build a where clause from the keyfields
|
// If unable to use the ROWID, build a where clause from the keyfields
|
||||||
if (strlen(whereClause) == 0)
|
if (strlen(whereClause) == 0)
|
||||||
GetWhereClause(whereClause, DB_WHERE_KEYFIELDS);
|
GetWhereClause(whereClause, DB_WHERE_KEYFIELDS, queryTableName);
|
||||||
|
|
||||||
// Requery the record
|
// Requery the record
|
||||||
where = whereClause;
|
where = whereClause;
|
||||||
@@ -1442,4 +1515,5 @@ bool wxTable::Refresh(void)
|
|||||||
} // wxTable::Refresh()
|
} // wxTable::Refresh()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// wxUSE_ODBC
|
// wxUSE_ODBC
|
||||||
|
|
||||||
|
@@ -1075,6 +1075,19 @@ bool wxString::Matches(const char *pszMask) const
|
|||||||
return *pszTxt == '\0';
|
return *pszTxt == '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Count the number of chars
|
||||||
|
int wxString::Freq(char ch) const
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
int len = Len();
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
if (GetChar(i) == ch)
|
||||||
|
count ++;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// standard C++ library string functions
|
// standard C++ library string functions
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user