Removed tabs and cleaned up indentations.
Added SQL_LOG_FILENAME and SQL_CATALOG_FILENAME constants to remove embedded text filenames git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5754 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -63,29 +63,15 @@
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef float SFLOAT;
|
typedef float SFLOAT;
|
||||||
typedef double SDOUBLE;
|
typedef double SDOUBLE;
|
||||||
typedef unsigned int UINT;
|
typedef unsigned int UINT;
|
||||||
#define ULONG UDWORD
|
#define ULONG UDWORD
|
||||||
/*
|
|
||||||
#ifdef __UNIX__
|
|
||||||
# ifndef strnicmp
|
|
||||||
# define strnicmp strncasecmp
|
|
||||||
# endif
|
|
||||||
# ifndef stricmp
|
|
||||||
# define stricmp strcasecmp
|
|
||||||
# endif
|
|
||||||
#elif defined(__WXMAC__)
|
|
||||||
#else
|
|
||||||
# include <io.h>
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef wxODBC_FWD_ONLY_CURSORS
|
#ifndef wxODBC_FWD_ONLY_CURSORS
|
||||||
#define wxODBC_FWD_ONLY_CURSORS 1
|
#define wxODBC_FWD_ONLY_CURSORS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
enum enumDummy {enumDum1};
|
enum enumDummy {enumDum1};
|
||||||
|
|
||||||
#define SQL_C_BOOLEAN(datatype) (sizeof(datatype) == 1 ? SQL_C_UTINYINT : (sizeof(datatype) == 2 ? SQL_C_USHORT : SQL_C_ULONG))
|
#define SQL_C_BOOLEAN(datatype) (sizeof(datatype) == 1 ? SQL_C_UTINYINT : (sizeof(datatype) == 2 ? SQL_C_USHORT : SQL_C_ULONG))
|
||||||
@@ -103,6 +89,9 @@ enum enumDummy {enumDum1};
|
|||||||
|
|
||||||
const int DB_PATH_MAX = 254;
|
const int DB_PATH_MAX = 254;
|
||||||
|
|
||||||
|
char * const SQL_LOG_FILENAME = "sqllog.txt";
|
||||||
|
char * const SQL_CATALOG_FILENAME = "catalog.txt";
|
||||||
|
|
||||||
// Database Globals
|
// Database Globals
|
||||||
const int DB_TYPE_NAME_LEN = 40;
|
const int DB_TYPE_NAME_LEN = 40;
|
||||||
const int DB_MAX_STATEMENT_LEN = 2048;
|
const int DB_MAX_STATEMENT_LEN = 2048;
|
||||||
@@ -235,6 +224,7 @@ enum ODBC_ERRORS
|
|||||||
DB_ERR_TIMEOUT_EXPIRED // SqlState = 'S1T00'
|
DB_ERR_TIMEOUT_EXPIRED // SqlState = 'S1T00'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct DbStuff
|
struct DbStuff
|
||||||
{
|
{
|
||||||
HENV Henv;
|
HENV Henv;
|
||||||
@@ -249,6 +239,7 @@ struct DbStuff
|
|||||||
char defaultDir[DB_PATH_MAX]; // Directory that db file resides in
|
char defaultDir[DB_PATH_MAX]; // Directory that db file resides in
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char TypeName[DB_TYPE_NAME_LEN];
|
char TypeName[DB_TYPE_NAME_LEN];
|
||||||
@@ -259,22 +250,25 @@ typedef struct
|
|||||||
short MaximumScale;
|
short MaximumScale;
|
||||||
} SqlTypeInfo;
|
} SqlTypeInfo;
|
||||||
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxColFor
|
class WXDLLEXPORT wxColFor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxString s_Field; // Formated String for Output
|
wxString s_Field; // Formated String for Output
|
||||||
wxString s_Format[7]; // Formated Objekts - TIMESTAMP has the biggest (7)
|
wxString s_Format[7]; // Formated Objects - TIMESTAMP has the biggest (7)
|
||||||
wxString s_Menge[7]; // Formated Objekts - amount of things that can be formatted
|
wxString s_Menge[7]; // Formated Objects - amount of things that can be formatted
|
||||||
int i_Menge[7]; // Formated Objekts - TT MM YYYY HH MM SS m
|
int i_Menge[7]; // Formated Objects - TT MM YYYY HH MM SS m
|
||||||
int i_Nation; // 0 = timestamp , 1=EU, 2=UK, 3=International, 4=US
|
int i_Nation; // 0 = timestamp , 1=EU, 2=UK, 3=International, 4=US
|
||||||
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();
|
wxColFor();
|
||||||
~wxColFor();
|
~wxColFor();
|
||||||
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 wxColInf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -299,8 +293,9 @@ public:
|
|||||||
wxColFor *pColFor; // How should this columns be formatted
|
wxColFor *pColFor; // How should this columns be formatted
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxTableInf // Description of a Table
|
class WXDLLEXPORT wxTableInf // Description of a Table
|
||||||
{ // mj10777 : used in wxDbInf and GetCatalog(..)
|
{
|
||||||
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.
|
||||||
@@ -309,8 +304,9 @@ public:
|
|||||||
wxColInf *pColInf; // pColInf = NULL ; User can later call GetColumns(..);
|
wxColInf *pColInf; // pColInf = NULL ; User can later call GetColumns(..);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxDbInf // Description of a Database
|
class WXDLLEXPORT wxDbInf // Description of a Database
|
||||||
{ // mj10777 : used in GetCatalog(..)
|
{
|
||||||
public:
|
public:
|
||||||
char catalog[128+1];
|
char catalog[128+1];
|
||||||
char schema[128+1];
|
char schema[128+1];
|
||||||
@@ -318,12 +314,17 @@ public:
|
|||||||
wxTableInf *pTableInf; // pTableInf = new wxTableInf[numTables];
|
wxTableInf *pTableInf; // pTableInf = new wxTableInf[numTables];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum sqlLog
|
enum sqlLog
|
||||||
{
|
{
|
||||||
sqlLogOFF,
|
sqlLogOFF,
|
||||||
sqlLogON
|
sqlLogON
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// These are the databases currently tested and working with these classes
|
||||||
|
// See the comments in wxDB::Dbms() for exceptions/issues with
|
||||||
|
// each of these database engines
|
||||||
enum dbms
|
enum dbms
|
||||||
{
|
{
|
||||||
dbmsUNIDENTIFIED,
|
dbmsUNIDENTIFIED,
|
||||||
@@ -338,8 +339,10 @@ enum dbms
|
|||||||
dbmsINFORMIX
|
dbmsINFORMIX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef enum dbms DBMS;
|
typedef enum dbms DBMS;
|
||||||
|
|
||||||
|
|
||||||
// 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
|
||||||
@@ -349,11 +352,13 @@ typedef enum dbms DBMS;
|
|||||||
// 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];
|
||||||
|
|
||||||
|
|
||||||
// Backward compability for Remstar classes. This
|
// Backward compability for Remstar classes. This
|
||||||
// will eventually go away, so the wxColXxxx classes
|
// will eventually go away, so the wxColXxxx classes
|
||||||
// should be used
|
// should be used
|
||||||
typedef wxColInf CcolInf;
|
typedef wxColInf CcolInf;
|
||||||
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxDB
|
class WXDLLEXPORT wxDB
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -365,6 +370,7 @@ private:
|
|||||||
char *authStr; // Authorization string (password)
|
char *authStr; // Authorization string (password)
|
||||||
FILE *fpSqlLog; // Sql Log file pointer
|
FILE *fpSqlLog; // Sql Log file pointer
|
||||||
enum sqlLog sqlLogState; // On or Off
|
enum sqlLog sqlLogState; // On or Off
|
||||||
|
bool fwdOnlyCursors;
|
||||||
|
|
||||||
// Private member functions
|
// Private member functions
|
||||||
bool getDbInfo(void);
|
bool getDbInfo(void);
|
||||||
@@ -372,10 +378,7 @@ private:
|
|||||||
bool setConnectionOptions(void);
|
bool setConnectionOptions(void);
|
||||||
void logError(const char *errMsg, const char *SQLState);
|
void logError(const char *errMsg, const char *SQLState);
|
||||||
|
|
||||||
bool fwdOnlyCursors;
|
|
||||||
|
|
||||||
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.
|
||||||
struct
|
struct
|
||||||
@@ -455,7 +458,7 @@ public:
|
|||||||
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 char *SQLState);
|
||||||
wxDbInf *GetCatalog(char *userID);
|
wxDbInf *GetCatalog(char *userID);
|
||||||
bool Catalog(const char *userID=NULL, const char *fileName = "Catalog.txt");
|
bool Catalog(const char *userID=NULL, const char *fileName = SQL_CATALOG_FILENAME);
|
||||||
int GetKeyFields(char *tableName, wxColInf* colInf,int nocols);
|
int GetKeyFields(char *tableName, wxColInf* colInf,int nocols);
|
||||||
wxColInf *GetColumns(char *tableName[], const char *userID=NULL);
|
wxColInf *GetColumns(char *tableName[], const char *userID=NULL);
|
||||||
wxColInf *GetColumns(char *tableName, int *numCols, const char *userID=NULL);
|
wxColInf *GetColumns(char *tableName, int *numCols, const char *userID=NULL);
|
||||||
@@ -470,11 +473,10 @@ 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(enum sqlLog state, const char *filename = "sqllog.txt", bool append = FALSE);
|
bool SqlLog(enum sqlLog state, const char *filename = SQL_LOG_FILENAME, bool append = FALSE);
|
||||||
bool WriteSqlLog(const char *logMsg);
|
bool WriteSqlLog(const char *logMsg);
|
||||||
DBMS Dbms(void);
|
DBMS 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
|
||||||
@@ -512,8 +514,10 @@ bool WXDLLEXPORT FreeDbConnection(wxDB *pDb);
|
|||||||
void WXDLLEXPORT CloseDbConnections(void);
|
void WXDLLEXPORT CloseDbConnections(void);
|
||||||
int WXDLLEXPORT NumberDbConnectionsInUse(void);
|
int WXDLLEXPORT NumberDbConnectionsInUse(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 SqlLog(enum sqlLog state, const char *filename = "sqllog.txt");
|
bool SqlLog(enum sqlLog state, const char *filename = SQL_LOG_FILENAME);
|
||||||
|
|
||||||
|
|
||||||
// This routine allows you to query a driver manager
|
// This routine allows you to query a driver manager
|
||||||
// for a list of available datasources. Call this routine
|
// for a list of available datasources. Call this routine
|
||||||
|
@@ -72,6 +72,7 @@ public:
|
|||||||
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
|
}; // wxColDef
|
||||||
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxColDataPtr
|
class WXDLLEXPORT wxColDataPtr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -96,10 +97,10 @@ public:
|
|||||||
bool Ascending;
|
bool Ascending;
|
||||||
}; // CidxDef
|
}; // CidxDef
|
||||||
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxTable
|
class WXDLLEXPORT wxTable
|
||||||
{
|
{
|
||||||
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
|
||||||
|
|
||||||
// Private member variables
|
// Private member variables
|
||||||
@@ -115,7 +116,6 @@ private:
|
|||||||
bool query(int queryType, bool forUpdate, bool distinct, char *pSqlStmt = 0);
|
bool query(int queryType, bool forUpdate, bool distinct, char *pSqlStmt = 0);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Pointer to the database object this table belongs to
|
// Pointer to the database object this table belongs to
|
||||||
wxDB *pDb;
|
wxDB *pDb;
|
||||||
|
|
||||||
@@ -194,8 +194,6 @@ 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);
|
||||||
// BJO20000121 : new prototype
|
|
||||||
// bool SetColDefs (wxColInf *colInfs, ULONG numCols, wxColDataPtr *pColDataPtrs);
|
|
||||||
wxColDataPtr* SetColDefs (wxColInf *colInfs, ULONG numCols);
|
wxColDataPtr* SetColDefs (wxColInf *colInfs, ULONG numCols);
|
||||||
|
|
||||||
HSTMT *NewCursor(bool setCursor = FALSE, bool bindColumns = TRUE);
|
HSTMT *NewCursor(bool setCursor = FALSE, bool bindColumns = TRUE);
|
||||||
|
Reference in New Issue
Block a user