- case DB_SELECT_WHERE:
- if (where && wxStrlen(where)) // May not want a where clause!!!
- {
- wxStrcat(pSqlStmt, " WHERE ");
- wxStrcat(pSqlStmt, where);
- }
- break;
- case DB_SELECT_KEYFIELDS:
- GetWhereClause(whereClause, DB_WHERE_KEYFIELDS);
- if (wxStrlen(whereClause))
+ case DB_SELECT_WHERE:
+#if wxODBC_BACKWARD_COMPATABILITY
+ if (where && wxStrlen(where)) // May not want a where clause!!!
+#else
+ if (where.Length()) // May not want a where clause!!!
+#endif
+ {
+ pSqlStmt += wxT(" WHERE ");
+ pSqlStmt += where;
+ }
+ break;
+ case DB_SELECT_KEYFIELDS:
+ BuildWhereClause(whereClause, DB_WHERE_KEYFIELDS);
+ if (whereClause.Length())
+ {
+ pSqlStmt += wxT(" WHERE ");
+ pSqlStmt += whereClause;
+ }
+ break;
+ case DB_SELECT_MATCHING:
+ BuildWhereClause(whereClause, DB_WHERE_MATCHING);
+ if (whereClause.Length())
+ {
+ pSqlStmt += wxT(" WHERE ");
+ pSqlStmt += whereClause;
+ }
+ break;
+ }
+
+ // Append the ORDER BY clause
+#if wxODBC_BACKWARD_COMPATABILITY
+ if (orderBy && wxStrlen(orderBy))
+#else
+ if (orderBy.Length())
+#endif
+ {
+ pSqlStmt += wxT(" ORDER BY ");
+ pSqlStmt += orderBy;
+ }
+
+ // SELECT FOR UPDATE if told to do so and the datasource is capable. Sybase
+ // parses the FOR UPDATE clause but ignores it. See the comment above on the
+ // HOLDLOCK for Sybase.
+ if (selectForUpdate && CanSelectForUpdate())
+ pSqlStmt += wxT(" FOR UPDATE");
+
+} // wxDbTable::BuildSelectStmt()
+
+
+/***** DEPRECATED: use wxDbTable::BuildSelectStmt(wxString &....) form *****/
+void wxDbTable::BuildSelectStmt(wxChar *pSqlStmt, int typeOfSelect, bool distinct)
+{
+ wxString tempSqlStmt;
+ BuildSelectStmt(tempSqlStmt, typeOfSelect, distinct);
+ wxStrcpy(pSqlStmt, tempSqlStmt);
+} // wxDbTable::BuildSelectStmt()
+
+
+/********** wxDbTable::BuildUpdateStmt() **********/
+void wxDbTable::BuildUpdateStmt(wxString &pSqlStmt, int typeOfUpd, const wxString &pWhereClause)
+{
+ wxASSERT(!queryOnly);
+ if (queryOnly)
+ return;
+
+ wxString whereClause;
+ whereClause.Empty();
+
+ bool firstColumn = TRUE;
+
+ pSqlStmt.Printf(wxT("UPDATE %s SET "), tableName.Upper().c_str());
+
+ // Append a list of columns to be updated
+ int i;
+ for (i = 0; i < noCols; i++)
+ {
+ // Only append Updateable columns
+ if (colDefs[i].Updateable)