Getting Started with TRANSACT (32247-90007)

42 Chapter2
Using Character Mode I/O
Adding Data to a Dataset
Updating Data in a Dataset
The programs that follow demonstrate three types of updating. These are changing data
for non-key items, changing data for key items, and deleting records.
Figure 2-8. Program to Update Data in a Dataset
3 LIST reserves space to hold the customer record. In the previous example
we let the PROMPT verb reserve space automatically as we went along.
LIST prepares a temporary storage area to receive data. When LIST is
used, DATA is used to prompt for data and receive the input. In these
simple programs, the two methods produce the same result. For more
complex data manipulation, setting up the temporary area before
prompting for data provides more flexibility.
5 Since the space has already been reserved, we use the DATA verb rather
than the PROMPT verb. Since we are updating existing records, we want
to verify that the cust-no that is entered already exists. If it does not exist,
an error message is generated and the prompt repeated.
CHECK=CUSTOMER does this for us.
6 SET(KEY) sets up the IMAGE key to be used to retrieve the customer
record.
8 DISPLAY displays the record. This gives the user a chance to see if this is
really the record he meant to update.
9 The SET option specifies that if the user presses [[RETURN]] in response
to any prompt, the original data for that item is retained. If we did not use
this option, then when the user pressed [[RETURN]] the item would
1 system ex11,base=orders(";");
2 set(delimiter) "/";
3 list(auto) customer;
4 level;
5 data cust-no,check=customer;
6 set(key) list (customer);
7 get customer;
8 display;
9 data(set) name:
street-addr:
city-state:
zipcode;
10 update customer;
11 end;