SQL::ConnectionGenerateUpdateStatement Method
Syntax
Arguments
- TableInfoSQL::TableInfo
A SQL::TableInfo object for the table created with the DIM statement.
- UseBatchQualifiersLogical
Default = .T. Changes the syntax of SQL INSERT, DELETE, and UPDATE statements.
- SourceTableInfoSQL::TableInfo
SQL::TableInfo
Returns
- StatementCharacter
A SQL UPDATE statement.
Description
Generate a SQL Update statement for the table passed in.
Discussion
The GenerateUpdateStatement() method generates a SQL UPDATE statement for the table defined in TableInfo.
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).
If UseBatchQualifiers is true then field values will be generated as arguments prefaced with 'new.' and 'old.' so a result set can be the source of the data.
When UseBatchQualifiers is explicitly set to .T. . UPDATE statements need to differentiate between new and old values (note the prefix of "new__").
UPDATE tablename SET column2 = :new.column2 WHERE column1 = :old.column1 and column2 = :old.column2
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)
You would probably have a key column in the WHERE clause, which is generally not updated but is used to uniquely identify the row. In this case, the presence of the original value of column2 in the WHERE clause will return zero rows affected if the value of column2 has changed (optimistic concurrency - see the list of arguments for SQL::Connection::GenerateUpdateStatement).
See Also