SQL::ConnectionGenerateWhereClause Method
Syntax
Arguments
- TableInfoSQL::TableInfo
A SQL::TableInfo object for the table created with the DIM statement.
- CriteriaSQL::UpdateWhereCriteria
A SQL::UpdateWhereCriteria object for the table created with the DIM statement.
- UseBatchQualifiersLogical
Default = .T. Changes the syntax of SQL INSERT, DELETE, and UPDATE statements.
- UseOldNewPrefixLogical
Default = .F.
- SourceTableInfoSQL::TableInfo
SQL::TableInfo
Returns
- Select_ClauseCharacter
A SQL WHERE clause.
Description
Generate a SQL WHERE clause for a table, based on the update criteria specified.
The GenerateWhereClause() method generates a SQL WHERE clause based on the value of (see the values for the type SQL::UpdateWhereCriteria ) that can be attached to an update statement. The WHERE clause will uniquely identify a row to be updated based on the primary key, the primary key and all updatable columns or all columns that are valid for a where clause (for example IMAGE types can not be used in a where clause when using the SQLServer database).
When UseBatchQualifiers is explicitly set to .T., the appropriate column values are generated in the format :old. or :new. (All :old. for DELETE or WHERE clauses, All :new. for INSERT and a mixture for UPDATE statements).
Example
INSERT INTO tablename (column1, column2) VALUES (:new.value1, :new.value2) DELETE FROM tablename WHERE column1 = :old.value1
If UseBatchQualifiers is set to .F., these function will generate the value entries as simple arguments (with one exception) so you can build an arguments collection up and execute the statement.
INSERT INTO tablename (column1, column2) VALUES (:value1, :value2)
The exception is that UPDATE statements need to differentiate between new and old values (note the prefix of "new__").
UPDATE tablename SET column1 = :new__value1 WHERE column2 = :value2
See Also