SORT-MERGE/XL General User's Guide
> Chapter 6 SORT-MERGE/XL CommandsKEY |
||||||||||||||||||||
|
SYNTAX>K[EY] keyspec1 [; keyspec2]...[; keyspecN] PARAMETERS
Indicates the records are to be arranged in descending order. If this parameter is not specified, the records are arranged in the default ascending order. Display Positive Negative No Sign Digit 0 { (%173 $78) } (%175 $7D) 0 (%60 $30) 1 A (%101 $41) J (%112 $4A) 1 (%61 $31) 2 B (%102 $42) K (%113 $4B) 2 (%62 $32) 3 C (%103 $43) L (%114 $4C) 3 (%63 $33) 4 D (%104 $44) M (%115 $4D) 4 (%64 $34) 5 E (%105 $45) N (%116 $4E) 5 (%65 $35) 6 F (%106 $46) O (%117 $4F) 6 (%66 $36) 7 G (%107 $47) P (%120 $50) 7 (%67 $37) 8 H (%110 $48) Q (%121 $51) 8 (%70 $38) 9 I (%111 $49) R (%122 $52) 9 (%71 $39) DISCUSSIONSORT-MERGE/XL sorts keys contain binary, ASCII, or EBCDIC data according to an eight-bit binary sequence (00000000 to 11111111), except for the type CHARACTER, which is sorted according to the collating sequence of the native language specified in the >LANGUAGE command. Refer to Appendix C for further information on native language collating. Other types of data (integer, real, etc.) are sorted according to the standard arithmetic relational operators. For example, 2 is greater than -5. The keys can contain alphabetic, numeric, or alphanumeric (alphabetic and numeric intermixed) data. They can be contiguous or separated in a record or they can overlap each other, provided the collating sequence is not altered, or a user-defined sequence is not used. An entire record can be considered as a single key. As explained in Chapter 3, each >KEY command can specify one or more key fields which are separated by semicolons. Multiple key fields can also be specified with more than one >KEY command. All the key fields do not have to be specified in the same command. The most significant key is called the major key and is declared first in the command. Other keys have decreasing significance according to their relative positions following the major key. They are compared if a comparison or more significant keys results in an equal condition. Consider a file containing the records of all the students in a high school. Each record can contain information such as name, address, grade level, grades in individual courses, as well as data on other information. You can specify the order in which the records are sorted. If the first record is of the student with the highest grades (A) in English and Math, you specify an ascending order. If the major key is English and the other key is Math, the data in the Math fields are compared only if the data in the English fields are the same. The sorting order is specified in the same commands that specify the keys. An order is declared for each key. This order does not have to be the same for all the keys in a record. For example, in the high school file, you can declare English (major key) with an ascending order and Math with a descending order. Note even if the sorting order is different for each key, only one collating sequence is used for a particular operation. EXAMPLESThe following examples show using the >KEY command and some of its options: >KEY 10, 5BYTE key of length 5 starting in position 10, sorted in the ascending order. >KEY 20, REALREAL key of length 4, starting in position 20 and sorted in an ascending order since four is the default for the length parameter when the key data type is REAL. >KEY 30, 20, INT, DESC20-byte integer key starting in position 30, and sorted in a descending order. For information on making corrections to the key specification, refer to the >RESET command in this chapter. ADDITIONAL DISCUSSIONRefer to the >RESET command in this chapter.
|