[Figure: Updating data using the current date and time]
3.2.5 Using values from other columns in data to be updated
Values from other columns can be used to update data. An example of this follows.
Suppose that a table named SHIPMT table consisting of the four columns ITMNO, SHIPQTY, PREVSHIPMT, and
VARIATION exists. When products are shipped, the quantity is set in SHIPQTY and the quantity previously shipped is
set in PREVSHIPMT. VARIATION is the difference between the current SHIPQTY and the previous SHIPQTY. The
value of VARIATION is not set every time shipment data is produced. Instead, data is assembled and set only when
required.
Example:
SHIPQTY is updated to "120" for the product with ITMNO "140" in the SHIPMT table, and the previous
SHIPQTY is set for PREVSHIPMT. Column VARIATION is not updated at this time.
UPDATE STOCKS. SHIPMT SET SHIPQTY = 120, PREVSHIPMT = SHIPQTY
WHERE ITMNO = 140
33