How to search by key with case insensitive on ISAM files


The START I/O statement allows you the use of the WHILE LIKE clause.
With this clause it is possible to search records that match a regular expression pattern.
With regular expressions, the possibilities of patterns to be used for search are considerably expanded.
In this article we will explore on how to use that clause and the regular expressions power, in order to search on ISAM keys in case insensitive mode.
The search pattern will include "(?i)" in the beginning, to indicate that the search will be case insensitive. The word (or substring) to search will be enclosed within ".*" (before and after) in order to search for that word in any position of the key.
For example:

   Move "(?i).*salt.*" to key-search-pattern
   Start customers-file
      while key is like key-search-pattern.
The above will allow the program to read all records (on a reading loop) that have the word "SALT" on any case combination in any position of the record key.

Attached you will find the full example of this.

When this sample is run, it produces the following output:
Creating file...
Searching: key
start Ok
aKey01    aaaaaaa
bKEY02    bbbbbbb
ckeY03    ccccccc
-----
Searching: SALT
start Ok
dsaLt034  ddddddd
eSaLt023  eeeeeee
fsaLT025  fffffff
-----
Searching: raY
start Ok
graY002F  ggggggg
hRaY003G  hhhhhhh
iray004D  iiiiiii
-----



Article ID: 294
Created: June 12, 2018
Last Updated: June 12, 2018
Author: Support KB Author

Online URL: https://support.veryant.com/phpkb/article.php?id=294