xHarbour Reference Documentation > Command Reference |
Opens one or more index files in the current work area.
SET INDEX TO [<cIndexFile,...>] [ADDITIVE]
The SET INDEX command opens index files in the current work area. The first index file specified becomes the controlling index. If the file contains multiple indexes, the first index in the multiple index file becomes the controlling index.
All open indexes are closed when SET INDEX is issued, unless the ADDITIVE option is used.
After the indexes are opened, the record pointer is positioned on the first logical record of the controlling index, unless the ADDITIVE option is used. ADDITIVE neither changes the controlling index nor the record pointer.
The command SET ORDER can later be used to change the controlling index.
See also: | CLOSE, DbClearIndex(), DbSetIndex(), INDEX, OrdListAdd(), REINDEX, SET ORDER, 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 ? IndexOrd(), IndexKey() // result: 1 Upper(City) SET INDEX TO Cust01, Cust02 ? IndexOrd(), IndexKey() // result: 1 Upper(FirstName) SET ORDER TO TAG LName ? IndexOrd(), IndexKey() // result: 2 Upper(LastName+FirstName) SET INDEX TO Cust03 ADDITIVE ? IndexOrd(), IndexKey() // result: 2 Upper(LastName+FirstName) SET ORDER TO 3 ? IndexOrd(), IndexKey() // result: 3 Upper(City) CLOSE Customer RETURN
http://www.xHarbour.com