Compaq AAQ2G1FTK Marine Radio User Manual


 
Using the SORT and MERGE Statements
9.1 Sorting Data with the SORT Statement
If you select Hypersort at DCL level, it will be in effect for a SORT statement
within a COBOL program as well.
Hypersort is the sole method available on Tru64 UNIX and Windows NT Alpha.
See Appendix A for the record and key size limits with Sort-32 and Hypersort.
9.2 Merging Data with the MERGE Statement
The MERGE statement combines two or more identically sequenced files and
makes their records available, in merged order, to an output procedure or to
one or more output files. Use MERGE statement phrases the same way you use
their SORT statement phrase equivalents. Note that the SORT phrases with
DUPLICATES IN ORDER INPUT PROCEDURE are not allowed with MERGE.
In Example 9–6, district sales data is merged into one regional sales file.
Example 96 Using the MERGE Statement
.
.
.
DATA DIVISION.
FILE SECTION.
SD MERGE-FILE.
01 MERGE-REC.
03 FILLER PIC XX.
03 M-PRODUCT-CODE PIC X(10).
03 FILLER PIC X(88).
FD DISTRICT1-SALES.
01 DISTRICT1-REC PIC X(100).
FD DISTRICT2-SALES.
01 DISTRICT2-REC PIC X(100).
FD REGION1-SALES.
01 REGION1-REC PIC X(100).
PROCEDURE DIVISION.
000-MERGE-FILES.
MERGE MERGE-FILE ON ASCENDING KEY M-PRODUCT-CODE
USING DISTRICT1-SALES DISTRICT2-SALES
GIVING REGION1-SALES.
STOP RUN.
9.3 Sample Programs Using the SORT and MERGE Statements
The programs in Example 9–7, Example 9–8, Example 9–9, Example 9–10,
Example 9–11, and Example 9–12 all show how to use the SORT and MERGE
statements.
Example 9–7 shows how to use the SORT statement with the USING and
GIVING phrases.
910 Using the SORT and MERGE Statements