- if (!colDefs) // May happen if the database connection fails
- return;
-
- if (wxStrlen(fieldName) > (unsigned int) DB_MAX_COLUMN_NAME_LEN)
- {
- wxStrncpy (colDefs[index].ColName, fieldName, DB_MAX_COLUMN_NAME_LEN);
- colDefs[index].ColName[DB_MAX_COLUMN_NAME_LEN] = 0;
- }
- else
- wxStrcpy(colDefs[index].ColName, fieldName);
-
- colDefs[index].DbDataType = dataType;
- colDefs[index].PtrDataObj = pData;
- colDefs[index].SqlCtype = cType;
- colDefs[index].SzDataObj = size;
- colDefs[index].KeyField = keyField;
- colDefs[index].DerivedCol = derivedCol;
- // Derived columns by definition would NOT be "Insertable" or "Updateable"
- if (derivedCol)
- {
- colDefs[index].Updateable = FALSE;
- colDefs[index].InsertAllowed = FALSE;
- }
- else
- {
- colDefs[index].Updateable = upd;
- colDefs[index].InsertAllowed = insAllow;
- }
-
- colDefs[index].Null = FALSE;
-
-} // wxTable::SetColDefs()
-
-/********** wxTable::SetCursor() **********/
-void wxTable::SetCursor(HSTMT *hstmtActivate)
+ if (SQLSetStmtOption(hstmtInsert, SQL_QUERY_TIMEOUT, nSeconds) != SQL_SUCCESS)
+ return(pDb->DispAllErrors(henv, hdbc, hstmtInsert));
+ if (SQLSetStmtOption(hstmtUpdate, SQL_QUERY_TIMEOUT, nSeconds) != SQL_SUCCESS)
+ return(pDb->DispAllErrors(henv, hdbc, hstmtUpdate));
+ if (SQLSetStmtOption(hstmtDelete, SQL_QUERY_TIMEOUT, nSeconds) != SQL_SUCCESS)
+ return(pDb->DispAllErrors(henv, hdbc, hstmtDelete));
+ if (SQLSetStmtOption(hstmtInternal, SQL_QUERY_TIMEOUT, nSeconds) != SQL_SUCCESS)
+ return(pDb->DispAllErrors(henv, hdbc, hstmtInternal));
+
+ // Completed Successfully
+ return(TRUE);
+
+} // wxDbTable::SetQueryTimeout()
+
+
+/********** wxDbTable::SetColDefs() **********/
+void wxDbTable::SetColDefs(int index, const char *fieldName, int dataType, void *pData,
+ int cType, int size, bool keyField, bool upd,
+ bool insAllow, bool derivedCol)
+{
+ if (!colDefs) // May happen if the database connection fails
+ return;
+
+ if (wxStrlen(fieldName) > (unsigned int) DB_MAX_COLUMN_NAME_LEN)
+ {
+ wxStrncpy (colDefs[index].ColName, fieldName, DB_MAX_COLUMN_NAME_LEN);
+ colDefs[index].ColName[DB_MAX_COLUMN_NAME_LEN] = 0;
+ }
+ else
+ wxStrcpy(colDefs[index].ColName, fieldName);
+
+ colDefs[index].DbDataType = dataType;
+ colDefs[index].PtrDataObj = pData;
+ colDefs[index].SqlCtype = cType;
+ colDefs[index].SzDataObj = size;
+ colDefs[index].KeyField = keyField;
+ colDefs[index].DerivedCol = derivedCol;
+ // Derived columns by definition would NOT be "Insertable" or "Updateable"
+ if (derivedCol)
+ {
+ colDefs[index].Updateable = FALSE;
+ colDefs[index].InsertAllowed = FALSE;
+ }
+ else
+ {
+ colDefs[index].Updateable = upd;
+ colDefs[index].InsertAllowed = insAllow;
+ }
+
+ colDefs[index].Null = FALSE;
+
+} // wxDbTable::SetColDefs()
+
+
+/********** wxDbTable::SetColDefs() **********/
+wxDbColDataPtr* wxDbTable::SetColDefs(wxDbColInf *pColInfs, ULONG numCols)
+{
+ assert(pColInfs);
+ wxDbColDataPtr *pColDataPtrs = NULL;
+
+ if (pColInfs)
+ {
+ ULONG index;
+
+ pColDataPtrs = new wxDbColDataPtr[numCols+1];
+
+ for (index = 0; index < numCols; index++)
+ {
+ // Process the fields
+ 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))
+ {
+ pColDataPtrs[index].PtrDataObj = new long;
+ pColDataPtrs[index].SzDataObj = sizeof(long);
+ pColDataPtrs[index].SqlCtype = SQL_C_SLONG;
+ }
+ else
+ {
+ pColDataPtrs[index].PtrDataObj = new short;
+ pColDataPtrs[index].SzDataObj = sizeof(short);
+ pColDataPtrs[index].SqlCtype = SQL_C_SSHORT;
+ }
+ break;
+ case DB_DATA_TYPE_FLOAT:
+ // Can be float or double
+ if (pColInfs[index].bufferLength == sizeof(float))
+ {
+ pColDataPtrs[index].PtrDataObj = new float;
+ pColDataPtrs[index].SzDataObj = sizeof(float);
+ pColDataPtrs[index].SqlCtype = SQL_C_FLOAT;
+ }
+ else
+ {
+ pColDataPtrs[index].PtrDataObj = new double;
+ pColDataPtrs[index].SzDataObj = sizeof(double);
+ 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::SetColDefs()
+
+
+/********** wxDbTable::SetCursor() **********/
+void wxDbTable::SetCursor(HSTMT *hstmtActivate)