[Figure: Example of using values from other columns to update data]
Note that when column values are specified for data to be updated, the values used are those prior to execution of the
UPDATE statement. In this example, SHIPQTY is updated to "120", as specified by the literal. However,
PREVSHIPMT is updated to "100", the value of SHIPQTY prior to execution of the UPDATE statement. SHIPQTY is
not "120", which is the value to be updated to by this UPDATE statement.
3.2.6 Performing arithmetic operations on data to be updated
The result of arithmetic operations performed on values such as column values can be used for data to be updated.
The following is an example of using this for data to be updated:
Example:
In this example, PRICE is reduced by 10% and 150 is added to ORDERQTY for the data for
CUSTOMER "61" in the ORDER table.
[Figure: Example in which arithmetic operations are performed on data to be updated]
In this example, the operation "PRICE x 0.9" is performed to reduce PRICE by 10%. The operation "PRICE - (PRICE
x 0.1)" could also be used. However, the processing efficiency of SQL statements deteriorates as the number of
operators increases. As in this example, simplify the operational expression as much as possible.
34