Getting Started with TRANSACT (32247-90007)
40 Chapter2
Using Character Mode I/O
Adding Data to a Dataset
2 The SET(DELIMITER) statement makes the field separator a slash rather
than the comma.
An example of a terminal session is shown in Figure 2-4.
Figure 2-4. Using a Programmer-Defined Field Delimiter
In the example above, we entered the data for the first customer one item at a time. The
data for the second customer was all entered on one line by separating the fields with
slashes. Note that Transact did not prompt for the data items that were stacked.
Let's run the program again to see what happens if the customer already exists.
Figure 2-5. Automatic Error Handling for a Duplicate Record
Transact provides us with an error message and restarts the Transaction at the point of
data entry. We can make the program more user friendly by checking to see whether the
customer exists before asking for the rest of the customer data. Then if an error occurs, all
the input will not have to be entered a second time. The program now looks like this:
CUST-NO> 303
NAME> John's Consulting
STREET-ADDR> 5489 El Camino
CITY-STATE> Santa Clara, Ca.
ZIPCODE> 95143
CUST-NO> 304/The Flower Shop/123 1st Street/San Jose, Ca./95125
CUST-NO> ]
EXIT/RESTART(E/R)?>
END OF PROGRAM
:
CUST-NO> 301 |
| NAME> New name |
| STREET-ADDR> New street |
| CITY-STATE> New city |
| ZIPCODE> 123 |
| *ERROR:DUPLICATE KEY VALUE IN MASTER (IMAGE 43,7,CUSTOMER)|
| CUST-NO> ] |
| EXIT/RESTART(E/R)?> |
| END OF PROGRAM |
| :