Updated: 11 December 1998 |
OpenVMS User's Manual
Previous | Contents | Index |
Characters are sorted according to a collating sequence. For files that contain character data, you can use the /COLLATING_SEQUENCE=sequence qualifier to specify the collating sequence. The following table describes the collating sequence options.
Collating Sequence | sequence | Description |
---|---|---|
ASCII | ASCII | The default collating sequence for character data. The ASCII sequence orders numbers (0 to 9) first, then uppercase letters (A to Z), and then lowercase letters (a to z). |
EBCDIC | EBCDIC | Generates an output file that is ordered in EBCDIC sequence. The data remains in the ASCII representation. The EBCDIC sequence orders lowercase letters (a to z) first, then uppercase letters (A to Z), and then numbers (0 to 9). |
DEC Multinational character set | MULTINATIONAL |
The multinational collating sequence collates characters according to
the DEC Multinational character set (refer to Appendix B). In the
MULTINATIONAL character sequence, characters are ordered according to
the following rules:
|
National character set (NCS) | Collating sequence name |
The named collating sequence must be defined in an NCS library. For
more information, see the OpenVMS National Character Set Utility Manual. NCS collating sequences are
supported ` and not through specification files.
(The high-performance Sort/Merge utility does not support the National Character Set (NCS) collating sequences. Support for NCS collating sequences is deferred to a future OpenVMS Alpha release.) |
User-defined sequence | (sequence-string) |
Specifies a user-defined collating sequence. User-defined collating
sequences are supported only through specification files and not
through the command line interface.
(The high-performance Sort/Merge utility does not support user-defined collating sequences. Support for user-defined collating sequences is deferred to a future OpenVMS Alpha release.) |
Define a collating sequence by specifying a string of single or double
characters or ranges of single characters. (A double character is any
set of two single characters collated as if they were one character.
For example, "CH" can be defined to collate as "C".) This string should
be enclosed in parentheses.
You can also represent characters by their corresponding octal, decimal, or hexadecimal values using the radix operators: %O, %D, %X. You must observe the following rules when defining your collating sequence:
The following string defines a collating sequence in which the
double character LL collates as a single character between L and M.
|
Exercise caution when using the multinational collating sequence to sort or merge files for further processing. Sequence-checking procedures in most programming languages compare numeric characters. Normal sequence checking does not work because the multinational sequence is based on actual graphic characters, not the codes representing those characters. |
The following examples demonstrate the creation of user-defined collating sequences for use in specification files. See Section 11.7 for information about specification files.
/COLLATING_SEQUENCE=(SEQUENCE=ASCII,IGNORE=("-"," ")) |
252-3412 252 3412 2523412 |
/COLLATING_SEQUENCE=(SEQUENCE=("A"-"L","LL","M"-"R","RR","S"-"Z")) |
Batch jobs are programs or DCL command procedures that run
independently of your current session. If you are sorting large files,
consider submitting the Sort operation as a batch job because the sort
will require some time. See Chapter 18, Chapter 15, and
Chapter 16 for more information about batch jobs and command
procedures.
11.4.1 Command Procedures
Specify the SORT command in your command procedure just as you would write it on the screen. If your default directory does not contain the files to be sorted, explicitly set your default directory in the command procedure or include the directory in the command file specifications.
The following example submits the DCL command procedure SORTJOB.COM as a batch job. The text of the command procedure is shown following the command line:
$ SUBMIT SORTJOB |
! SORTJOB.COM ! $ SET DEFAULT [USER.PER] ! Set default to location of input files $ SORT/KEY=(POSITION:10,SIZE:15) EMPLOYEE.LST BYNAME.LST $ TYPE BYNAME.LST $ EXIT |
You can include the input records in the batch job by placing them after the SORT command with one record per line. Individual sort records can be longer than one line.
As with terminal input of records, specify the input file parameter as SYS$INPUT. Use the /FORMAT qualifier to specify the record size in bytes and the approximate file size in blocks. Approximately six 80-character lines equal one block.
The following example demonstrates including input records in a command procedure:
$ SUBMIT SORTJOB |
! SORTJOB.COM ! $ SET DEFAULT [USER.PER] $ SORT/KEY=(POSITION:10,SIZE:15) - SYS$INPUT- /FORMAT=(RECORD_SIZE:24,FILE_SIZE:10) - BYNAME.LST $ DECK BST 7828 MCMAHON JANE ADM 7933 ROSENBERG HARRY COM 8102 KNIGHT MARTHA ANS 8042 BENTLEY PETER BIO 7951 LOWELL FRANK $ EOD |
The MERGE command combines up to 10 (the high-performance Sort/Merge utility supports up to 12) sorted files into one ordered output file. You can merge input files that have the same format and have been sorted by the same key fields.
By default, Merge checks the sequence of the records in the input files to be sure they are in order. Specify the /CHECK_SEQUENCE qualifier if you want Merge to check the order. If you specify this qualifier and a record is out of order (for example, if you have not sorted one of the input files), Merge reports the following error:
%SORT-W-BAD_ORDER, merge input is out of order |
You can use the same qualifiers with the MERGE command as you use with the SORT command with two exceptions:
In the following example, the files BYNAME1.LST and BYNAME2.LST have already been sorted by customer name in ascending order. The command shown merges them:
$ MERGE BYNAME1.LST,BYNAME2.LST BYNAME3.LST |
The output file BYNAME3.LST contains all the records from both files, BYNAME1.LST and BYNAME2.LST, as shown in the following figure:
To merge files that are sorted using a specific key, you must specify the same key with the /KEY qualifier on the MERGE command line.
If you do not specify a key, Merge uses the default key described in Section 11.2.
In the following example, the files BILLING1.LST and BILLING4.LST were sorted by account number (/KEY=POSITION:5,SIZE:4,DECIMAL). To merge the files into the output file MAILING.LST, enter the following command line:
$ MERGE/KEY=(POSITION:5,SIZE:4,DECIMAL) - _$ BILLING1.LST,BILLING4.LST MAILING.LST |
The results of the merge are as follows:
If you want to merge files that you know are in sorted order, you can
prevent sequence checking by specifying the /NOCHECK_SEQUENCE qualifier.
11.5.2 Identical Key Fields
As with a Sort operation, when input files contain records with
identical key fields, Merge does not necessarily maintain the same
order in which the records had appeared in the input file. To maintain
the input order of records with identical keys, specify the /STABLE
qualifier on the MERGE command line. To retain only one copy of records
with identical keys, specify the /NODUPLICATES qualifier.
11.6 Entering Records from a Terminal
Records that you want to sort or merge do not have to be in a file. You can enter the records directly from the terminal as you enter the SORT or MERGE command. The following table describes the procedure:
Step | Task |
---|---|
1 |
Specify SYS$INPUT as the input file on the SORT or MERGE command line.
Use the input file qualifier /FORMAT to specify the size of the longest record, in bytes, and the approximate size of the input file, in blocks. |
2 |
Enter the input records on successive lines.
End each record by pressing Return. |
3 | Press Ctrl/Z to end the file. |
The following example demonstrates a Sort operation in which the input records to be sorted are entered directly from the terminal:
$ SORT/KEY=(POSITION:8,SIZE:15) - _$ SYS$INPUT/FORMAT=(RECORD_SIZE:24,FILE_SIZE:10) BYNAME.LST BST 7828 MCMAHON JANE [Return] ADM 7933 ROSENBERG HARRY[Return] COM 8102 KNIGHT MARTHA[Return] ANS 8042 BENTLEY PETER[Return] BIO 7951 LOWELL FRANK[Return] [Ctrl/Z] |
This sequence of commands creates the output file BYNAME.LST, which
contains the sorted records.
11.7 Using a Sort/Merge Specification File
Sort/Merge allows you to maintain sort definitions and to specify more complex sort criteria in specification files. (The high-performance Sort/Merge utility does not support specification files. Implementation of this feature is deferred to a future OpenVMS Alpha release.) You can use any standard editor, or the DCL CREATE command to create a specification file.
A Sort/Merge specification file allows you to:
After you complete the specification file, specify the file name using the /SPECIFICATION qualifier. The default file type for a specification file is .SRT.
Each command in the specification file should start with a slash (/) and continuation characters are not required if a command spans more than one line.
Many of the qualifiers used in the specification file are similar to the DCL qualifiers used in the Sort/Merge command line. Note, however, that the syntax of these qualifiers can be different. For example, the /KEY qualifier at DCL level has different syntax than the /KEY qualifier in the specification file. See Section 11.9.3 for a summary of the specification file qualifiers. |
Any DCL command qualifiers that you specify on the command line override corresponding entries in the specification file. For example, if you specify the /KEY qualifier in the DCL command line, Sort/Merge ignores the /KEY clause in the specification file.
Generally, there is no required order in which you must specify the qualifiers in a specification file. However, the order becomes significant in the following cases:
When you specify the FOLD, MODIFICATION, and IGNORE keywords with the /COLLATING_SEQUENCE qualifier, you should specify all MODIFICATION and IGNORE clauses before any FOLD clauses. See Section 11.9.3 for more information about the /COLLATING_SEQUENCE qualifier.
You can include comments in your specification file by beginning each comment line with an exclamation point (!). Unlike DCL command lines, specification files do not need hyphens (-) to continue the line.
Examples
! Specification file for sorting negative and positive data ! in ascending order ! /FIELD=(NAME=SIGN,POS:1,SIZ:1) (1) /FIELD=(NAME=AMT,POS:2,SIZ:4) (2) /CONDITION=(NAME=CHECK1, (3) TEST=(SIGN EQ "-")) /CONDITION=(NAME=CHECK2, (4) TEST=(SIGN EQ " ")) /INCLUDE=(CONDITION=CHECK1, (5) KEY=(AMT,DESCENDING), DATA=SIGN, DATA=AMT) /INCLUDE=(CONDITION=CHECK2, (6) KEY=(AMT,ASCENDING), DATA=SIGN, DATA=AMT) |
Figure 11-8 Output from Using a Specification File
/FIELD=(NAME=RECORD_TYPE,POS:1,SIZ:1) ! Record type, 1-byte /FIELD=(NAME=PRICE,POS:2,SIZ:8) ! Price, both files /FIELD=(NAME=TAXES,POS:10,SIZ:5) ! Taxes, both files /FIELD=(NAME=STYLE_A,POS:15,SIZ:10) ! Style, format A file /FIELD=(NAME=STYLE_B,POS:20,SIZ:10) ! Style, format B file /FIELD=(NAME=ZIP_A,POS:25,SIZ:5) ! Zip code, format A file /FIELD=(NAME=ZIP_B,POS:15,SIZ:5) ! Zip code, format B file /CONDITION=(NAME=FORMAT_A, ! Condition test, format A TEST=(RECORD_TYPE EQ "A")) /CONDITION=(NAME=FORMAT_B, ! Condition test, format B TEST=(RECORD_TYPE EQ "B")) /INCLUDE=(CONDITION=FORMAT_A, ! Output format, type A KEY=ZIP_A, DATA=PRICE, DATA=TAXES, DATA=STYLE_A, DATA=ZIP_A) /INCLUDE=(CONDITION=FORMAT_B, ! Output format, type B KEY=ZIP_B, DATA=PRICE, DATA=TAXES, DATA=STYLE_B, DATA=ZIP_B) |
|A|PRICE|TAXES|STYLE|ZIP| 1 2 10 15 25 |
|B|PRICE|TAXES|ZIP|STYLE| 1 2 10 15 20 |
/COLLATING_SEQUENCE=(SEQUENCE= ("AN","EB","AR","PR","AY","UN","UL", "UG","EP","CT","OV","EC","0"-"9"), MODIFICATION=("'"="19"), FOLD) |
16 NOV 1983 Communication Skills 05 APR 1984 Coping with Alcoholism 11 Jan '84 How to Be Assertive 12 OCT 1983 Improving Productivity 15 MAR 1984 Living with Your Teenager 08 FEB 1984 Single Parenting 07 Dec '83 Stress --- Causes and Cures 14 SEP 1983 Time Management |
14 SEP 1983 Time Management 12 OCT 1983 Improving Productivity 16 NOV 1983 Communication Skills 07 Dec '83 Stress --- Causes and Cures 11 Jan '84 How to Be Assertive 08 FEB 1984 Single Parenting 15 MAR 1984 Living with Your Teenager 05 APR 1984 Coping with Alcoholism |
/FIELD=(NAME=AGENT,POSITION:20,SIZE:15) /CONDITION=(NAME=AGENCY, TEST=(AGENT EQ "Real-T Trust" OR AGENT EQ "Realty Trust")) /DATA=(IF AGENCY THEN "Realty Trust" ELSE AGENT) |
/FIELD=(NAME=ZIP,POSITION:60,SIZE:6) /CONDITION=(NAME=LOCATION, TEST=(ZIP EQ "01863")) /KEY=(IF LOCATION THEN 1 ELSE 2) |
/FIELD=(NAME=ZIP,POSITION:60,SIZE:6) /CONDITION=(NAME=LOCATION, TEST=(ZIP EQ "01863")) /DATA=(IF LOCATION THEN "NORTH CHELMSFORD" ELSE "Outside district") |
/FIELD=(NAME=FFLOAT,POS:1,SIZ:0,F_FLOATING) /CONDITION=(NAME=CFFLOAT,TEST=(FFLOAT GE 100)) /OMIT=(CONDITION=CFFLOAT) |
/FIELD=(NAME=AGENT,POSITION:1,SIZE:5) /FIELD=(NAME=ZIP,POSITION:6,SIZE:3) /FIELD=(NAME=STYLE,POSITION:10,SIZE:5) /FIELD=(NAME=CONDITION,POSITION:16,SIZE:9) /FIELD=(NAME=PRICE,POSITION:26,SIZE:5) /FIELD=(NAME=TAXES,POSITION:32,SIZE:5) /DATA=PRICE /DATA=" " /DATA=TAXES /DATA=" " /DATA=STYLE /DATA=" " /DATA=ZIP /DATA=" " /DATA=AGENT |
AGENT ZIP STYLE CONDITION PRICE TAXES |
PRICE TAXES STYLE ZIP AGENT |
Previous | Next | Contents | Index |
Copyright © Compaq Computer Corporation 1998. All rights reserved. Legal |
6489PRO_025.HTML
|