SORT

From Recital Documentation Wiki
Revision as of 16:10, 3 September 2010 by Yvonnemilne (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Purpose

Sort a table to another in a specific order


Syntax

SORT [<scope>] TO <.dbf filename> | (<expC>)

ON <field> [/A] [/D] [/C]

[FOR <condition>]

[WHILE <condition>]


See Also

DESCEND(), INDEX, SCOPE, SET INDEX


Description

The SORT command copies records from the currently selected table to another table in the specified sorted order. The file name can be substituted with a <expC>, enclosed in round brackets, which returns a valid filename. If no file extension is specified, '.dbf' is used. If no <scope> is specified, a SCOPE of ALL is used, unless the WHILE clause is specified, in which case it will default to REST. When you want to sort a table on multiple fields, then you should specify the most important field first.

/A /D /C

The /A, /D, and /C options can be specified for each sort field. The /A option sorts on the specified field in ascending order. The /D option sorts in descending order. The /C option can be used in conjunction with /A or /D to provide case insensitive sorting for character fields. For example, /AC causes Recital to treat all characters in the sort field as upper case. If no sort order is specified on a field, then /A is assumed.

FOR <condition>

If the FOR <condition> is specified, then only those records which satisfy the specified <condition> are processed.

WHILE <condition>

The WHILE <condition> is often used in conjunction with the SEEK command, and the REST <scope>, to restrict the range of records processed, and therefore reduce the time needed to sort the table.

If the currently selected table is indexed, then SORT processes the records in order of the master index. You cannot sort on logical fields. You cannot sort a table on expressions using the SORT command, this can be achieved using the INDEX command. The INDEX command is a much faster way of organizing a table. The DESCEND() function can be used with the INDEX command to create indexes in descending order.


Example

use patrons
sort to temp on date/a, event/ac, name/ac;
  for year(date)=1999


Products

Recital Server, Recital