# Indexes and JQL Commands

Updated: 10/19/2021, 9:29:48 PM
Created: 10/19/2021, 9:29:48 PM
Last Updated By: Kevin Munoz
Read Time: 1 minute(s)

Tags: file indexing jql

# Description

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
1

Assuming 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
1
2
3
4
5
6
7
8
9
10
11

and there is need to select all customers in that file whose last name equals "COOPER]".

The jQL statement would be :

jsh -->SELECT CUSTOMERS IF LASTNAME EQ "COOPER]"
1

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. If the rebuild-index command is run as:

jsh -->rebuild-index CUSTOMERS lastname
1

and the SELECT is re-executed , then instead of scanning through the entire CUSTOMERS file, it will look through the index definition "lastname" instead and will therefore execute considerably quicker.

Back to Indexes