Class renaming so that all ODBC related classes begin with wxDbXxxxx. Backward compatability is maintained using typedefs.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7050 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
143
include/wx/db.h
143
include/wx/db.h
@@ -1,7 +1,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: db.h
|
// Name: db.h
|
||||||
// Purpose: Header file wxDB class. The wxDB class represents a connection
|
// Purpose: Header file wxDb class. The wxDb class represents a connection
|
||||||
// to an ODBC data source. The wxDB class allows operations on the data
|
// to an ODBC data source. The wxDb class allows operations on the data
|
||||||
// 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: George Tasker
|
// Modified by: George Tasker
|
||||||
@@ -246,7 +246,7 @@ struct wxDbConnectInf
|
|||||||
char defaultDir[DB_PATH_MAX]; // Directory that db file resides in
|
char defaultDir[DB_PATH_MAX]; // Directory that db file resides in
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wxSqlTypeInfo
|
struct wxDbSqlTypeInfo
|
||||||
{
|
{
|
||||||
char TypeName[DB_TYPE_NAME_LEN];
|
char TypeName[DB_TYPE_NAME_LEN];
|
||||||
int FsqlType;
|
int FsqlType;
|
||||||
@@ -257,7 +257,7 @@ struct wxSqlTypeInfo
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxColFor
|
class WXDLLEXPORT wxDbColFor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxString s_Field; // Formated String for Output
|
wxString s_Field; // Formated String for Output
|
||||||
@@ -268,14 +268,14 @@ public:
|
|||||||
int i_dbDataType; // conversion of the 'sqlDataType' to the generic data type used by these classes
|
int i_dbDataType; // conversion of the 'sqlDataType' to the generic data type used by these classes
|
||||||
SWORD i_sqlDataType;
|
SWORD i_sqlDataType;
|
||||||
|
|
||||||
wxColFor();
|
wxDbColFor();
|
||||||
~wxColFor();
|
~wxDbColFor();
|
||||||
|
|
||||||
int Format(int Nation, int dbDataType, SWORD sqlDataType, short columnSize, short decimalDigits);
|
int Format(int Nation, int dbDataType, SWORD sqlDataType, short columnSize, short decimalDigits);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxColInf
|
class WXDLLEXPORT wxDbColInf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
char catalog[128+1];
|
char catalog[128+1];
|
||||||
@@ -296,39 +296,39 @@ public:
|
|||||||
char PkTableName[DB_MAX_TABLE_NAME_LEN+1]; // Tables that use this PKey as a FKey
|
char PkTableName[DB_MAX_TABLE_NAME_LEN+1]; // Tables that use this PKey as a FKey
|
||||||
int FkCol; // Foreign key column 0=No; 1= First Key, 2 = Second Key etc.
|
int FkCol; // Foreign key column 0=No; 1= First Key, 2 = Second Key etc.
|
||||||
char FkTableName[DB_MAX_TABLE_NAME_LEN+1]; // Foreign key table name
|
char FkTableName[DB_MAX_TABLE_NAME_LEN+1]; // Foreign key table name
|
||||||
wxColFor *pColFor; // How should this columns be formatted
|
wxDbColFor *pColFor; // How should this columns be formatted
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxTableInf // Description of a Table
|
class WXDLLEXPORT wxDbTableInf // Description of a Table
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
char tableName[DB_MAX_TABLE_NAME_LEN+1];
|
char tableName[DB_MAX_TABLE_NAME_LEN+1];
|
||||||
char tableType[254+1]; // "TABLE" or "SYSTEM TABLE" etc.
|
char tableType[254+1]; // "TABLE" or "SYSTEM TABLE" etc.
|
||||||
char tableRemarks[254+1];
|
char tableRemarks[254+1];
|
||||||
int numCols; // How many Columns does this Table have: GetColumnCount(..);
|
int numCols; // How many Columns does this Table have: GetColumnCount(..);
|
||||||
wxColInf *pColInf; // pColInf = NULL ; User can later call GetColumns(..);
|
wxDbColInf *pColInf; // pColInf = NULL ; User can later call GetColumns(..);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxDbInf // Description of a Database
|
class WXDLLEXPORT wxDbInf // Description of a Database
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
char catalog[128+1];
|
char catalog[128+1];
|
||||||
char schema[128+1];
|
char schema[128+1];
|
||||||
int numTables; // How many tables does this database have
|
int numTables; // How many tables does this database have
|
||||||
wxTableInf *pTableInf; // pTableInf = new wxTableInf[numTables];
|
wxDbTableInf *pTableInf; // pTableInf = new wxDbTableInf[numTables];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum wxSqlLogState
|
enum wxDbSqlLogState
|
||||||
{
|
{
|
||||||
sqlLogOFF,
|
sqlLogOFF,
|
||||||
sqlLogON
|
sqlLogON
|
||||||
};
|
};
|
||||||
|
|
||||||
// These are the databases currently tested and working with these classes
|
// These are the databases currently tested and working with these classes
|
||||||
// See the comments in wxDB::Dbms() for exceptions/issues with
|
// See the comments in wxDb::Dbms() for exceptions/issues with
|
||||||
// each of these database engines
|
// each of these database engines
|
||||||
enum wxDBMS
|
enum wxDBMS
|
||||||
{
|
{
|
||||||
@@ -345,17 +345,17 @@ enum wxDBMS
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// The wxDB::errorList is copied to this variable when the wxDB object
|
// The wxDb::errorList is copied to this variable when the wxDb object
|
||||||
// is closed. This way, the error list is still available after the
|
// is closed. This way, the error list is still available after the
|
||||||
// database object is closed. This is necessary if the database
|
// database object is closed. This is necessary if the database
|
||||||
// connection fails so the calling application can show the operator
|
// connection fails so the calling application can show the operator
|
||||||
// why the connection failed. Note: as each wxDB object is closed, it
|
// why the connection failed. Note: as each wxDb object is closed, it
|
||||||
// will overwrite the errors of the previously destroyed wxDB object in
|
// will overwrite the errors of the previously destroyed wxDb object in
|
||||||
// this variable.
|
// this variable.
|
||||||
extern char DBerrorList[DB_MAX_ERROR_HISTORY][DB_MAX_ERROR_MSG_LEN];
|
extern char DBerrorList[DB_MAX_ERROR_HISTORY][DB_MAX_ERROR_MSG_LEN];
|
||||||
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxDB
|
class WXDLLEXPORT wxDb
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bool dbIsOpen;
|
bool dbIsOpen;
|
||||||
@@ -363,15 +363,23 @@ private:
|
|||||||
char *uid; // User ID
|
char *uid; // User ID
|
||||||
char *authStr; // Authorization string (password)
|
char *authStr; // Authorization string (password)
|
||||||
FILE *fpSqlLog; // Sql Log file pointer
|
FILE *fpSqlLog; // Sql Log file pointer
|
||||||
wxSqlLogState sqlLogState; // On or Off
|
wxDbSqlLogState sqlLogState; // On or Off
|
||||||
bool fwdOnlyCursors;
|
bool fwdOnlyCursors;
|
||||||
|
|
||||||
// Private member functions
|
// Private member functions
|
||||||
bool getDbInfo(void);
|
bool getDbInfo(void);
|
||||||
bool getDataTypeInfo(SWORD fSqlType, wxSqlTypeInfo &structSQLTypeInfo);
|
bool getDataTypeInfo(SWORD fSqlType, wxDbSqlTypeInfo &structSQLTypeInfo);
|
||||||
bool setConnectionOptions(void);
|
bool setConnectionOptions(void);
|
||||||
void logError(const char *errMsg, const char *SQLState);
|
void logError(const char *errMsg, const char *SQLState);
|
||||||
|
|
||||||
|
// ODBC handles
|
||||||
|
HENV henv; // ODBC Environment handle
|
||||||
|
HDBC hdbc; // ODBC DB Connection handle
|
||||||
|
HSTMT hstmt; // ODBC Statement handle
|
||||||
|
|
||||||
|
//Error reporting mode
|
||||||
|
bool silent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// The following structure contains database information gathered from the
|
// The following structure contains database information gathered from the
|
||||||
// datasource when the datasource is first opened.
|
// datasource when the datasource is first opened.
|
||||||
@@ -409,34 +417,27 @@ public:
|
|||||||
UDWORD loginTimeout; // Number seconds to wait for a login request
|
UDWORD loginTimeout; // Number seconds to wait for a login request
|
||||||
} dbInf;
|
} dbInf;
|
||||||
|
|
||||||
// ODBC handles
|
|
||||||
HENV henv; // ODBC Environment handle
|
|
||||||
HDBC hdbc; // ODBC DB Connection handle
|
|
||||||
HSTMT hstmt; // ODBC Statement handle
|
|
||||||
|
|
||||||
// ODBC Error Inf.
|
// ODBC Error Inf.
|
||||||
wxChar sqlState[20];
|
|
||||||
SDWORD nativeError;
|
|
||||||
wxChar errorMsg[SQL_MAX_MESSAGE_LENGTH];
|
|
||||||
SWORD cbErrorMsg;
|
SWORD cbErrorMsg;
|
||||||
wxChar errorList[DB_MAX_ERROR_HISTORY][DB_MAX_ERROR_MSG_LEN];
|
|
||||||
int DB_STATUS;
|
int DB_STATUS;
|
||||||
|
wxChar errorList[DB_MAX_ERROR_HISTORY][DB_MAX_ERROR_MSG_LEN];
|
||||||
|
wxChar errorMsg[SQL_MAX_MESSAGE_LENGTH];
|
||||||
|
SDWORD nativeError;
|
||||||
|
wxChar sqlState[20];
|
||||||
|
|
||||||
//Error reporting mode
|
// Number of Ctable objects connected to this db object. FOR INTERNAL USE ONLY!!!
|
||||||
bool silent;
|
|
||||||
|
|
||||||
// Number of Ctable objects connected to this db object
|
|
||||||
unsigned int nTables;
|
unsigned int nTables;
|
||||||
|
|
||||||
// Inf. about logical data types VARCHAR, INTEGER, FLOAT and DATE.
|
// Information about logical data types VARCHAR, INTEGER, FLOAT and DATE.
|
||||||
// This inf. is obtained from the ODBC driver by use of the
|
//
|
||||||
// SQLGetTypeInfo() function. The key piece of inf. is the
|
// 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.
|
// type name the data source uses for each logical data type.
|
||||||
// e.g. VARCHAR; Oracle calls it VARCHAR2.
|
// e.g. VARCHAR; Oracle calls it VARCHAR2.
|
||||||
wxSqlTypeInfo typeInfVarchar, typeInfInteger, typeInfFloat, typeInfDate;
|
wxDbSqlTypeInfo typeInfVarchar, typeInfInteger, typeInfFloat, typeInfDate;
|
||||||
|
|
||||||
// Public member functions
|
// Public member functions
|
||||||
wxDB(HENV &aHenv, bool FwdOnlyCursors=(bool)TRUE);
|
wxDb(HENV &aHenv, bool FwdOnlyCursors=(bool)TRUE);
|
||||||
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);
|
||||||
@@ -450,12 +451,12 @@ public:
|
|||||||
bool GetNext(void);
|
bool GetNext(void);
|
||||||
bool GetData(UWORD colNo, SWORD cType, PTR pData, SDWORD maxLen, SDWORD FAR *cbReturned);
|
bool GetData(UWORD colNo, SWORD cType, PTR pData, SDWORD maxLen, SDWORD FAR *cbReturned);
|
||||||
bool Grant(int privileges, const char *tableName, const char *userList = "PUBLIC");
|
bool Grant(int privileges, const char *tableName, const char *userList = "PUBLIC");
|
||||||
int TranslateSqlState(const char *SQLState);
|
int TranslateSqlState(const wxChar *SQLState);
|
||||||
wxDbInf *GetCatalog(char *userID);
|
wxDbInf *GetCatalog(char *userID);
|
||||||
bool Catalog(const char *userID=NULL, const char *fileName = SQL_CATALOG_FILENAME);
|
bool Catalog(const char *userID=NULL, const char *fileName = SQL_CATALOG_FILENAME);
|
||||||
int GetKeyFields(char *tableName, wxColInf* colInf,int nocols);
|
int GetKeyFields(char *tableName, wxDbColInf* colInf, int nocols);
|
||||||
wxColInf *GetColumns(char *tableName[], const char *userID=NULL);
|
wxDbColInf *GetColumns(char *tableName[], const char *userID=NULL);
|
||||||
wxColInf *GetColumns(char *tableName, int *numCols, const char *userID=NULL);
|
wxDbColInf *GetColumns(char *tableName, int *numCols, const char *userID=NULL);
|
||||||
int GetColumnCount(char *tableName, const char *userID=NULL);
|
int GetColumnCount(char *tableName, const char *userID=NULL);
|
||||||
char *GetDatabaseName(void) {return dbInf.dbmsName;}
|
char *GetDatabaseName(void) {return dbInf.dbmsName;}
|
||||||
char *GetDataSource(void) {return dsn;}
|
char *GetDataSource(void) {return dsn;}
|
||||||
@@ -467,11 +468,11 @@ public:
|
|||||||
HSTMT GetHSTMT(void) {return hstmt;}
|
HSTMT GetHSTMT(void) {return hstmt;}
|
||||||
bool TableExists(const char *tableName, const char *userID=NULL, const char *path=NULL); // Table name can refer to a table, view, alias or synonym
|
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 LogError(const char *errMsg, const char *SQLState = 0) {logError(errMsg, SQLState);}
|
||||||
bool SqlLog(wxSqlLogState state, const char *filename = SQL_LOG_FILENAME, bool append = FALSE);
|
bool SetSqlLogging(wxDbSqlLogState state, const wxChar *filename = SQL_LOG_FILENAME, bool append = FALSE);
|
||||||
bool WriteSqlLog(const char *logMsg);
|
bool WriteSqlLog(const wxChar *logMsg);
|
||||||
wxDBMS Dbms(void);
|
wxDBMS Dbms(void);
|
||||||
bool FwdOnlyCursors(void) {return fwdOnlyCursors;}
|
bool FwdOnlyCursors(void) {return fwdOnlyCursors;}
|
||||||
}; // wxDB
|
}; // wxDb
|
||||||
|
|
||||||
|
|
||||||
// This structure forms a node in a linked list. The linked list of "DbList" objects
|
// This structure forms a node in a linked list. The linked list of "DbList" objects
|
||||||
@@ -481,8 +482,8 @@ public:
|
|||||||
struct wxDbList
|
struct wxDbList
|
||||||
{
|
{
|
||||||
wxDbList *PtrPrev; // Pointer to previous item in the list
|
wxDbList *PtrPrev; // Pointer to previous item in the list
|
||||||
char Dsn[SQL_MAX_DSN_LENGTH+1]; // Data Source Name
|
wxChar Dsn[SQL_MAX_DSN_LENGTH+1]; // Data Source Name
|
||||||
wxDB *PtrDb; // Pointer to the wxDB object
|
wxDb *PtrDb; // Pointer to the wxDb object
|
||||||
bool Free; // Is item free or in use?
|
bool Free; // Is item free or in use?
|
||||||
wxDbList *PtrNext; // Pointer to next item in the list
|
wxDbList *PtrNext; // Pointer to next item in the list
|
||||||
};
|
};
|
||||||
@@ -494,7 +495,7 @@ class wxTablesInUse : public wxObject
|
|||||||
public:
|
public:
|
||||||
const char *tableName;
|
const char *tableName;
|
||||||
ULONG tableID;
|
ULONG tableID;
|
||||||
class wxDB *pDb;
|
class wxDb *pDb;
|
||||||
}; // wxTablesInUse
|
}; // wxTablesInUse
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -502,14 +503,14 @@ class wxTablesInUse : public wxObject
|
|||||||
// The following routines allow a user to get new database connections, free them
|
// The following routines allow a user to get new database connections, free them
|
||||||
// for other code segments to use, or close all of them when the application has
|
// for other code segments to use, or close all of them when the application has
|
||||||
// completed.
|
// completed.
|
||||||
wxDB WXDLLEXPORT *wxDbGetConnection(wxDbConnectInf *pDbConfig, bool FwdOnlyCursors=(bool)wxODBC_FWD_ONLY_CURSORS);
|
wxDb WXDLLEXPORT *wxDbGetConnection(wxDbConnectInf *pDbConfig, bool FwdOnlyCursors=(bool)wxODBC_FWD_ONLY_CURSORS);
|
||||||
bool WXDLLEXPORT wxDbFreeConnection(wxDB *pDb);
|
bool WXDLLEXPORT wxDbFreeConnection(wxDb *pDb);
|
||||||
void WXDLLEXPORT wxDbCloseConnections(void);
|
void WXDLLEXPORT wxDbCloseConnections(void);
|
||||||
int WXDLLEXPORT wxDbConnectionsInUse(void);
|
int WXDLLEXPORT wxDbConnectionsInUse(void);
|
||||||
|
|
||||||
|
|
||||||
// This function sets the sql log state for all open wxDB objects
|
// This function sets the sql log state for all open wxDb objects
|
||||||
bool wxDbSqlLog(wxSqlLogState state, const char *filename = SQL_LOG_FILENAME);
|
bool wxDbSqlLog(wxDbSqlLogState state, const wxChar *filename = SQL_LOG_FILENAME);
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@@ -533,16 +534,22 @@ bool WXDLLEXPORT wxDbGetDataSource(HENV henv, char *Dsn, SWORD DsnMax, char *DsD
|
|||||||
//#################################################################################
|
//#################################################################################
|
||||||
|
|
||||||
// Backward compability structures/classes. This will eventually go away
|
// Backward compability structures/classes. This will eventually go away
|
||||||
typedef wxColInf CcolInf;
|
typedef wxDb wxDB;
|
||||||
typedef wxSqlTypeInfo SqlTypeInfo;
|
typedef wxDbTableInf wxTableInf;
|
||||||
typedef enum wxSqlLogState sqlLog;
|
typedef wxDbColInf wxColInf;
|
||||||
typedef enum wxDBMS dbms;
|
typedef wxDbColInf CcolInf;
|
||||||
typedef enum wxDBMS DBMS;
|
typedef wxDbColFor wxColFor;
|
||||||
typedef wxODBC_ERRORS ODBC_ERRORS;
|
typedef wxDbSqlTypeInfo SqlTypeInfo;
|
||||||
typedef wxDbConnectInf DbStuff;
|
typedef wxDbSqlTypeInfo wxSqlTypeInfo;
|
||||||
typedef wxDbList DbList;
|
typedef enum wxDbSqlLogState sqlLog;
|
||||||
|
typedef enum wxDbSqlLogState wxSqlLogState;
|
||||||
|
typedef enum wxDBMS dbms;
|
||||||
|
typedef enum wxDBMS DBMS;
|
||||||
|
typedef wxODBC_ERRORS ODBC_ERRORS;
|
||||||
|
typedef wxDbConnectInf DbStuff;
|
||||||
|
typedef wxDbList DbList;
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
typedef wxTablesInUse CstructTablesInUse;
|
typedef wxTablesInUse CstructTablesInUse;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Deprecated function names that are replaced by the function names listed above
|
// Deprecated function names that are replaced by the function names listed above
|
||||||
@@ -551,7 +558,7 @@ bool WXDLLEXPORT FreeDbConnection(wxDB *pDb);
|
|||||||
void WXDLLEXPORT CloseDbConnections(void);
|
void WXDLLEXPORT CloseDbConnections(void);
|
||||||
int WXDLLEXPORT NumberDbConnectionsInUse(void);
|
int WXDLLEXPORT NumberDbConnectionsInUse(void);
|
||||||
|
|
||||||
bool SqlLog(sqlLog state, const char *filename = SQL_LOG_FILENAME);
|
bool SqlLog(sqlLog state, const wxChar *filename = SQL_LOG_FILENAME);
|
||||||
|
|
||||||
bool WXDLLEXPORT GetDataSource(HENV henv, char *Dsn, SWORD DsnMax, char *DsDesc, SWORD DsDescMax,
|
bool WXDLLEXPORT GetDataSource(HENV henv, char *Dsn, SWORD DsnMax, char *DsDesc, SWORD DsDescMax,
|
||||||
UWORD direction = SQL_FETCH_NEXT);
|
UWORD direction = SQL_FETCH_NEXT);
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: dbtable.h
|
// Name: dbtable.h
|
||||||
// Purpose: Declaration of the wxTable class.
|
// Purpose: Declaration of the wxDbTable class.
|
||||||
// Author: Doug Card
|
// Author: Doug Card
|
||||||
// Modified by: George Tasker
|
// Modified by: George Tasker
|
||||||
// Created: 9.96
|
// Created: 9.96
|
||||||
@@ -49,14 +49,14 @@ const bool QUERY_ONLY = TRUE;
|
|||||||
const bool DISABLE_VIEW = TRUE;
|
const bool DISABLE_VIEW = TRUE;
|
||||||
|
|
||||||
// The following class is used to define a column of a table.
|
// The following class is used to define a column of a table.
|
||||||
// The wxTable constructor will dynamically allocate as many of
|
// The wxDbTable constructor will dynamically allocate as many of
|
||||||
// these as there are columns in the table. The class derived
|
// these as there are columns in the table. The class derived
|
||||||
// from wxTable must initialize these column definitions in it's
|
// from wxDbTable must initialize these column definitions in it's
|
||||||
// constructor. These column definitions provide inf. to the
|
// constructor. These column definitions provide inf. to the
|
||||||
// wxTable class which allows it to create a table in the data
|
// wxDbTable class which allows it to create a table in the data
|
||||||
// source, exchange data between the data source and the C++
|
// source, exchange data between the data source and the C++
|
||||||
// object, and so on.
|
// object, and so on.
|
||||||
class WXDLLEXPORT wxColDef
|
class WXDLLEXPORT wxDbColDef
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
char ColName[DB_MAX_COLUMN_NAME_LEN+1]; // Column Name
|
char ColName[DB_MAX_COLUMN_NAME_LEN+1]; // Column Name
|
||||||
@@ -70,28 +70,28 @@ public:
|
|||||||
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!!!
|
||||||
bool Null; // NOT FULLY IMPLEMENTED - Allows NULL values in Inserts and Updates
|
bool Null; // NOT FULLY IMPLEMENTED - Allows NULL values in Inserts and Updates
|
||||||
}; // wxColDef
|
}; // wxDbColDef
|
||||||
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxColDataPtr
|
class WXDLLEXPORT wxDbColDataPtr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void *PtrDataObj;
|
void *PtrDataObj;
|
||||||
int SzDataObj;
|
int SzDataObj;
|
||||||
int SqlCtype;
|
int SqlCtype;
|
||||||
}; // wxColDataPtr
|
}; // wxDbColDataPtr
|
||||||
|
|
||||||
|
|
||||||
// This structure is used when creating secondary indexes.
|
// This structure is used when creating secondary indexes.
|
||||||
class WXDLLEXPORT wxIdxDef
|
class WXDLLEXPORT wxDbIdxDef
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
char ColName[DB_MAX_COLUMN_NAME_LEN+1];
|
char ColName[DB_MAX_COLUMN_NAME_LEN+1];
|
||||||
bool Ascending;
|
bool Ascending;
|
||||||
}; // wxIdxDef
|
}; // wxDbIdxDef
|
||||||
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxTable
|
class WXDLLEXPORT wxDbTable
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
ULONG tableID; // Used for debugging. This can help to match up mismatched constructors/destructors
|
ULONG tableID; // Used for debugging. This can help to match up mismatched constructors/destructors
|
||||||
@@ -110,7 +110,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// Pointer to the database object this table belongs to
|
// Pointer to the database object this table belongs to
|
||||||
wxDB *pDb;
|
wxDb *pDb;
|
||||||
|
|
||||||
// ODBC Handles
|
// ODBC Handles
|
||||||
HENV henv; // ODBC Environment handle
|
HENV henv; // ODBC Environment handle
|
||||||
@@ -132,24 +132,24 @@ public:
|
|||||||
char tablePath[DB_PATH_MAX]; // needed for dBase tables
|
char tablePath[DB_PATH_MAX]; // needed for dBase tables
|
||||||
|
|
||||||
// Column Definitions
|
// Column Definitions
|
||||||
wxColDef *colDefs; // Array of wxColDef structures
|
wxDbColDef *colDefs; // Array of wxDbColDef structures
|
||||||
|
|
||||||
// Where, Order By and From 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 wxTable::Query(). Format: ",tbl,tbl..."
|
char *from; // Allows for joins in a wxDbTable::Query(). Format: ",tbl,tbl..."
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
bool selectForUpdate;
|
bool selectForUpdate;
|
||||||
|
|
||||||
// Public member functions
|
// Public member functions
|
||||||
wxTable(wxDB *pwxDB, const char *tblName, const int nCols,
|
wxDbTable(wxDb *pwxDb, const char *tblName, const int nCols,
|
||||||
const char *qryTblName = 0, bool qryOnly = !QUERY_ONLY, const char *tblPath=NULL);
|
const char *qryTblName = 0, bool qryOnly = !QUERY_ONLY, const char *tblPath=NULL);
|
||||||
virtual ~wxTable();
|
virtual ~wxDbTable();
|
||||||
bool Open(void);
|
bool Open(void);
|
||||||
bool CreateTable(bool attemptDrop=TRUE);
|
bool CreateTable(bool attemptDrop=TRUE);
|
||||||
bool DropTable(void);
|
bool DropTable(void);
|
||||||
bool CreateIndex(const char * idxName, bool unique, int noIdxCols, wxIdxDef *pIdxDefs, bool attemptDrop=TRUE);
|
bool CreateIndex(const char * idxName, bool unique, int noIdxCols, wxDbIdxDef *pIdxDefs, bool attemptDrop=TRUE);
|
||||||
bool DropIndex(const char * idxName);
|
bool DropIndex(const char * idxName);
|
||||||
bool CloseCursor(HSTMT cursor);
|
bool CloseCursor(HSTMT cursor);
|
||||||
int Insert(void);
|
int Insert(void);
|
||||||
@@ -166,7 +166,7 @@ public:
|
|||||||
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)); }
|
||||||
|
|
||||||
/***** These four functions only work with wxDB instances that are defined *****
|
/***** These four functions only work with wxDb instances that are defined *****
|
||||||
***** as not being FwdOnlyCursors *****/
|
***** as not being FwdOnlyCursors *****/
|
||||||
bool GetPrev(void);
|
bool GetPrev(void);
|
||||||
bool operator--(int);
|
bool operator--(int);
|
||||||
@@ -187,7 +187,7 @@ public:
|
|||||||
void SetColDefs (int index, const char *fieldName, int dataType, void *pData, int cType,
|
void SetColDefs (int index, const 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);
|
||||||
wxColDataPtr* SetColDefs (wxColInf *colInfs, ULONG numCols);
|
wxDbColDataPtr* SetColDefs (wxDbColInf *colInfs, ULONG numCols);
|
||||||
|
|
||||||
HSTMT *NewCursor(bool setCursor = FALSE, bool bindColumns = TRUE);
|
HSTMT *NewCursor(bool setCursor = FALSE, bool bindColumns = TRUE);
|
||||||
bool DeleteCursor(HSTMT *hstmtDel);
|
bool DeleteCursor(HSTMT *hstmtDel);
|
||||||
@@ -203,7 +203,7 @@ public:
|
|||||||
ULONG GetTableID() { return tableID; };
|
ULONG GetTableID() { return tableID; };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}; // wxTable
|
}; // wxDbTable
|
||||||
|
|
||||||
|
|
||||||
// Change this to 0 to remove use of all deprecated functions
|
// Change this to 0 to remove use of all deprecated functions
|
||||||
@@ -213,9 +213,13 @@ public:
|
|||||||
//#################################################################################
|
//#################################################################################
|
||||||
|
|
||||||
// Backward compability. These will eventually go away
|
// Backward compability. These will eventually go away
|
||||||
typedef wxColDef CcolDef;
|
typedef wxDbTable wxTable;
|
||||||
typedef wxColDataPtr CcolDataPtr;
|
typedef wxDbIdxDef wxIdxDef;
|
||||||
typedef wxIdxDef CidxDef;
|
typedef wxDbIdxDef CidxDef;
|
||||||
|
typedef wxDbColDef wxColDef;
|
||||||
|
typedef wxDbColDef CcolDef;
|
||||||
|
typedef wxDbColDataPtr wxColDataPtr;
|
||||||
|
typedef wxDbColDataPtr CcolDataPtr;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user