Merging Data With The Merge Statement; Sample Programs Using The Sort And Merge Statements; Using The Merge Statement - Compaq COBOL AAQ2G1FTK User Manual

Compaq computer accessories user manual
Table of Contents

Advertisement

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 9–6 Using the MERGE Statement
.
.
.
DATA DIVISION.
FILE SECTION.
SD MERGE-FILE.
01 MERGE-REC.
03 FILLER
03 M-PRODUCT-CODE
03 FILLER
FD DISTRICT1-SALES.
01 DISTRICT1-REC
FD DISTRICT2-SALES.
01 DISTRICT2-REC
FD REGION1-SALES.
01 REGION1-REC
PROCEDURE DIVISION.
000-MERGE-FILES.
MERGE MERGE-FILE ON ASCENDING KEY M-PRODUCT-CODE
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.
9–10 Using the SORT and MERGE Statements
PIC XX.
PIC X(10).
PIC X(88).
PIC X(100).
PIC X(100).
PIC X(100).
USING DISTRICT1-SALES DISTRICT2-SALES
GIVING REGION1-SALES.

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COBOL AAQ2G1FTK and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents