Reformatted source to normalize - no code changes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7946 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -138,6 +138,7 @@ typedef struct
|
||||
} wxDbTablePrivilegeInfo;
|
||||
#endif
|
||||
|
||||
|
||||
/********** wxDbColFor Constructor **********/
|
||||
wxDbColFor::wxDbColFor()
|
||||
{
|
||||
@@ -167,12 +168,13 @@ int wxDbColFor::Format(int Nation,int dbDataType,SWORD sqlDataType,short columnS
|
||||
// -- 19991224 : mj10777@gmx.net : Create
|
||||
// There is still a lot of work to do here, but it is a start
|
||||
// It handles all the basic data-types that I have run into up to now
|
||||
// The main work will have be with Dates and float Formatting (US 1,000.00 ; EU 1.000,00)
|
||||
// There are wxWindow plans for locale support and the new wxDateTime.
|
||||
// - if they define some constants (wxEUROPEAN) that can be gloably used,
|
||||
// The main work will have be with Dates and float Formatting
|
||||
// (US 1,000.00 ; EU 1.000,00)
|
||||
// There are wxWindow plans for locale support and the new wxDateTime. If
|
||||
// they define some constants (wxEUROPEAN) that can be gloably used,
|
||||
// they should be used here.
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// There should also be a Function to scan in a string to fill the variable
|
||||
// There should also be a function to scan in a string to fill the variable
|
||||
// ----------------------------------------------------------------------------------------
|
||||
wxString Temp0;
|
||||
i_Nation = Nation; // 0 = timestamp , 1=EU, 2=UK, 3=International, 4=US
|
||||
@@ -199,17 +201,17 @@ int wxDbColFor::Format(int Nation,int dbDataType,SWORD sqlDataType,short columnS
|
||||
switch(i_dbDataType) // -A-> Still a lot of proper formatting to do
|
||||
{
|
||||
case DB_DATA_TYPE_VARCHAR:
|
||||
s_Field = "%s"; //
|
||||
s_Field = "%s";
|
||||
break;
|
||||
case DB_DATA_TYPE_INTEGER:
|
||||
s_Field = "%d"; //
|
||||
s_Field = "%d";
|
||||
break;
|
||||
case DB_DATA_TYPE_FLOAT:
|
||||
if (decimalDigits == 0)
|
||||
decimalDigits = 2;
|
||||
Temp0 = "%";
|
||||
Temp0.Printf(wxT("%s%d.%d"),Temp0.c_str(),columnSize,decimalDigits);
|
||||
s_Field.Printf(wxT("%sf"),Temp0.c_str()); //
|
||||
s_Field.Printf(wxT("%sf"),Temp0.c_str());
|
||||
break;
|
||||
case DB_DATA_TYPE_DATE:
|
||||
if (i_Nation == 0) // timestamp YYYY-MM-DD HH:MM:SS.SSS (tested for SYBASE)
|
||||
@@ -234,7 +236,7 @@ int wxDbColFor::Format(int Nation,int dbDataType,SWORD sqlDataType,short columnS
|
||||
}
|
||||
break;
|
||||
default:
|
||||
s_Field.Printf(wxT("-E-> unknown Format(%d)-sql(%d)"),dbDataType,sqlDataType); //
|
||||
s_Field.Printf(wxT("Unknown Format(%d)-SQL(%d)"),dbDataType,sqlDataType); //
|
||||
break;
|
||||
};
|
||||
return TRUE;
|
||||
@@ -872,7 +874,10 @@ bool wxDb::getDataTypeInfo(SWORD fSqlType, wxDbSqlTypeInfo &structSQLTypeInfo)
|
||||
// BJO 20000427 : OpenLink driver
|
||||
if (!wxStrncmp(dbInf.driverName, "oplodbc", 7) ||
|
||||
!wxStrncmp(dbInf.driverName, "OLOD", 4))
|
||||
if (!wxStrcmp(structSQLTypeInfo.TypeName, "double precision")) wxStrcpy(structSQLTypeInfo.TypeName, "real");
|
||||
{
|
||||
if (!wxStrcmp(structSQLTypeInfo.TypeName, "double precision"))
|
||||
wxStrcpy(structSQLTypeInfo.TypeName, "real");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (SQLGetData(hstmt, 3, SQL_C_LONG, (UCHAR*) &structSQLTypeInfo.Precision, 0, &cbRet) != SQL_SUCCESS)
|
||||
@@ -1025,7 +1030,6 @@ bool wxDb::GetNextError(HENV aHenv, HDBC aHdbc, HSTMT aHstmt)
|
||||
/********** wxDb::DispNextError() **********/
|
||||
void wxDb::DispNextError(void)
|
||||
{
|
||||
// char odbcErrMsg[DB_MAX_ERROR_MSG_LEN];
|
||||
wxString odbcErrMsg;
|
||||
|
||||
odbcErrMsg.sprintf("SQL State = %s\nNative Error Code = %li\nError Message = %s\n", sqlState, nativeError, errorMsg);
|
||||
@@ -1045,7 +1049,6 @@ void wxDb::DispNextError(void)
|
||||
wxLogDebug(odbcErrMsg,wxT("ODBC DEBUG MESSAGE"));
|
||||
#endif // __WXDEBUG__
|
||||
|
||||
|
||||
} // wxDb::DispNextError()
|
||||
|
||||
|
||||
@@ -1268,7 +1271,6 @@ int wxDb::TranslateSqlState(const wxChar *SQLState)
|
||||
/********** wxDb::Grant() **********/
|
||||
bool wxDb::Grant(int privileges, const char *tableName, const char *userList)
|
||||
{
|
||||
// char sqlStmt[DB_MAX_STATEMENT_LEN];
|
||||
wxString sqlStmt;
|
||||
|
||||
// Build the grant statement
|
||||
@@ -1322,7 +1324,6 @@ bool wxDb::Grant(int privileges, const char *tableName, const char *userList)
|
||||
/********** wxDb::CreateView() **********/
|
||||
bool wxDb::CreateView(const char *viewName, const char *colList, const char *pSqlStmt, bool attemptDrop)
|
||||
{
|
||||
// char sqlStmt[DB_MAX_STATEMENT_LEN];
|
||||
wxString sqlStmt;
|
||||
|
||||
// Drop the view first
|
||||
@@ -1495,8 +1496,8 @@ int wxDb::GetKeyFields(char *tableName, wxDbColInf* colInf, int noCols)
|
||||
for (i=0;i<noCols;i++) // Find the Column name
|
||||
if (!wxStrcmp(colInf[i].colName,szPkCol)) // We have found the Column
|
||||
colInf[i].PkCol = iKeySeq; // Which Primary Key is this (first, second usw.) ?
|
||||
} // if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
|
||||
} // while ((retcode == SQL_SUCCESS) || (retcode == SQL_SUCCESS_WITH_INFO))
|
||||
} // if
|
||||
} // while
|
||||
SQLFreeStmt(hstmt, SQL_CLOSE); /* Close the cursor (the hstmt is still allocated). */
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
@@ -1527,15 +1528,17 @@ int wxDb::GetKeyFields(char *tableName, wxDbColInf* colInf, int noCols)
|
||||
GetData( 7, SQL_C_CHAR, szFkTable, DB_MAX_TABLE_NAME_LEN+1, &cb);
|
||||
GetData( 8, SQL_C_CHAR, szFkCol, DB_MAX_COLUMN_NAME_LEN+1, &cb);
|
||||
Temp0.Printf(wxT("%s[%s] "),Temp0.c_str(),szFkTable); // [ ] in case there is a blank in the Table name
|
||||
} // if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
|
||||
} // while ((retcode == SQL_SUCCESS) || (retcode == SQL_SUCCESS_WITH_INFO))
|
||||
} // if
|
||||
} // while
|
||||
Temp0.Trim(); // Get rid of any unneeded blanks
|
||||
if (Temp0 != wxT(""))
|
||||
{
|
||||
for (i=0;i<noCols;i++) // Find the Column name
|
||||
for (i=0;i<noCols;i++)
|
||||
{ // Find the Column name
|
||||
if (!wxStrcmp(colInf[i].colName,szPkCol)) // We have found the Column, store the Information
|
||||
wxStrcpy(colInf[i].PkTableName,Temp0.c_str()); // Name of the Tables where this Primary Key is used as a Foreign Key
|
||||
} // if (Temp0 != "")
|
||||
}
|
||||
} // if
|
||||
SQLFreeStmt(hstmt, SQL_CLOSE); /* Close the cursor (the hstmt is still allocated). */
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
@@ -1570,14 +1573,14 @@ int wxDb::GetKeyFields(char *tableName, wxDbColInf* colInf, int noCols)
|
||||
{
|
||||
colInf[i].FkCol = iKeySeq; // Which Foreign Key is this (first, second usw.) ?
|
||||
wxStrcpy(colInf[i].FkTableName,szPkTable); // Name of the Table where this Foriegn is the Primary Key
|
||||
} // if (!wxStrcmp(colInf[i].colName,szFkCol))
|
||||
} // for (i=0;i<noCols;i++)
|
||||
} // if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
|
||||
} // while ((retcode == SQL_SUCCESS) || (retcode == SQL_SUCCESS_WITH_INFO))
|
||||
} // if
|
||||
} // for
|
||||
} // if
|
||||
} // while
|
||||
SQLFreeStmt(hstmt, SQL_CLOSE); /* Close the cursor (the hstmt is still allocated). */
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
return TRUE;
|
||||
|
||||
} // wxDb::GetKeyFields()
|
||||
|
||||
|
||||
@@ -1950,23 +1953,26 @@ wxDbColInf *wxDb::GetColumns(char *tableName, int *numCols, const char *userID)
|
||||
|
||||
} // wxDb::GetColumns()
|
||||
|
||||
|
||||
#else // New GetColumns
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
BJO 20000503
|
||||
These are tentative new GetColumns members which should be more database independant and
|
||||
which always returns the columns in the order they were created.
|
||||
|
||||
- The first one (wxDbColInf *wxDb::GetColumns(char *tableName[], const char* userID)) calls
|
||||
the second implementation for each separate table before merging the results. This makes the
|
||||
code easier to maintain as only one member (the second) makes the real work
|
||||
- wxDbColInf *wxDb::GetColumns(char *tableName, int *numCols, const char *userID) is a little bit improved
|
||||
- It doesn't anymore rely on the type-name to find out which database-type each column has
|
||||
- It ends by sorting the columns, so that they are returned in the same order they were created
|
||||
These are tentative new GetColumns members which should be more database
|
||||
independant and which always returns the columns in the order they were
|
||||
created.
|
||||
|
||||
- The first one (wxDbColInf *wxDb::GetColumns(char *tableName[], const
|
||||
char* userID)) calls the second implementation for each separate table
|
||||
before merging the results. This makes the code easier to maintain as
|
||||
only one member (the second) makes the real work
|
||||
- wxDbColInf *wxDb::GetColumns(char *tableName, int *numCols, const
|
||||
char *userID) is a little bit improved
|
||||
- It doesn't anymore rely on the type-name to find out which database-type
|
||||
each column has
|
||||
- It ends by sorting the columns, so that they are returned in the same
|
||||
order they were created
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
@@ -1975,6 +1981,7 @@ typedef struct
|
||||
wxDbColInf *colInf;
|
||||
} _TableColumns;
|
||||
|
||||
|
||||
wxDbColInf *wxDb::GetColumns(char *tableName[], const char* userID)
|
||||
{
|
||||
int i, j;
|
||||
@@ -1995,7 +2002,8 @@ wxDbColInf *wxDb::GetColumns(char *tableName[], const char* userID)
|
||||
|
||||
{
|
||||
TableColumns[i].colInf = GetColumns(tableName[i], &TableColumns[i].noCols, userID);
|
||||
if (TableColumns[i].colInf == NULL) return NULL;
|
||||
if (TableColumns[i].colInf == NULL)
|
||||
return NULL;
|
||||
noCols += TableColumns[i].noCols;
|
||||
}
|
||||
|
||||
@@ -2021,7 +2029,7 @@ wxDbColInf *wxDb::GetColumns(char *tableName[], const char* userID)
|
||||
delete [] TableColumns;
|
||||
|
||||
return colInf;
|
||||
}
|
||||
} // wxDb::GetColumns() -- NEW
|
||||
|
||||
|
||||
wxDbColInf *wxDb::GetColumns(char *tableName, int *numCols, const char *userID)
|
||||
@@ -2038,7 +2046,6 @@ wxDbColInf *wxDb::GetColumns(char *tableName, int *numCols, const char *userID)
|
||||
// NOTE: ALL column bindings associated with this wxDb instance are unbound
|
||||
// by this function. This function should use its own wxDb instance
|
||||
// to avoid undesired unbinding of columns.
|
||||
|
||||
{
|
||||
SWORD noCols = 0;
|
||||
int colNo = 0;
|
||||
@@ -2185,8 +2192,6 @@ wxDbColInf *wxDb::GetColumns(char *tableName, int *numCols, const char *userID)
|
||||
case SQL_DATE:
|
||||
colInf[colNo].dbDataType = DB_DATA_TYPE_DATE;
|
||||
break;
|
||||
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
default:
|
||||
wxString errMsg;
|
||||
@@ -2194,9 +2199,6 @@ wxDbColInf *wxDb::GetColumns(char *tableName, int *numCols, const char *userID)
|
||||
wxLogDebug(errMsg,wxT("ODBC DEBUG MESSAGE"));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
colNo++;
|
||||
}
|
||||
}
|
||||
@@ -2218,8 +2220,6 @@ wxDbColInf *wxDb::GetColumns(char *tableName, int *numCols, const char *userID)
|
||||
// Store Primary and Foreign Keys
|
||||
GetKeyFields(tableName,colInf,noCols);
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Now sort the the columns in order to make them appear in the right order
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -2288,9 +2288,6 @@ wxDbColInf *wxDb::GetColumns(char *tableName, int *numCols, const char *userID)
|
||||
// End sorting
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
if (numCols)
|
||||
*numCols = noCols;
|
||||
return colInf;
|
||||
@@ -2298,7 +2295,7 @@ wxDbColInf *wxDb::GetColumns(char *tableName, int *numCols, const char *userID)
|
||||
} // wxDb::GetColumns()
|
||||
|
||||
|
||||
#endif
|
||||
#endif // #else OLD_GETCOLUMNS
|
||||
|
||||
|
||||
/********** wxDb::GetColumnCount() **********/
|
||||
@@ -2430,7 +2427,6 @@ wxDbInf *wxDb::GetCatalog(char *userID)
|
||||
int pass;
|
||||
RETCODE retcode;
|
||||
SDWORD cb;
|
||||
// char tblNameSave[DB_MAX_TABLE_NAME_LEN+1];
|
||||
wxString tblNameSave;
|
||||
|
||||
wxString UserID;
|
||||
@@ -2467,7 +2463,6 @@ wxDbInf *wxDb::GetCatalog(char *userID)
|
||||
// - Create the Cols array = NULL
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
||||
for (pass = 1; pass <= 2; pass++)
|
||||
{
|
||||
SQLFreeStmt(hstmt, SQL_CLOSE); // Close if Open
|
||||
@@ -2477,7 +2472,6 @@ wxDbInf *wxDb::GetCatalog(char *userID)
|
||||
Dbms() != dbmsMY_SQL &&
|
||||
Dbms() != dbmsACCESS)
|
||||
{
|
||||
|
||||
retcode = SQLTables(hstmt,
|
||||
NULL, 0, // All qualifiers
|
||||
(UCHAR *) UserID.c_str(), SQL_NTS, // User specified
|
||||
@@ -2486,7 +2480,6 @@ wxDbInf *wxDb::GetCatalog(char *userID)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
retcode = SQLTables(hstmt,
|
||||
NULL, 0, // All qualifiers
|
||||
NULL, 0, // User specified
|
||||
@@ -2504,7 +2497,6 @@ wxDbInf *wxDb::GetCatalog(char *userID)
|
||||
|
||||
while ((retcode = SQLFetch(hstmt)) == SQL_SUCCESS) // Table Information
|
||||
{
|
||||
|
||||
if (pass == 1) // First pass, just count the Tables
|
||||
{
|
||||
if (pDbInf->numTables == 0)
|
||||
@@ -2535,9 +2527,9 @@ wxDbInf *wxDb::GetCatalog(char *userID)
|
||||
GetData( 5, SQL_C_CHAR, (UCHAR*) (pDbInf->pTableInf+noTab)->tableRemarks, 254+1, &cb);
|
||||
|
||||
noTab++;
|
||||
} // if (pass == 2) We now know the amount of Tables
|
||||
} // while ((retcode = SQLFetch(hstmt)) == SQL_SUCCESS)
|
||||
} // for (pass = 1; pass <= 2; pass++)
|
||||
} // if
|
||||
} // while
|
||||
} // for
|
||||
SQLFreeStmt(hstmt, SQL_CLOSE);
|
||||
|
||||
// Query how many columns are in each table
|
||||
@@ -2545,7 +2537,9 @@ wxDbInf *wxDb::GetCatalog(char *userID)
|
||||
{
|
||||
(pDbInf->pTableInf+noTab)->numCols = GetColumnCount((pDbInf->pTableInf+noTab)->tableName,UserID);
|
||||
}
|
||||
|
||||
return pDbInf;
|
||||
|
||||
} // wxDb::GetCatalog()
|
||||
|
||||
|
||||
@@ -2704,7 +2698,6 @@ bool wxDb::TableExists(const char *tableName, const char *userID, const char *ta
|
||||
|
||||
if (Dbms() == dbmsDBASE)
|
||||
{
|
||||
|
||||
wxString dbName;
|
||||
if (tablePath && wxStrlen(tablePath))
|
||||
dbName.sprintf("%s\\%s.dbf",tablePath,tableName);
|
||||
@@ -2771,10 +2764,12 @@ bool wxDb::TableExists(const char *tableName, const char *userID, const char *ta
|
||||
}
|
||||
|
||||
SQLFreeStmt(hstmt, SQL_CLOSE);
|
||||
|
||||
return(TRUE);
|
||||
|
||||
} // wxDb::TableExists()
|
||||
|
||||
|
||||
#if EXPERIMENTAL_WXDB_FUNCTIONS // will be added in 2.4
|
||||
/********** wxDB::TablePrivileges() **********/
|
||||
bool wxDB::TablePrivileges(const char *tableName, const char* priv,
|
||||
@@ -2862,9 +2857,11 @@ bool wxDB::TablePrivileges(const char *tableName, const char* priv,
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
||||
} // wxDB::TablePrivileges
|
||||
#endif
|
||||
|
||||
|
||||
/********** wxDb::SetSqlLogging() **********/
|
||||
bool wxDb::SetSqlLogging(wxDbSqlLogState state, const char *filename, bool append)
|
||||
{
|
||||
@@ -2948,6 +2945,7 @@ wxDBMS wxDb::Dbms(void)
|
||||
*
|
||||
* SYBASE (Enterprise)
|
||||
* - If a column is part of the Primary Key, the column cannot be NULL
|
||||
* - Maximum row size is somewhere in the neighborhood of 1920 bytes
|
||||
*
|
||||
* MY_SQL
|
||||
* - If a column is part of the Primary Key, the column cannot be NULL
|
||||
@@ -2955,10 +2953,11 @@ wxDBMS wxDb::Dbms(void)
|
||||
* - Columns that are part of primary or secondary keys must be defined as being NOT NULL
|
||||
* when they are created. Some code is added in ::CreateIndex to try to adjust the
|
||||
* column definition if it is not defined correctly, but it is experimental
|
||||
* - Does not support sub-queries in SQL statements
|
||||
*
|
||||
* POSTGRES
|
||||
* - Does not support the keywords 'ASC' or 'DESC' as of release v6.5.0
|
||||
*
|
||||
* - Does not support sub-queries in SQL statements
|
||||
*
|
||||
*/
|
||||
{
|
||||
@@ -2979,10 +2978,11 @@ wxDBMS wxDb::Dbms(void)
|
||||
// Is it also returned by Sybase Adapatitve server?
|
||||
// OpenLink driver name is OLOD3032.DLL for msw and oplodbc.so for unix
|
||||
if (!wxStricmp(dbInf.dbmsName,"SQL Server"))
|
||||
{
|
||||
if (!wxStrncmp(dbInf.driverName, "oplodbc", 7) ||
|
||||
!wxStrncmp(dbInf.driverName, "OLOD", 4))
|
||||
return dbmsMS_SQL_SERVER; else return dbmsSYBASE_ASE;
|
||||
|
||||
}
|
||||
|
||||
if (!wxStricmp(dbInf.dbmsName,"Microsoft SQL Server"))
|
||||
return(dbmsMS_SQL_SERVER);
|
||||
@@ -2995,7 +2995,6 @@ wxDBMS wxDb::Dbms(void)
|
||||
if (!wxStricmp(baseName,"Informix"))
|
||||
return(dbmsINFORMIX);
|
||||
|
||||
|
||||
baseName[6] = 0;
|
||||
if (!wxStricmp(baseName,"Oracle"))
|
||||
return(dbmsORACLE);
|
||||
@@ -3011,6 +3010,7 @@ wxDBMS wxDb::Dbms(void)
|
||||
return(dbmsDBASE);
|
||||
|
||||
return(dbmsUNIDENTIFIED);
|
||||
|
||||
} // wxDb::Dbms()
|
||||
|
||||
|
||||
@@ -3151,7 +3151,6 @@ bool wxDbSqlLog(wxDbSqlLogState state, const wxChar *filename)
|
||||
}
|
||||
|
||||
SQLLOGstate = state;
|
||||
// wxStrcpy(SQLLOGfn,filename);
|
||||
SQLLOGfn = filename;
|
||||
|
||||
return(TRUE);
|
||||
|
@@ -191,7 +191,6 @@ wxDbTable::wxDbTable(wxDb *pwxDb, const char *tblName, const int nCols,
|
||||
pDb->GetNextError(henv, hdbc, hstmtInternal);
|
||||
if (! wxStrcmp(pDb->sqlState, "01S02")) // Option Value Changed
|
||||
{
|
||||
|
||||
// Datasource does not support static cursors. Driver
|
||||
// will substitute a cursor type. Call SQLGetStmtOption()
|
||||
// to determine which cursor type was selected.
|
||||
@@ -202,17 +201,20 @@ wxDbTable::wxDbTable(wxDb *pwxDb, const char *tblName, const int nCols,
|
||||
switch(cursorType)
|
||||
{
|
||||
case SQL_CURSOR_FORWARD_ONLY:
|
||||
cout << "Forward Only"; break;
|
||||
cout << "Forward Only";
|
||||
break;
|
||||
case SQL_CURSOR_STATIC:
|
||||
cout << "Static"; break;
|
||||
cout << "Static";
|
||||
break;
|
||||
case SQL_CURSOR_KEYSET_DRIVEN:
|
||||
cout << "Keyset Driven"; break;
|
||||
cout << "Keyset Driven";
|
||||
break;
|
||||
case SQL_CURSOR_DYNAMIC:
|
||||
cout << "Dynamic"; break;
|
||||
cout << "Dynamic";
|
||||
break;
|
||||
}
|
||||
cout << endl << endl;
|
||||
#endif
|
||||
|
||||
// BJO20000425
|
||||
if (pDb->FwdOnlyCursors() && cursorType != SQL_CURSOR_FORWARD_ONLY)
|
||||
{
|
||||
@@ -317,7 +319,6 @@ wxDbTable::~wxDbTable()
|
||||
if (hstmtUpdate)
|
||||
if (SQLFreeStmt(hstmtUpdate, SQL_DROP) != SQL_SUCCESS)
|
||||
pDb->DispAllErrors(henv, hdbc);
|
||||
|
||||
}
|
||||
|
||||
if (hstmtInternal)
|
||||
@@ -331,7 +332,6 @@ wxDbTable::~wxDbTable()
|
||||
if (hstmtCount)
|
||||
DeleteCursor(hstmtCount);
|
||||
|
||||
|
||||
} // wxDbTable::~wxDbTable()
|
||||
|
||||
|
||||
@@ -359,7 +359,6 @@ bool wxDbTable::bindInsertParams(void)
|
||||
continue;
|
||||
switch(colDefs[i].DbDataType)
|
||||
{
|
||||
|
||||
case DB_DATA_TYPE_VARCHAR:
|
||||
fSqlType = pDb->GetTypeInfVarchar().FsqlType;
|
||||
precision = colDefs[i].SzDataObj;
|
||||
@@ -400,8 +399,10 @@ bool wxDbTable::bindInsertParams(void)
|
||||
if (SQLBindParameter(hstmtInsert, colNo++, SQL_PARAM_INPUT, colDefs[i].SqlCtype,
|
||||
fSqlType, precision, scale, (UCHAR*) colDefs[i].PtrDataObj,
|
||||
precision+1,&colDefs[i].CbValue) != SQL_SUCCESS)
|
||||
{
|
||||
return(pDb->DispAllErrors(henv, hdbc, hstmtInsert));
|
||||
}
|
||||
}
|
||||
|
||||
// Completed successfully
|
||||
return(TRUE);
|
||||
@@ -462,8 +463,10 @@ bool wxDbTable::bindUpdateParams(void)
|
||||
if (SQLBindParameter(hstmtUpdate, colNo++, SQL_PARAM_INPUT, colDefs[i].SqlCtype,
|
||||
fSqlType, precision, scale, (UCHAR*) colDefs[i].PtrDataObj,
|
||||
precision+1, &colDefs[i].CbValue) != SQL_SUCCESS)
|
||||
{
|
||||
return(pDb->DispAllErrors(henv, hdbc, hstmtUpdate));
|
||||
}
|
||||
}
|
||||
|
||||
// Completed successfully
|
||||
return(TRUE);
|
||||
@@ -482,8 +485,10 @@ bool wxDbTable::bindCols(HSTMT cursor)
|
||||
{
|
||||
if (SQLBindCol(cursor, i+1, colDefs[i].SqlCtype, (UCHAR*) colDefs[i].PtrDataObj,
|
||||
colDefs[i].SzDataObj, &cb) != SQL_SUCCESS)
|
||||
{
|
||||
return (pDb->DispAllErrors(henv, hdbc, cursor));
|
||||
}
|
||||
}
|
||||
|
||||
// Completed successfully
|
||||
return(TRUE);
|
||||
@@ -504,11 +509,13 @@ bool wxDbTable::getRec(UWORD fetchType)
|
||||
|
||||
retcode = SQLExtendedFetch(hstmt, fetchType, 0, &cRowsFetched, &rowStatus);
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO)
|
||||
{
|
||||
if (retcode == SQL_NO_DATA_FOUND)
|
||||
return(FALSE);
|
||||
else
|
||||
return(pDb->DispAllErrors(henv, hdbc, hstmt));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fetch the next record from the record set
|
||||
@@ -571,7 +578,9 @@ bool wxDbTable::query(int queryType, bool forUpdate, bool distinct, const char *
|
||||
{ // so generate a select statement.
|
||||
BuildSelectStmt(sqlStmt, queryType, distinct);
|
||||
pDb->WriteSqlLog(sqlStmt);
|
||||
} else wxStrcpy(sqlStmt, pSqlStmt);
|
||||
}
|
||||
else
|
||||
wxStrcpy(sqlStmt, pSqlStmt);
|
||||
|
||||
SQLFreeStmt(hstmt, SQL_CLOSE);
|
||||
if (SQLExecDirect(hstmt, (UCHAR FAR *) sqlStmt, SQL_NTS) == SQL_SUCCESS)
|
||||
@@ -741,6 +750,7 @@ bool wxDbTable::GetPrev(void)
|
||||
}
|
||||
else
|
||||
return(getRec(SQL_FETCH_PRIOR));
|
||||
|
||||
} // wxDbTable::GetPrev()
|
||||
|
||||
|
||||
@@ -754,6 +764,7 @@ bool wxDbTable::operator--(int)
|
||||
}
|
||||
else
|
||||
return(getRec(SQL_FETCH_PRIOR));
|
||||
|
||||
} // wxDbTable::operator--
|
||||
|
||||
|
||||
@@ -767,6 +778,7 @@ bool wxDbTable::GetFirst(void)
|
||||
}
|
||||
else
|
||||
return(getRec(SQL_FETCH_FIRST));
|
||||
|
||||
} // wxDbTable::GetFirst()
|
||||
|
||||
|
||||
@@ -780,6 +792,7 @@ bool wxDbTable::GetLast(void)
|
||||
}
|
||||
else
|
||||
return(getRec(SQL_FETCH_LAST));
|
||||
|
||||
} // wxDbTable::GetLast()
|
||||
|
||||
|
||||
@@ -942,7 +955,6 @@ bool wxDbTable::CreateTable(bool attemptDrop)
|
||||
return FALSE;
|
||||
|
||||
int i, j;
|
||||
// char sqlStmt[DB_MAX_STATEMENT_LEN];
|
||||
wxString sqlStmt;
|
||||
|
||||
#ifdef DBDEBUG_CONSOLE
|
||||
@@ -999,13 +1011,17 @@ bool wxDbTable::CreateTable(bool attemptDrop)
|
||||
switch(colDefs[i].DbDataType)
|
||||
{
|
||||
case DB_DATA_TYPE_VARCHAR:
|
||||
sqlStmt += pDb->GetTypeInfVarchar().TypeName; break;
|
||||
sqlStmt += pDb->GetTypeInfVarchar().TypeName;
|
||||
break;
|
||||
case DB_DATA_TYPE_INTEGER:
|
||||
sqlStmt += pDb->GetTypeInfInteger().TypeName; break;
|
||||
sqlStmt += pDb->GetTypeInfInteger().TypeName;
|
||||
break;
|
||||
case DB_DATA_TYPE_FLOAT:
|
||||
sqlStmt += pDb->GetTypeInfFloat().TypeName; break;
|
||||
sqlStmt += pDb->GetTypeInfFloat().TypeName;
|
||||
break;
|
||||
case DB_DATA_TYPE_DATE:
|
||||
sqlStmt += pDb->GetTypeInfDate().TypeName; break;
|
||||
sqlStmt += pDb->GetTypeInfDate().TypeName;
|
||||
break;
|
||||
}
|
||||
// For varchars, append the size of the string
|
||||
if (colDefs[i].DbDataType == DB_DATA_TYPE_VARCHAR)
|
||||
@@ -1084,7 +1100,7 @@ bool wxDbTable::CreateTable(bool attemptDrop)
|
||||
|
||||
// Commit the transaction and close the cursor
|
||||
if (!pDb->CommitTrans())
|
||||
return(FALSE);
|
||||
rEturn(FALSE);
|
||||
if (!CloseCursor(hstmt))
|
||||
return(FALSE);
|
||||
|
||||
@@ -1187,13 +1203,17 @@ bool wxDbTable::CreateIndex(const char * idxName, bool unique, int noIdxCols, wx
|
||||
switch(colDefs[j].DbDataType)
|
||||
{
|
||||
case DB_DATA_TYPE_VARCHAR:
|
||||
typeNameAndSize = pDb->GetTypeInfVarchar().TypeName; break;
|
||||
typeNameAndSize = pDb->GetTypeInfVarchar().TypeName;
|
||||
break;
|
||||
case DB_DATA_TYPE_INTEGER:
|
||||
typeNameAndSize = pDb->GetTypeInfInteger().TypeName; break;
|
||||
typeNameAndSize = pDb->GetTypeInfInteger().TypeName;
|
||||
break;
|
||||
case DB_DATA_TYPE_FLOAT:
|
||||
typeNameAndSize = pDb->GetTypeInfFloat().TypeName; break;
|
||||
typeNameAndSize = pDb->GetTypeInfFloat().TypeName;
|
||||
break;
|
||||
case DB_DATA_TYPE_DATE:
|
||||
typeNameAndSize = pDb->GetTypeInfDate().TypeName; break;
|
||||
typeNameAndSize = pDb->GetTypeInfDate().TypeName;
|
||||
break;
|
||||
}
|
||||
|
||||
// For varchars, append the size of the string
|
||||
@@ -1807,7 +1827,6 @@ void wxDbTable::ClearMemberVars(void)
|
||||
pDt->second = 0;
|
||||
pDt->fraction = 0;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1889,14 +1908,11 @@ wxDbColDataPtr* wxDbTable::SetColDefs (wxDbColInf *pColInfs, ULONG numCols)
|
||||
switch (pColInfs[index].dbDataType)
|
||||
{
|
||||
case DB_DATA_TYPE_VARCHAR:
|
||||
{
|
||||
pColDataPtrs[index].PtrDataObj = new char[pColInfs[index].bufferLength+1];
|
||||
pColDataPtrs[index].SzDataObj = pColInfs[index].columnSize;
|
||||
pColDataPtrs[index].SqlCtype = SQL_C_CHAR;
|
||||
break;
|
||||
}
|
||||
case DB_DATA_TYPE_INTEGER:
|
||||
{
|
||||
// Can be long or short
|
||||
if (pColInfs[index].bufferLength == sizeof(long))
|
||||
{
|
||||
@@ -1911,9 +1927,7 @@ wxDbColDataPtr* wxDbTable::SetColDefs (wxDbColInf *pColInfs, ULONG numCols)
|
||||
pColDataPtrs[index].SqlCtype = SQL_C_SSHORT;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DB_DATA_TYPE_FLOAT:
|
||||
{
|
||||
// Can be float or double
|
||||
if (pColInfs[index].bufferLength == sizeof(float))
|
||||
{
|
||||
@@ -1928,20 +1942,18 @@ wxDbColDataPtr* wxDbTable::SetColDefs (wxDbColInf *pColInfs, ULONG numCols)
|
||||
pColDataPtrs[index].SqlCtype = SQL_C_DOUBLE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DB_DATA_TYPE_DATE:
|
||||
{
|
||||
pColDataPtrs[index].PtrDataObj = new TIMESTAMP_STRUCT;
|
||||
pColDataPtrs[index].SzDataObj = sizeof(TIMESTAMP_STRUCT);
|
||||
pColDataPtrs[index].SqlCtype = SQL_C_TIMESTAMP;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SetColDefs (index,pColInfs[index].colName,pColInfs[index].dbDataType, pColDataPtrs[index].PtrDataObj, pColDataPtrs[index].SqlCtype, pColDataPtrs[index].SzDataObj);
|
||||
}
|
||||
}
|
||||
|
||||
return (pColDataPtrs);
|
||||
|
||||
} // wxDbTable::SetColDef()
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user