Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
SORT-MERGE/XL General User's Guide: 900 Series HP 3000 Computer Systems > Chapter 4 Using MERGE/XL Interactively

Merging Files Using a Single Key

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

To combine the two files EMPLOYEE and NEWHIRES using a single key data item to create a new merged file named COMPANY, enter the following commands:

     :MERGE 

HP32214A.01.00 MERGE/3000 WED, JUN 3, 1987, 11:55 AM
© HEWLETT-PACKARD CO. 1986

>INPUT EMPLOYEE, NEWHIRES
>OUTPUT COMPANY
>KEY 1, 11
>END

The two input files (EMPLOYEE and NEWHIRES) and the resulting output file (COMPANY) are shown below. These files are merged according to last name, as indicated by the command >KEY 1, 11. Since no other specification was made, the merge is done alphabetically using the default ascending alphabetical order. Notice that the entries for ADAMS, CARLSON, CLARK, and MATHEWS are merged into a single list with the other employees in the file COMPANY.

The existing file EMPLOYEE contains the following data:

                     1         2         3         4 
123456789012345678901234567890123456789012345

1 ANDERSON CHARLES PRESIDENT 0247
2 ANDERSON CHARLES SALES REP 3456
3 ANDERSON MARY ACCOUNTANT 6345
4 CARLSON ROBERTA TREASURER 3586
5 FISHER TOM SHIPPING CLERK 7309
6 JOHNSON FRANCES RECEPTIONIST 7943
7 LANGE ROBERT ENGINEER 3235
8 SMITH HOWARD DESIGNER 6794
9 TAYLOR HEATHER SECRETARY 7272
10 ZIMMER ANDREW ENGINEER 5739

The newly created and sorted file NEWHIRES contains the following data:

                   1         2         3         4 
123456789012345678901234567890123456789012345

1 ADAMS JERROLD INSPECTOR 8044
2 CARLSON PETER BUYER 8043
3 CLARK STEVE ASSEMBLER 8046
4 MATHEWS EDDY PLANNER 8045

The file COMPANY, created as a result of merging the files NEWHIRES and EMPLOYEE, contains the following data:

                     1         2         3         4 
123456789012345678901234567890123456789012345

1 ADAMS JERROLD INSPECTOR 8044
2 ANDERSON CHARLES PRESIDENT 0247
3 ANDERSON CHARLES SALES REP 3456
4 ANDERSON MARY ACCOUNTANT 6345
5 CARLSON ROBERTA TREASURER 3586
6 CARLSON PETER BUYER 8043
7 CLARK STEVE ASSEMBLER 8046
8 FISHER TOM SHIPPING CLERK 7309
9 JOHNSON FRANCES RECEPTIONIST 7943
10 LANGE ROBERT ENGINEER 3235
11 MATHEWS EDDY PLANNER 8045
12 SMITH HOWARD DESIGNER 6794
13 TAYLOR HEATHER SECRETARY 7272
14 ZIMMER ANDREW ENGINEER 5739

Note that the two CARLSON entries are not listed alphabetically according to their first names. In case of a tie during a single key merge, the names are listed in the order in which the system receives them. Since ROBERTA CARLSON appeared in the file EMPLOYEE, which was the first file designated with the >INPUT command, that entry is listed first in the merged file. Doing a multiple key merge, as shown below, would arrange these entries in the proper order.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.