Welcome to jBASE's new documentation site! Many answers to your questions can be found by searching the Knowledgebase or viewing the jBASE Documentation. We also have a Google Group for peer discussion about jBASE. If you are unable to find the information you are looking for, jBASE Support will be glad to assist in resolving your technical problems. Enjoy and please provide comments and feedback .

How can we help you?



This command allows you to select or count a list of record keys. It is called as:

query-index -Options filename index_name
query-index -Options filename {IF/WITH} iname {Op} "startpos"
query-index -Options filename {IF/WITH} iname {Op} "startpos" {AND} {Op} "endpos"

where Op can be: 

  • LT < less than ,
  • LE <= less than or equal 
  • GT > greater than 
  • GE >= greater than or equal to 

and Options can be: 

COUNT the records (default is to select records)
Indexes used restricted to approx. nn indexes
Match algorithm - type is: "REGEXP" or "JQL" or "DEFAULT"
Record count restricted to approx. nn records

It is important to note that file updates that cause a change to an index will wait for a query-index to complete. 

The first structure of the query-index command allows for selection of all record keys sorted by the index definition. For example, to select all customers sorted by their last name:

jsh->query-index CUSTOMERS lastname

The second structure of the query-index command allows for specifying a single conditional parameter, making this query less than, greater than etc. to the parameter. If LT,GT,etc are unspecified, it defaults to equals. For example, select all customers whose name begins with "KOOP"


Note that in this case the double quotes will be ignored , as would single quotes. The IF token is a throwaway token, and is used simply for clarity. WITH can also be used to the same effect.

Another example is to select all customers whose date of birth is before 25 July 1956


The third structure of the query-index command allows for specifying a range of values. This means the operators must be either GT or GE followed by LT or LE. If the operators are not specified the command defaults to GE and LE.

Example: Count all the customers whose last order was placed between 19-DEC-1996 and 23-DEC-1996 inclusively.

jsh->query-index -c CUSTOMERS IF order.date >= "19-DEC-1996" and <= "23-DEC-1996"

Option -c means a count of record keys is done instead of producing a select list.

Option -m allows the pattern matching algorithm to be changed :

When the command is performing its test, it does so using a simple string or numeric test. To make the test more akin to say a jQL command, then one would use the -mJQL option. For example, selecting all customers whose name ends in PATEL:

jsh-> query-index -mJQL CUSTOMERS IF lastname EQ "[PATEL"

Similarly -mREGEXP to use a pattern matching algorithm called "Regular Expressions". This allows complicated patterns to be searched for. See the "Regular Expressions" chapter in this document. As an example, the following command will select all products whose description begins with the letter A is followed by any number of characters before the sequence PIPE is found:

jsh-> query-index -mREGEXP PRODUCTS IF description EQ "^A.*PIPE"

Option -i can be used to restrict the number of indexes used to create the list of record keys. This can be useful to restrict a search to a smaller subset.

Option -r is similar to -i except it restrict the number of record keys.

Was this article helpful?