struct WXDLLEXPORT wxDbSqlTypeInfo
{
wxString TypeName;
- int FsqlType;
+ SWORD FsqlType;
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];
- 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();
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(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;}
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.
public:
void *PtrDataObj;
int SzDataObj;
- int SqlCtype;
+ SWORD SqlCtype;
}; // wxDbColDataPtr
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();
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
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
- 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
- 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 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; }
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);
/********** 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 szFkCol[DB_MAX_COLUMN_NAME_LEN+1]; /* Foreign key column */
SQLRETURN retcode;
SDWORD cb;
- int i;
+ SWORD i;
wxString tempStr;
/*
* -----------------------------------------------------------------------
* to avoid undesired unbinding of columns.
*/
{
- int noCols = 0;
- int colNo = 0;
+ UWORD noCols = 0;
+ int colNo = 0;
wxDbColInf *colInf = 0;
RETCODE retcode;
/********** 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
// to avoid undesired unbinding of columns.
{
- int noCols = 0;
- int colNo = 0;
+ UWORD noCols = 0;
+ int colNo = 0;
wxDbColInf *colInf = 0;
RETCODE retcode;
typedef struct
{
- int noCols;
+ UWORD noCols;
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.
- int noCols = 0;
+ UWORD noCols = 0;
// How many tables ?
int tbl;
// by this function. This function should use its own wxDb instance
// to avoid undesired unbinding of columns.
{
- SWORD noCols = 0;
+ UWORD noCols = 0;
int colNo = 0;
wxDbColInf *colInf = 0;
/********** 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
* to avoid undesired unbinding of columns.
*/
{
- int noCols = 0;
+ UWORD noCols = 0;
RETCODE retcode;
wxString TableName;
- wxString UserID;
+ wxString UserID,Schema;
convertUserID(userID,UserID);
+ convertUserID(schema,Schema);
TableName = tableName;
// Oracle and Interbase table names are uppercase only, so force
SQLFreeStmt(hstmt, SQL_CLOSE);
- if (!schema)
+ // 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
- NULL, 0, // Schema
+ (UCHAR FAR *)Schema.c_str(), SQL_NTS, // Schema
(UCHAR FAR *)TableName.c_str(), SQL_NTS);
}
else
{
retcode = SQLTablePrivileges(hstmt,
NULL, 0, // Catalog
- (UCHAR FAR *)schema, SQL_NTS, // Schema
+ NULL, 0, // Schema
(UCHAR FAR *)TableName.c_str(), SQL_NTS);
}