Sort Command [SO]. Robelle Suprtool 4.6.01, STExport, Suprlink
Reklama
Reklama
Sort Command [SO]
Specifies the next sort key via an Eloquence field, a table column name, or a field in
a self-describing file, or a Defined field. See "Key Command [K]" on page 128 for
sort keys specified by explicit byte position. Up to 20 Sort and Key commands can be specified per extract task. The first key entered is the major sort key.
SORT field [(subscript)] [DESCENDING]
(Default: Ascending order)
Field
The field specified must be an Eloquence data item that is a field of the input source, a selected item from the selected table, or a defined field, or a field from a selfdescribing file.
Subscript
If the field is a compound item (e.g., 2X25), the first sub-item is the default if no
subscript is specified. You can sort on any sub-item by specifying the subscript. For example,
>sort address(2) {sorts on 2nd sub-item}
Descending vs. Ascending Order
By default, sorts are done in ascending order. Descending specifies that the field is to be sorted in descending order.
Examples
The most common use of the Sort command is to specify a sort field of a database field. You may use the Key command to specify all sorts. We recommend that the
Sort command be used wherever possible. If the structure of your database changes, your Suprtool tasks still work if sort fields are specified with the Sort command:
>open oracle demo reader
>select * from sales {input from a table}
>sort account {primary sort field}
>sort purchased,desc {newest transactions first}
>output dsales {write the sorted records to a disc file}
>exit
In the next example we sort a disc file. We create a field using the Define command.
Rather than using the Key command, we use the Sort command to specify the sort field. If the disc file changes, only the Define command must be changed:
>input invent {input is from a disc file}
>define a,11,2,int {"A" is an integer that starts…}
>output outfile { at the 11th byte of Invent}
>sort a {sort the input records by the "A" field}
>exit
With the =dataset form of the Input command, we can have even greater flexibility to use the Sort command. We assume that the MPE file Mcust has the same structure as the m-customer dataset. We sort the file using the first of the two street addresses in m-customer:
Suprtool 4.6 for HP-UX: Suprtool Suprtool Commands
• 169
>base store
>input mcust=m-customer {same format as m-customer}
>sort street-address {a repeated field, but only}
>exit { the first address is used}
Notes
The Verify command shows all of the current command values and the Reset command cancels them. If you have not defined any sort fields before the Xeq or
Exit command, Suprtool performs a copy only, no sort.
Suprtool uses some temporary files during a sort. It creates the files in the directory specified by the TMPDIR environment. The size of the files will be equal to the size of the output file. If Suprtool runs out of disc space during a sort, you can try to specify another directory for TMPDIR.
170
• Suprtool Commands
Suprtool 4.6 for HP-UX: Suprtool
Atsisiųsti
Reklama