-/********** wxTable::bindInsertParams() **********/
-bool wxTable::bindInsertParams(void)
-{
- assert(!queryOnly);
- if (queryOnly)
- return(FALSE);
-
- SWORD fSqlType = 0;
- UDWORD precision = 0;
- SWORD scale = 0;
-
- // Bind each column (that can be inserted) of the table to a parameter marker
- int i,colNo;
- for (i = 0, colNo = 1; i < noCols; i++)
- {
- if (! colDefs[i].InsertAllowed)
- continue;
- switch(colDefs[i].DbDataType)
- {
- case DB_DATA_TYPE_VARCHAR:
- fSqlType = pDb->typeInfVarchar.FsqlType;
- precision = colDefs[i].SzDataObj;
- scale = 0;
- colDefs[i].CbValue = SQL_NTS;
- break;
- case DB_DATA_TYPE_INTEGER:
- fSqlType = pDb->typeInfInteger.FsqlType;
- precision = pDb->typeInfInteger.Precision;
- scale = 0;
- colDefs[i].CbValue = 0;
- break;
- case DB_DATA_TYPE_FLOAT:
- fSqlType = pDb->typeInfFloat.FsqlType;
- precision = pDb->typeInfFloat.Precision;
- scale = pDb->typeInfFloat.MaximumScale;
- // SQL Sybase Anywhere v5.5 returned a negative number for the
- // MaxScale. This caused ODBC to kick out an error on ibscale.
- // I check for this here and set the scale = precision.
- //if (scale < 0)
- // scale = (short) precision;
- colDefs[i].CbValue = 0;
- break;
- case DB_DATA_TYPE_DATE:
- fSqlType = pDb->typeInfDate.FsqlType;
- precision = pDb->typeInfDate.Precision;
- scale = 0;
- colDefs[i].CbValue = 0;
- break;
- }
- // Null values
- if (colDefs[i].Null)
- {
- colDefs[i].CbValue = SQL_NULL_DATA;
- colDefs[i].Null = FALSE;
- }
- 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);
-
-} // wxTable::bindInsertParams()
-
-
-/********** wxTable::bindUpdateParams() **********/
-bool wxTable::bindUpdateParams(void)
-{
- assert(!queryOnly);
- if (queryOnly)
- return(FALSE);
-
- SWORD fSqlType = 0;
- UDWORD precision = 0;
- SWORD scale = 0;
-
- // Bind each UPDATEABLE column of the table to a parameter marker
- int i,colNo;
- for (i = 0, colNo = 1; i < noCols; i++)
- {
- if (! colDefs[i].Updateable)
- continue;
- switch(colDefs[i].DbDataType)
- {
- case DB_DATA_TYPE_VARCHAR:
- fSqlType = pDb->typeInfVarchar.FsqlType;
- precision = colDefs[i].SzDataObj;
- scale = 0;
- colDefs[i].CbValue = SQL_NTS;
- break;
- case DB_DATA_TYPE_INTEGER:
- fSqlType = pDb->typeInfInteger.FsqlType;
- precision = pDb->typeInfInteger.Precision;
- scale = 0;
- colDefs[i].CbValue = 0;
- break;
- case DB_DATA_TYPE_FLOAT:
- fSqlType = pDb->typeInfFloat.FsqlType;
- precision = pDb->typeInfFloat.Precision;
- scale = pDb->typeInfFloat.MaximumScale;
- // SQL Sybase Anywhere v5.5 returned a negative number for the
- // MaxScale. This caused ODBC to kick out an error on ibscale.
- // I check for this here and set the scale = precision.
- //if (scale < 0)
- // scale = (short) precision;
- colDefs[i].CbValue = 0;
- break;
- case DB_DATA_TYPE_DATE:
- fSqlType = pDb->typeInfDate.FsqlType;
- precision = pDb->typeInfDate.Precision;
- scale = 0;
- colDefs[i].CbValue = 0;
- break;
- }
- 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);
-
-} // wxTable::bindUpdateParams()
-
-
-/********** wxTable::bindCols() **********/
-bool wxTable::bindCols(HSTMT cursor)
-{
- static SDWORD cb;
-
- // Bind each column of the table to a memory address for fetching data
- int i;
- for (i = 0; i < noCols; i++)
- {
- 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);
-
-} // wxTable::bindCols()
-
-
-/********** wxTable::getRec() **********/
-bool wxTable::getRec(UWORD fetchType)
-{
- RETCODE retcode;
-
- if (!pDb->FwdOnlyCursors())
- {
- // Fetch the NEXT, PREV, FIRST or LAST record, depending on fetchType
- UDWORD cRowsFetched;
- UWORD rowStatus;
-
- 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
- retcode = SQLFetch(hstmt);
- if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO)
- {
- if (retcode == SQL_NO_DATA_FOUND)
- return(FALSE);
- else
- return(pDb->DispAllErrors(henv, hdbc, hstmt));
- }
- }
-
- // Completed successfully
- return(TRUE);
-
-} // wxTable::getRec()
-
-
-/********** wxTable::execDelete() **********/
-bool wxTable::execDelete(const char *pSqlStmt)
-{
- // Execute the DELETE statement
- if (SQLExecDirect(hstmtDelete, (UCHAR FAR *) pSqlStmt, SQL_NTS) != SQL_SUCCESS)
- return(pDb->DispAllErrors(henv, hdbc, hstmtDelete));
-
- // Record deleted successfully
- return(TRUE);
-
-} // wxTable::execDelete()
-
-
-/********** wxTable::execUpdate() **********/
-bool wxTable::execUpdate(const char *pSqlStmt)
+
+/********** wxDbTable::getRec() **********/
+bool wxDbTable::getRec(UWORD fetchType)
+{
+ RETCODE retcode;
+
+ if (!pDb->FwdOnlyCursors())
+ {
+ // Fetch the NEXT, PREV, FIRST or LAST record, depending on fetchType
+ UDWORD cRowsFetched;
+ UWORD rowStatus;
+
+ 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
+ {
+ // Set the Null member variable to indicate the Null state
+ // of each column just read in.
+ int i;
+ for (i = 0; i < noCols; i++)
+ colDefs[i].Null = (colDefs[i].CbValue == SQL_NULL_DATA);
+ }
+ }
+ else
+ {
+ // Fetch the next record from the record set
+ retcode = SQLFetch(hstmt);
+ 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
+ {
+ // Set the Null member variable to indicate the Null state
+ // of each column just read in.
+ int i;
+ for (i = 0; i < noCols; i++)
+ colDefs[i].Null = (colDefs[i].CbValue == SQL_NULL_DATA);
+ }
+ }
+
+ // Completed successfully
+ return(TRUE);
+
+} // wxDbTable::getRec()
+
+
+/********** wxDbTable::execDelete() **********/
+bool wxDbTable::execDelete(const wxString &pSqlStmt)