SQL::ConnectionGenerateWhereClause Method


Select_Clause as C = GenerateWhereClause as C (TableInfo as SQL::TableInfo, Criteria as SQL::UpdateWhereCriteria [, UseBatchQualifiers = .t. as L [, UseOldNewPrefix = .f. as L ][, SourceTableInfo as SQL::TableInfo]])



A SQL::TableInfo object for the table created with the DIM statement.


A SQL::UpdateWhereCriteria object for the table created with the DIM statement.


Default = .T. Changes the syntax of SQL INSERT, DELETE, and UPDATE statements.


Default = .F.





A SQL WHERE clause.


Generate a SQL WHERE clause for a table, based on the update criteria specified.

If UseBatchQualifiers is true then fields will be prefaced with ':old.' so a result set can be the source of the data.

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).


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