xHarbour Reference Documentation > Command Reference |
Selects the controlling index.
SET ORDER TO <nIndexPos> SET ORDER TO TAG <cIndexName> [IN <cIndexFile]
When no argument is passed or when the order is 0, all indexes remain open, but database navigation follows the physical order of records. That is, there is no controlling index.
The SET ORDER TO command selects the controlling index from a list of indexes open in the current work area. Indexes are opened with the SET INDEX command or the INDEX option of the USE command. The latter, however, is not recommended in a network environment.
The controlling index can either be specified by its ordinal position <nIndexPos>, or by its symbolic name <cIndexName>. The former is determined by the order in which indexes are opened (beginning with 1), while the latter is specified with the TAG option of the INDEX command when the index is created.
A controlling index affects the logical order of records in a work area. Relative database navigation with SKIP, GO TOP and GO BOTTOM follows this order, rather than the physical order how records are stored in a database.
The controlling index can be disabled temporarily by setting the index order to 0. This leaves all indexes open but database navigation follows the physical order.
See also: | DbSetOrder(), INDEX, IndexKey(), IndexOrd(), OrdNumber(), OrdSetFocus(), SEEK, SET INDEX, USE |
Category: | Database commands , Index commands |
Source: | rdd\dbcmd.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example creates three index files holding one index each. PROCEDURE Main USE Customer INDEX ON Upper(FirstName) TAG FName TO Cust01 INDEX ON Upper(LastName+Firstname) TAG LName TO Cust02 INDEX ON Upper(City) TAG City TO Cust03 SET INDEX TO Cust01, Cust02, Cust03 ? OrdNumber(),OrdKey() // result: 1 Upper(FirstName) SET ORDER TO TAG LName ? OrdNumber(),OrdKey() // result: 2 Upper(LastName+FirstName) SET ORDER TO 3 ? OrdNumber(),OrdKey() // result: 3 Upper(City) SET ORDER TO 0 ** No controlling index ? OrdNumber(),OrdKey() // result: 0 "" ** indexes are still open ? OrdKey(1) // result: Upper(FirstName) ? OrdKey(2) // result: Upper(LastName+FirstName) ? OrdKey(3) // result: Upper(City) CLOSE Customer RETURN
http://www.xHarbour.com