Query Combining |
For UPDATE statements, let the Rules Engine combine the statement used to retrieve and lock the records to be updated with the internal SQL statement used to determine the new values. BackgroundBefore USoft Developer 5.2, UPDATE statements were always handled as follows: one SQL statement retrieved and locked the records to be updated and for each selected record the new values were queried (and then the record was updated). The BenchMark reasons for these SQL statements were SELECT_FOR_UPDATE and NEWVALUES. As of USoft Developer 5.2, in some cases these statements can be combined into one single OLD_NEWVALUES statement. This reduces the number of SQL statements sent to the database. When to useThe Rules Engine is NOT able to combine the SELECT_FOR_UPDATE statement with the NEWVALUES statements if the SET clauses of the UPDATE statement contain: •An INVOKE, ROWNUM, or UNION keyword. •An outer-join condition. •A GROUP BY clause. •A group function. •A CONNECT BY clause. These statements are NOT combined for Update on Self constraints. For applications built in USoft Developer 5.2 or higher, the SELECT_FOR_UPDATE and NEWVALUES statements are combined by default. For upgraded applications, or applications older than USoft Developer 5.2, you have to combine these statements:
Example Suppose the following SQL statement is issued in SQL Command:
If the COMBINE_QUERIES parameter has been set to True, one single SQL statement retrieves the scheduled tours to be updated and the number of days of the corresponding tour. This SQL statement has reason OLD_NEWVALUES:
Database behaviourOn Oracle and on Microsoft SQL Server, the behaviour is as described in the example. On ODBC, query combining is not supported. These databases do not allow for a SELECT_FOR_UPDATE clause with a join.
See also |