Fujitsu J2X0-1634-01EN Computer Accessories User Manual


 
Data can also be updated using a cursor. For information on this method, see 4.5 "Updating Data Using a Cursor".
The UPDATE statement explained in this section is called the UPDATE statement (searched) because search
conditions are used to specify rows to be updated.
3.2.1 Updating values in multiple columns
In the first example in 3.2 "Updating Data in a Data Base", data was updated in column ORDERQTY only. Suppose
that data in two columns, PRICE and ORDERQTY, is to be updated. An UPDATE statement could be executed once
for each column, but this is not efficient. Instead, the UPDATE statement can update values in multiple columns at the
same time.
To update data in multiple columns, specify the columns by separating each set clause with a comma. The values for
columns not specified in the set clause are not changed. The following is an example of updating multiple columns:
Example:
In this example, PRICE is updated to "216,000" and ORDERQTY is updated to "160" for the data for
CUSTOMER "61" and PRODNO "215" in the ORDER table.
UPDATE STOCKS. ORDER SET PRICE = 216000, ORDERQTY = 160
WHERE CUSTOMER = 61 AND PRODNO = 215
[Figure: Example of updating multiple columns]
3.2.2 Specifying a null value for data to be updated
To update data in a table to a null value, specify the keyword "NULL" instead of specifying a value in the set clause or
use an indicator variable. The following is an example of updating data to a null value:
Example 1:
In this example, the keyword "NULL" is specified. PRICE is updated to "216,000" and ORDERQTY is
updated to a null value for data for CUSTOMER "61" and PRODNO "215" in the ORDER table.
30