Getting Started with TRANSACT (32247-90007)

46 Chapter2
Using Character Mode I/O
Adding Data to a Dataset
Figure 2-12. Changing a Key Field Value
Most of the time this program works correctly. However, if a problem like a system crash
occurs immediately after the delete of the old customer and just before the add of the new
customer, we force the user to add the complete customer record after system recovery.
We could modify this program to first add the new customer and then delete the old, but to
do this would require setting up a data item within the program to hold the value of the old
cust-no while we added the new one. We may do this in a later example, but another way to
do this is to use the special verb REPLACE, which does the hard work for us. The following
program shows how to use REPLACE to update a key field.
CUST-NO> 301
CUST-NO: NAME: STREET-ADDR: CITY-STATE: ZIPCODE:
301 The Cannery 123 Worthy Street Waltham, Ma. 46534
enter new cust-no> 303
*ERROR: ENTRY ALREADY EXISTS (IMAGE 1,16,CUSTOMER)
enter new cust-no> 302
NAME>
STREET-ADDR>
CITY-STATE>
ZIPCODE> 46533
CUST-NO> 302
CUST-NO: NAME: STREET-ADDR: CITY-STATE: ZIPCODE:
302 The Cannery 123 Worthy Street Waltham, Ma. 46533
enter new cust-no> 301
NAME>
STREET-ADDR>
CITY-STATE>
ZIPCODE>
CUST-NO> ]
EXIT/RESTART(E/R)?>
END OF PROGRAM
: