Using the SORT and MERGE Statements
9.1 Sorting Data with the SORT Statement
In contrast, the WITH DUPLICATES IN ORDER phrase guarantees that records
with duplicate sort keys remain in the same sequence as they were in the input
file.
9.1.6 Specifying Non-ASCII Collating Sequences with the COLLATING
SEQUENCE IS Alphabet-Name Phrase
This phrase lets you specify a collating sequence other than the ASCII default.
You define collating sequences in the Environment Division SPECIAL-NAMES
paragraph. A sequence specified in the COLLATING SEQUENCE IS phrase of
the SORT statement overrides a sequence specified in the Environment Division
PROGRAM COLLATING SEQUENCE IS phrase.
Example 9–3 shows the alphabet name NEWSEQUENCE overriding the
EBCDIC-CODE collating sequence.
Example 9–3 Overriding the COLLATING SEQUENCE IS Phrase
ENVIRONMENT DIVISION.
OBJECT-COMPUTER.
FOO
PROGRAM COLLATING SEQUENCE IS EBCDIC-CODE.
SPECIAL-NAMES.
ALPHABET NEWSEQUENCE IS "ZYXWVUTSRQPONMLKJIHGFEDCBA"
ALPHABET EBCDIC-CODE IS EBCDIC.
.
.
.
PROCEDURE DIVISION.
000-DO-THE-SORT.
SORT SORT-FILE ON ASCENDING KEY
SORT-KEY-1
SORT-KEY-2
COLLATING SEQUENCE IS NEWSEQUENCE
USING INPUT-FILE GIVING OUTPUT-FILE.
9.1.7 Multiple Sorting
A program can contain multiple sort files, multiple SORT statements, or both
multiple sort files and multiple SORT statements. Example 9–4 uses two sort
files to produce two reports with different sort sequences.
Example 9–4 Using Two Sort Files
.
.
.
DATA DIVISION.
FILE SECTION.
SD
SORT-FILE1.
01
SORT-REC-1.
03
S1-KEY-1
PIC X(5).
03
FILLER
PIC X(40).
03
S1-KEY-2
PIC X(5).
03
FILLER
PIC X(50).
SD
SORT-FILE2.
01
SORT-REC-2.
(continued on next page)
Using the SORT and MERGE Statements 9–7
Содержание COBOL AAQ2G1FTK
Страница 22: ......
Страница 30: ......
Страница 94: ......
Страница 110: ......
Страница 146: ......
Страница 180: ......
Страница 194: ...Processing Files and Records 6 1 Defi...
Страница 300: ......
Страница 490: ......
Страница 516: ......
Страница 517: ......
Страница 530: ......
Страница 534: ......
Страница 590: ......
Страница 620: ......