X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e115e77131d5a7a68d0cfb2fb41fcb98deefdd29..b662c13583d9fc10d7b912fb246b8f632339a279:/include/wx/db.h diff --git a/include/wx/db.h b/include/wx/db.h index 7ba5b74748..40f261cc85 100644 --- a/include/wx/db.h +++ b/include/wx/db.h @@ -4,7 +4,7 @@ // to an ODBC data source. The wxDB class allows operations on the data // source such as opening and closing the data source. // Author: Doug Card -// Modified by: +// Modified by: George Tasker // Mods: Dec, 1998: // -Added support for SQL statement logging and database cataloging // April, 1999 @@ -49,11 +49,6 @@ #endif #endif -#if defined(wx_msw) || defined(__WXMSW__) || defined(WIN32) -#include -#endif - -#ifdef _IODBC_ #if wxMAJOR_VERSION == 2 extern "C" { #include "../../src/iodbc/isql.h" @@ -65,26 +60,29 @@ #include "isqlext.h" } #endif + typedef float SFLOAT; typedef double SDOUBLE; typedef unsigned int UINT; #define ULONG UDWORD -#else // msw - #define ODBCVER 0x0250 - #include - #include -#endif - -#ifdef __UNIX__ +/* +#ifdef __UNIX__ # ifndef strnicmp # define strnicmp strncasecmp # endif # ifndef stricmp # define stricmp strcasecmp # endif +#elif defined(__WXMAC__) #else # include #endif +*/ + +#ifndef wxODBC_FWD_ONLY_CURSORS +#define wxODBC_FWD_ONLY_CURSORS 1 +#endif + enum enumDummy {enumDum1}; @@ -259,12 +257,63 @@ typedef struct short MaximumScale; } SqlTypeInfo; -class WXDLLEXPORT CcolInf +class WXDLLEXPORT wxColFor { + public: + wxString s_Field; // Formated String for Output + wxString s_Format[7]; // Formated Objekts - TIMESTAMP has the biggest (7) + wxString s_Menge[7]; // Formated Objekts - amount of things that can be formatted + int i_Menge[7]; // Formated Objekts - TT MM YYYY HH MM SS m + 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 + SWORD i_sqlDataType; + + wxColFor(); + ~wxColFor(); + int Format(int Nation, int dbDataType,SWORD sqlDataType,short columnSize,short decimalDigits); +}; + +class WXDLLEXPORT wxColInf +{ +public: + char catalog[128+1]; + char schema[128+1]; + char tableName[DB_MAX_TABLE_NAME_LEN+1]; + char colName[DB_MAX_COLUMN_NAME_LEN+1]; + SWORD sqlDataType; + char typeName[128+1]; + SWORD columnSize; + SWORD bufferLength; + short decimalDigits; + short numPrecRadix; + short nullable; + char remarks[254+1]; + int dbDataType; // conversion of the 'sqlDataType' to the generic data type used by these classes + // mj10777.19991224 : new + int PkCol; // Primary key column 0=No; 1= First Key, 2 = Second Key etc. + 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. + char FkTableName[DB_MAX_TABLE_NAME_LEN+1]; // Foreign key table name + wxColFor *pColFor; // How should this columns be formatted +}; + +class WXDLLEXPORT wxTableInf // Description of a Table +{ // mj10777 : used in wxDbInf and GetCatalog(..) public: - char tableName[DB_MAX_TABLE_NAME_LEN+1]; - char colName[DB_MAX_COLUMN_NAME_LEN+1]; - int sqlDataType; + char tableName[DB_MAX_TABLE_NAME_LEN+1]; + char tableType[254+1]; // "TABLE" or "SYSTEM TABLE" etc. + char tableRemarks[254+1]; + int numCols; // How many Columns does this Table have: GetColumnCount(..); + wxColInf *pColInf; // pColInf = NULL ; User can later call GetColumns(..); +}; + +class WXDLLEXPORT wxDbInf // Description of a Database +{ // mj10777 : used in GetCatalog(..) +public: + char catalog[128+1]; + char schema[128+1]; + int numTables; // How many tables does this database have + wxTableInf *pTableInf; // pTableInf = new wxTableInf[numTables]; }; enum sqlLog @@ -283,7 +332,8 @@ enum dbms dbmsMY_SQL, dbmsPOSTGRES, dbmsACCESS, - dbmsDBASE + dbmsDBASE, + dbmsINFORMIX }; typedef enum dbms DBMS; @@ -297,6 +347,11 @@ typedef enum dbms DBMS; // this variable. extern char DBerrorList[DB_MAX_ERROR_HISTORY][DB_MAX_ERROR_MSG_LEN]; +// Backward compability for Remstar classes. This +// will eventually go away, so the wxColXxxx classes +// should be used +typedef wxColInf CcolInf; + class WXDLLEXPORT wxDB { private: @@ -313,7 +368,9 @@ private: bool getDbInfo(void); bool getDataTypeInfo(SWORD fSqlType, SqlTypeInfo &structSQLTypeInfo); bool setConnectionOptions(void); - void logError(char *errMsg, char *SQLState); + void logError(const char *errMsg, const char *SQLState); + + bool fwdOnlyCursors; public: @@ -380,7 +437,7 @@ public: SqlTypeInfo typeInfVarchar, typeInfInteger, typeInfFloat, typeInfDate; // Public member functions - wxDB(HENV &aHenv); + wxDB(HENV &aHenv, bool FwdOnlyCursors=(bool)TRUE); bool Open(char *Dsn, char *Uid, char *AuthStr); // Data Source Name, User ID, Password void Close(void); bool CommitTrans(void); @@ -388,15 +445,19 @@ public: 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); void DispNextError(void); - bool CreateView(char *viewName, char *colList, char *pSqlStmt, bool attemptDrop=TRUE); - bool DropView(char *viewName); - bool ExecSql(char *pSqlStmt); + bool CreateView(const char *viewName, const char *colList, const char *pSqlStmt, bool attemptDrop=TRUE); + bool DropView(const char *viewName); + bool ExecSql(const char *pSqlStmt); bool GetNext(void); bool GetData(UWORD colNo, SWORD cType, PTR pData, SDWORD maxLen, SDWORD FAR *cbReturned); - bool Grant(int privileges, char *tableName, char *userList = "PUBLIC"); - int TranslateSqlState(char *SQLState); - bool Catalog(char *userID, char *fileName = "Catalog.txt"); - CcolInf *GetColumns(char *tableName[], char *userID=NULL); + bool Grant(int privileges, const char *tableName, const char *userList = "PUBLIC"); + int TranslateSqlState(const char *SQLState); + wxDbInf *GetCatalog(char *userID); + bool Catalog(const char *userID=NULL, const char *fileName = "Catalog.txt"); + int GetKeyFields(char *tableName, wxColInf* colInf,int nocols); + wxColInf *GetColumns(char *tableName[], const char *userID=NULL); + wxColInf *GetColumns(char *tableName, int *numCols, const char *userID=NULL); + int GetColumnCount(char *tableName, const char *userID=NULL); char *GetDatabaseName(void) {return dbInf.dbmsName;} char *GetDataSource(void) {return dsn;} char *GetUsername(void) {return uid;} @@ -405,11 +466,12 @@ public: HENV GetHENV(void) {return henv;} HDBC GetHDBC(void) {return hdbc;} HSTMT GetHSTMT(void) {return hstmt;} - bool TableExists(char *tableName, char *userID=NULL, char *path=NULL); // 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); + 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);} + bool SqlLog(enum sqlLog state, const char *filename = "sqllog.txt", bool append = FALSE); + bool WriteSqlLog(const char *logMsg); DBMS Dbms(void); + bool FwdOnlyCursors(void) {return fwdOnlyCursors;} }; // wxDB @@ -428,7 +490,7 @@ struct DbList }; -#if __WXDEBUG__ > 0 +#ifdef __WXDEBUG__ #include "wx/object.h" class CstructTablesInUse : public wxObject { @@ -443,13 +505,13 @@ class CstructTablesInUse : public wxObject // for other code segments to use, or close all of them when the application has // completed. -wxDB* WXDLLEXPORT GetDbConnection(DbStuff *pDbStuff); +wxDB WXDLLEXPORT *GetDbConnection(DbStuff *pDbStuff, bool FwdOnlyCursors=(bool)wxODBC_FWD_ONLY_CURSORS); bool WXDLLEXPORT FreeDbConnection(wxDB *pDb); void WXDLLEXPORT CloseDbConnections(void); int WXDLLEXPORT NumberDbConnectionsInUse(void); // This function sets the sql log state for all open wxDB objects -bool SqlLog(enum sqlLog state, char *filename = "sqllog.txt"); +bool SqlLog(enum sqlLog state, const char *filename = "sqllog.txt"); // This routine allows you to query a driver manager // for a list of available datasources. Call this routine