All variables/parameters having to do with number of columns changed to be of type UWORD rather than int, avoiding compiler warnings and giant tables causing problems, and matching the types with the ODBC APIs
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9718
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
struct WXDLLEXPORT wxDbSqlTypeInfo
{
wxString TypeName;
struct WXDLLEXPORT wxDbSqlTypeInfo
{
wxString TypeName;
long Precision;
short CaseSensitive;
// short MinimumScale;
long Precision;
short CaseSensitive;
// short MinimumScale;
wxChar tableName[DB_MAX_TABLE_NAME_LEN+1];
wxChar tableType[254+1]; // "TABLE" or "SYSTEM TABLE" etc.
wxChar tableRemarks[254+1];
wxChar tableName[DB_MAX_TABLE_NAME_LEN+1];
wxChar tableType[254+1]; // "TABLE" or "SYSTEM TABLE" etc.
wxChar tableRemarks[254+1];
- int numCols; // How many Columns does this Table have: GetColumnCount(..);
+ UWORD numCols; // How many Columns does this Table have: GetColumnCount(..);
wxDbColInf *pColInf; // pColInf = NULL ; User can later call GetColumns(..);
wxDbTableInf();
wxDbColInf *pColInf; // pColInf = NULL ; User can later call GetColumns(..);
wxDbTableInf();
int TranslateSqlState(const wxString &SQLState);
wxDbInf *GetCatalog(const wxChar *userID=NULL);
bool Catalog(const wxChar *userID=NULL, const wxString &fileName=SQL_CATALOG_FILENAME);
int TranslateSqlState(const wxString &SQLState);
wxDbInf *GetCatalog(const wxChar *userID=NULL);
bool Catalog(const wxChar *userID=NULL, const wxString &fileName=SQL_CATALOG_FILENAME);
- int GetKeyFields(const wxString &tableName, wxDbColInf* colInf, int nocols);
+ int GetKeyFields(const wxString &tableName, wxDbColInf* colInf, UWORD noCols);
wxDbColInf *GetColumns(wxChar *tableName[], const wxChar *userID=NULL);
wxDbColInf *GetColumns(wxChar *tableName[], const wxChar *userID=NULL);
- wxDbColInf *GetColumns(const wxString &tableName, int *numCols, const wxChar *userID=NULL);
+ wxDbColInf *GetColumns(const wxString &tableName, UWORD *numCols, const wxChar *userID=NULL);
- int GetColumnCount(const wxString &tableName, const wxChar *userID=NULL);
+ UWORD GetColumnCount(const wxString &tableName, const wxChar *userID=NULL);
const wxChar *GetDatabaseName(void) {return dbInf.dbmsName;}
const wxString &GetDataSource(void) {return dsn;}
const wxString &GetDatasourceName(void){return dsn;}
const wxChar *GetDatabaseName(void) {return dbInf.dbmsName;}
const wxString &GetDataSource(void) {return dsn;}
const wxString &GetDatasourceName(void){return dsn;}
public:
wxChar ColName[DB_MAX_COLUMN_NAME_LEN+1]; // Column Name
int DbDataType; // Logical Data Type; e.g. DB_DATA_TYPE_INTEGER
public:
wxChar ColName[DB_MAX_COLUMN_NAME_LEN+1]; // Column Name
int DbDataType; // Logical Data Type; e.g. DB_DATA_TYPE_INTEGER
- int SqlCtype; // C data type; e.g. SQL_C_LONG
+ SWORD SqlCtype; // C data type; e.g. SQL_C_LONG
void *PtrDataObj; // Address 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.
void *PtrDataObj; // Address 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.
public:
void *PtrDataObj;
int SzDataObj;
public:
void *PtrDataObj;
int SzDataObj;
bool insertable;
// Private member functions
bool insertable;
// Private member functions
- bool initialize(wxDb *pwxDb, const wxString &tblName, const int nCols,
+ bool initialize(wxDb *pwxDb, const wxString &tblName, const UWORD numColumns,
const wxString &qryTblName, bool qryOnly, const wxString &tblPath);
void cleanup();
const wxString &qryTblName, bool qryOnly, const wxString &tblPath);
void cleanup();
wxString tablePath; // needed for dBase tables
wxString tableName; // Table name
wxString queryTableName; // Query Table Name
wxString tablePath; // needed for dBase tables
wxString tableName; // Table name
wxString queryTableName; // Query Table Name
- int noCols; // # of columns in the table
+ UWORD noCols; // # of columns in the table
bool queryOnly; // Query Only, no inserts, updates or deletes
// Column Definitions
bool queryOnly; // Query Only, no inserts, updates or deletes
// Column Definitions
char tablePath[wxDB_PATH_MAX]; // needed for dBase tables
char tableName[DB_MAX_TABLE_NAME_LEN+1]; // Table name
char queryTableName[DB_MAX_TABLE_NAME_LEN+1]; // Query Table Name
char tablePath[wxDB_PATH_MAX]; // needed for dBase tables
char tableName[DB_MAX_TABLE_NAME_LEN+1]; // Table name
char queryTableName[DB_MAX_TABLE_NAME_LEN+1]; // Query Table Name
- int noCols; // # of columns in the table
+ UWORD noCols; // # of columns in the table
bool queryOnly; // Query Only, no inserts, updates or deletes
// Column Definitions
wxDbColDef *colDefs; // Array of wxDbColDef structures
#endif
// Public member functions
bool queryOnly; // Query Only, no inserts, updates or deletes
// Column Definitions
wxDbColDef *colDefs; // Array of wxDbColDef structures
#endif
// Public member functions
- wxDbTable(wxDb *pwxDb, const wxString &tblName, const int nCols,
+ wxDbTable(wxDb *pwxDb, const wxString &tblName, const UWORD numColumns,
const wxString &qryTblName="", bool qryOnly = !wxDB_QUERY_ONLY,
const wxString &tblPath="");
// DEPRECATED
const wxString &qryTblName="", bool qryOnly = !wxDB_QUERY_ONLY,
const wxString &tblPath="");
// DEPRECATED
- wxDbTable(wxDb *pwxDb, const wxString &tblName, const int nCols,
+ wxDbTable(wxDb *pwxDb, const wxString &tblName, const UWORD numColumns,
const wxChar *qryTblName="", bool qryOnly = !wxDB_QUERY_ONLY,
const wxString &tblPath="");
const wxChar *qryTblName="", bool qryOnly = !wxDB_QUERY_ONLY,
const wxString &tblPath="");
const wxString &GetQueryTableName() { return queryTableName; }
const wxString &GetTablePath() { return tablePath; }
const wxString &GetQueryTableName() { return queryTableName; }
const wxString &GetTablePath() { return tablePath; }
- int GetNumberOfColumns() { return noCols; } // number of "defined" columns for this wxDbTable instance
+ UWORD GetNumberOfColumns() { return noCols; } // number of "defined" columns for this wxDbTable instance
const wxString &GetFromClause() { return from; }
const wxString &GetOrderByClause() { return orderBy; }
const wxString &GetFromClause() { return from; }
const wxString &GetOrderByClause() { return orderBy; }
wxDbColDef *GetColDefs() { return colDefs; }
void SetColDefs(int index, const wxString &fieldName, int dataType,
wxDbColDef *GetColDefs() { return colDefs; }
void SetColDefs(int index, const wxString &fieldName, int dataType,
- void *pData, int cType,
+ void *pData, SWORD cType,
int size, bool keyField = FALSE, bool upd = TRUE,
bool insAllow = TRUE, bool derivedCol = FALSE);
wxDbColDataPtr *SetColDefs(wxDbColInf *colInfs, ULONG numCols);
int size, bool keyField = FALSE, bool upd = TRUE,
bool insAllow = TRUE, bool derivedCol = FALSE);
wxDbColDataPtr *SetColDefs(wxDbColInf *colInfs, ULONG numCols);
/********** wxDb::GetKeyFields() **********/
/********** wxDb::GetKeyFields() **********/
-int wxDb::GetKeyFields(const wxString &tableName, wxDbColInf* colInf, int noCols)
+int wxDb::GetKeyFields(const wxString &tableName, wxDbColInf* colInf, UWORD noCols)
{
wxChar szPkTable[DB_MAX_TABLE_NAME_LEN+1]; /* Primary key table name */
wxChar szFkTable[DB_MAX_TABLE_NAME_LEN+1]; /* Foreign key table name */
{
wxChar szPkTable[DB_MAX_TABLE_NAME_LEN+1]; /* Primary key table name */
wxChar szFkTable[DB_MAX_TABLE_NAME_LEN+1]; /* Foreign key table name */
wxChar szFkCol[DB_MAX_COLUMN_NAME_LEN+1]; /* Foreign key column */
SQLRETURN retcode;
SDWORD cb;
wxChar szFkCol[DB_MAX_COLUMN_NAME_LEN+1]; /* Foreign key column */
SQLRETURN retcode;
SDWORD cb;
wxString tempStr;
/*
* -----------------------------------------------------------------------
wxString tempStr;
/*
* -----------------------------------------------------------------------
* to avoid undesired unbinding of columns.
*/
{
* to avoid undesired unbinding of columns.
*/
{
- int noCols = 0;
- int colNo = 0;
+ UWORD noCols = 0;
+ int colNo = 0;
wxDbColInf *colInf = 0;
RETCODE retcode;
wxDbColInf *colInf = 0;
RETCODE retcode;
/********** wxDb::GetColumns() **********/
/********** wxDb::GetColumns() **********/
-wxDbColInf *wxDb::GetColumns(const wxString &tableName, int *numCols, const wxChar *userID)
+wxDbColInf *wxDb::GetColumns(const wxString &tableName, UWORD *numCols, const wxChar *userID)
//
// Same as the above GetColumns() function except this one gets columns
// only for a single table, and if 'numCols' is not NULL, the number of
//
// Same as the above GetColumns() function except this one gets columns
// only for a single table, and if 'numCols' is not NULL, the number of
// to avoid undesired unbinding of columns.
{
// to avoid undesired unbinding of columns.
{
- int noCols = 0;
- int colNo = 0;
+ UWORD noCols = 0;
+ int colNo = 0;
wxDbColInf *colInf = 0;
RETCODE retcode;
wxDbColInf *colInf = 0;
RETCODE retcode;
wxDbColInf *colInf;
} _TableColumns;
wxDbColInf *colInf;
} _TableColumns;
// The last array element of the tableName[] argument must be zero (null).
// This is how the end of the array is detected.
// The last array element of the tableName[] argument must be zero (null).
// This is how the end of the array is detected.
// How many tables ?
int tbl;
// How many tables ?
int tbl;
// by this function. This function should use its own wxDb instance
// to avoid undesired unbinding of columns.
{
// by this function. This function should use its own wxDb instance
// to avoid undesired unbinding of columns.
{
int colNo = 0;
wxDbColInf *colInf = 0;
int colNo = 0;
wxDbColInf *colInf = 0;
/********** wxDb::GetColumnCount() **********/
/********** wxDb::GetColumnCount() **********/
-int wxDb::GetColumnCount(const wxString &tableName, const wxChar *userID)
+UWORD wxDb::GetColumnCount(const wxString &tableName, const wxChar *userID)
/*
* Returns a count of how many columns are in a table.
* If an error occurs in computing the number of columns
/*
* Returns a count of how many columns are in a table.
* If an error occurs in computing the number of columns
* to avoid undesired unbinding of columns.
*/
{
* to avoid undesired unbinding of columns.
*/
{
+ wxString UserID,Schema;
convertUserID(userID,UserID);
convertUserID(userID,UserID);
+ convertUserID(schema,Schema);
TableName = tableName;
// Oracle and Interbase table names are uppercase only, so force
TableName = tableName;
// Oracle and Interbase table names are uppercase only, so force
SQLFreeStmt(hstmt, SQL_CLOSE);
SQLFreeStmt(hstmt, SQL_CLOSE);
+ // Some databases cannot accept a user name when looking up table names,
+ // so we use the call below that leaves out the user name
+ if (!Schema.IsEmpty() &&
+ Dbms() != dbmsMY_SQL &&
+ Dbms() != dbmsACCESS &&
+ Dbms() != dbmsMS_SQL_SERVER)
{
retcode = SQLTablePrivileges(hstmt,
NULL, 0, // Catalog
{
retcode = SQLTablePrivileges(hstmt,
NULL, 0, // Catalog
+ (UCHAR FAR *)Schema.c_str(), SQL_NTS, // Schema
(UCHAR FAR *)TableName.c_str(), SQL_NTS);
}
else
{
retcode = SQLTablePrivileges(hstmt,
NULL, 0, // Catalog
(UCHAR FAR *)TableName.c_str(), SQL_NTS);
}
else
{
retcode = SQLTablePrivileges(hstmt,
NULL, 0, // Catalog
- (UCHAR FAR *)schema, SQL_NTS, // Schema
(UCHAR FAR *)TableName.c_str(), SQL_NTS);
}
(UCHAR FAR *)TableName.c_str(), SQL_NTS);
}