/********** wxDbTable::wxDbTable() Constructor **********/
-wxDbTable::wxDbTable(wxDb *pwxDb, const wxString &tblName, const int nCols,
+wxDbTable::wxDbTable(wxDb *pwxDb, const wxString &tblName, const UWORD numColumns,
const wxString &qryTblName, bool qryOnly, const wxString &tblPath)
{
- if (!initialize(pwxDb, tblName, nCols, qryTblName, qryOnly, tblPath))
+ if (!initialize(pwxDb, tblName, numColumns, qryTblName, qryOnly, tblPath))
cleanup();
} // wxDbTable::wxDbTable()
/***** DEPRECATED: use wxDbTable::wxDbTable() format above *****/
-wxDbTable::wxDbTable(wxDb *pwxDb, const wxString &tblName, const int nCols,
+wxDbTable::wxDbTable(wxDb *pwxDb, const wxString &tblName, const UWORD numColumns,
const wxChar *qryTblName, bool qryOnly, const wxString &tblPath)
{
wxString tempQryTblName;
tempQryTblName = qryTblName;
- if (!initialize(pwxDb, tblName, nCols, tempQryTblName, qryOnly, tblPath))
+ if (!initialize(pwxDb, tblName, numColumns, tempQryTblName, qryOnly, tblPath))
cleanup();
} // wxDbTable::wxDbTable()
} // wxDbTable::~wxDbTable()
-bool wxDbTable::initialize(wxDb *pwxDb, const wxString &tblName, const int nCols,
+bool wxDbTable::initialize(wxDb *pwxDb, const wxString &tblName, const UWORD numColumns,
const wxString &qryTblName, bool qryOnly, const wxString &tblPath)
{
// Initializing member variables
hstmtInternal = 0;
colDefs = 0;
tableID = 0;
- noCols = nCols; // No. of cols in the table
+ noCols = numColumns; // Number of cols in the table
where.Empty(); // Where clause
orderBy.Empty(); // Order By clause
from.Empty(); // From clause
// Bind each column of the table that should be bound
// to a parameter marker
- int i,colNo;
+ int i;
+ UWORD colNo;
for (i = 0, colNo = 1; i < noCols; i++)
{
if (forUpdate)
else
colDefs[i].CbValue = 0;
break;
+ case DB_DATA_TYPE_BLOB:
+ fSqlType = pDb->GetTypeInfBlob().FsqlType;
+ precision = 50000;
+ scale = 0;
+ if (colDefs[i].Null)
+ colDefs[i].CbValue = SQL_NULL_DATA;
+ else
+ colDefs[i].CbValue = SQL_LEN_DATA_AT_EXEC(colDefs[i].SzDataObj);
+ break;
}
if (forUpdate)
{
//RG-NULL static SDWORD cb;
// Bind each column of the table to a memory address for fetching data
- int i;
+ UWORD i;
for (i = 0; i < noCols; i++)
{
- if (SQLBindCol(cursor, i+1, colDefs[i].SqlCtype, (UCHAR*) colDefs[i].PtrDataObj,
-//RG-NULL colDefs[i].SzDataObj, &cb) != SQL_SUCCESS)
+ if (SQLBindCol(cursor, (UWORD)(i+1), colDefs[i].SqlCtype, (UCHAR*) colDefs[i].PtrDataObj,
colDefs[i].SzDataObj, &colDefs[i].CbValue ) != SQL_SUCCESS)
{
return (pDb->DispAllErrors(henv, hdbc, cursor));
/********** wxDbTable::Open() **********/
-bool wxDbTable::Open(bool checkPrivileges)
+bool wxDbTable::Open(bool checkPrivileges, bool checkTableExists)
{
if (!pDb)
return FALSE;
s.Empty();
// Verify that the table exists in the database
- if (!pDb->TableExists(tableName,/*pDb->GetUsername()*/NULL,tablePath))
+ if (checkTableExists && !pDb->TableExists(tableName, pDb->GetUsername(), tablePath))
{
s = wxT("Table/view does not exist in the database");
if ( *(pDb->dbInf.accessibleTables) == wxT('Y'))
// Unfortunately this optimization doesn't seem to be
// reliable!
if (// *(pDb->dbInf.accessibleTables) == 'N' &&
- !pDb->TablePrivileges(tableName,wxT("SELECT"),NULL,pDb->GetUsername(),tablePath))
+ !pDb->TablePrivileges(tableName,wxT("SELECT"), pDb->GetUsername(), pDb->GetUsername(), tablePath))
s = wxT("Current logged in user does not have sufficient privileges to access this table.\n");
}
// Get the ROWID value. If not successful retreiving the ROWID,
// simply fall down through the code and build the WHERE clause
// based on the key fields.
- if (SQLGetData(hstmt, noCols+1, SQL_C_CHAR, (UCHAR*) rowid, wxDB_ROWID_LEN, &cb) == SQL_SUCCESS)
+ if (SQLGetData(hstmt, (UWORD)(noCols+1), SQL_C_CHAR, (UCHAR*) rowid, wxDB_ROWID_LEN, &cb) == SQL_SUCCESS)
{
pSqlStmt += wxT("ROWID = '");
pSqlStmt += rowid;
// Get the ROWID value. If not successful retreiving the ROWID,
// simply fall down through the code and build the WHERE clause
// based on the key fields.
- if (SQLGetData(hstmt, noCols+1, SQL_C_CHAR, (UCHAR*) rowid, wxDB_ROWID_LEN, &cb) == SQL_SUCCESS)
+ if (SQLGetData(hstmt, (UWORD)(noCols+1), SQL_C_CHAR, (UCHAR*) rowid, wxDB_ROWID_LEN, &cb) == SQL_SUCCESS)
{
pSqlStmt += wxT("ROWID = '");
pSqlStmt += rowid;
case DB_DATA_TYPE_DATE:
cout << pDb->typeInfDate.TypeName;
break;
+ case DB_DATA_TYPE_BLOB:
+ cout << pDb->typeInfBlob.TypeName;
+ break;
}
cout << endl;
}
case DB_DATA_TYPE_DATE:
sqlStmt += pDb->GetTypeInfDate().TypeName;
break;
+ case DB_DATA_TYPE_BLOB:
+ sqlStmt += pDb->GetTypeInfBlob().TypeName;
+ break;
}
// For varchars, append the size of the string
- if (colDefs[i].DbDataType == DB_DATA_TYPE_VARCHAR)
+ if (colDefs[i].DbDataType == DB_DATA_TYPE_VARCHAR)// ||
+// colDefs[i].DbDataType == DB_DATA_TYPE_BLOB)
{
wxString s;
s.Printf(wxT("(%d)"), colDefs[i].SzDataObj);
* as the ROWID is not getting updated correctly
*/
return FALSE;
-
+/*
if (pDb->Dbms() == dbmsORACLE)
return(TRUE);
else
return(FALSE);
-
+*/
} // wxDbTable::CanUpdByROWID()
/********** wxDbTable::SetColDefs() **********/
void wxDbTable::SetColDefs(int index, const wxString &fieldName, int dataType, void *pData,
- int cType, int size, bool keyField, bool upd,
+ SWORD cType, int size, bool keyField, bool upd,
bool insAllow, bool derivedCol)
{
if (!colDefs) // May happen if the database connection fails
pColDataPtrs[index].SzDataObj = sizeof(TIMESTAMP_STRUCT);
pColDataPtrs[index].SqlCtype = SQL_C_TIMESTAMP;
break;
+ case DB_DATA_TYPE_BLOB:
+ int notSupportedYet = 0;
+ wxASSERT_MSG(notSupportedYet, wxT("This form of ::SetColDefs() cannot be used with BLOB columns"));
+ pColDataPtrs[index].PtrDataObj = /*BLOB ADDITION NEEDED*/NULL;
+ pColDataPtrs[index].SzDataObj = /*BLOB ADDITION NEEDED*/sizeof(void *);
+ pColDataPtrs[index].SqlCtype = SQL_VARBINARY;
+ break;
+ }
+ if (pColDataPtrs[index].PtrDataObj != NULL)
+ SetColDefs (index,pColInfs[index].colName,pColInfs[index].dbDataType, pColDataPtrs[index].PtrDataObj, pColDataPtrs[index].SqlCtype, pColDataPtrs[index].SzDataObj);
+ else
+ {
+ // Unable to build all the column definitions, as either one of
+ // the calls to "new" failed above, or there was a BLOB field
+ // to have a column definition for. If BLOBs are to be used,
+ // the other form of ::SetColDefs() must be used, as it is impossible
+ // to know the maximum size to create the PtrDataObj to be.
+ delete [] pColDataPtrs;
+ return NULL;
}
- SetColDefs (index,pColInfs[index].colName,pColInfs[index].dbDataType, pColDataPtrs[index].PtrDataObj, pColDataPtrs[index].SqlCtype, pColDataPtrs[index].SzDataObj);
}
}
}
// Obtain the result
- if (SQLGetData(*hstmtCount, 1, SQL_C_ULONG, &count, sizeof(count), &cb) != SQL_SUCCESS)
+ if (SQLGetData(*hstmtCount, (UWORD)1, SQL_C_ULONG, &count, sizeof(count), &cb) != SQL_SUCCESS)
{
pDb->DispAllErrors(henv, hdbc, *hstmtCount);
return(0);
// Get the ROWID value. If not successful retreiving the ROWID,
// simply fall down through the code and build the WHERE clause
// based on the key fields.
- if (SQLGetData(hstmt, noCols+1, SQL_C_CHAR, (UCHAR*) rowid, wxDB_ROWID_LEN, &cb) == SQL_SUCCESS)
+ if (SQLGetData(hstmt, (UWORD)(noCols+1), SQL_C_CHAR, (UCHAR*) rowid, wxDB_ROWID_LEN, &cb) == SQL_SUCCESS)
{
whereClause += queryTableName;
whereClause += wxT(".ROWID = '");