jBASE supports a limited mechanism whereby jQL commands such as SORT or SELECT can automatically use any valid secondary index to reduce the search time. This does not involve creating a specific DICTionary item. If for any reason the index cannot be found, or is not up to date (e.g. awaiting a rebuild-index command) then the jQL command will ignore the secondary index and retrieve the information in the usual manner.
At present only a single search pattern can be used in a jQL command. As an example a file will have an index built onto attribute 23 , the customer last name like this:
jsh->create-index CUSTOMERS lastname BY 23
Let us assume there exists a DICTionary definition called LASTNAME that looks like this:
LASTNAME
001 A
002 23
003 Customer Lastname
004
005
006
007
008
009 T
010 20
Now let us assume we try to select all customers in that file whose last name equals "COOPER]". The jQL statement would look like this:
jsh-> SELECT CUSTOMERS IF LASTNAME EQ "COOPER]"
In this example the index definition is "out of sync", awaiting a rebuild-index command to be performed. Therefore the SELECT would achieve the result by looking through the entire file. Now let us run the rebuild-index command as:
jsh-> rebuild-index CUSTOMERS lastname
If we now re-execute the SELECT command, then instead of scanning through the entire CUSTOMERS file, it will look through the index definition "lastname" instead and will therefore execute considerably quicker.