how to use a similar "like"

hi all.
sorry for my english. i’m new of this forum and of natural/adabas.
I studied all the commands of natural, but I do not know if I can use a command similar the “like” SQL.
for example , i would try this

select * from employees where name like '%ric%'

i would find all employees with name similar ‘eric’ , ‘richard’ etc.
is possible in natural?
thanx

I hate to suggest it because it is terribly inefficient, but if your database is small, or you can use a descriptor to limit the scope of your search you can use the WHERE clause of the READ or FIND statement.


FIND EMPLOYEES WITH CITY = 'DARMSTADT'  
      WHERE FIRST-NAME = MASK (*'RIC')
  DISPLAY FIRST-NAME CITY                                               
END-FIND
END                                                                  

Output:


     FIRST-NAME              CITY        
-------------------- --------------------
                                          
RICHARD              DARMSTADT            
HEINRICH             DARMSTADT            
ULRICH               DARMSTADT            
                                     

Realize that Natural is case sensitive, so if your names are stored mixed case, this would not find Richard.

If you are basically forced to do something that requires reqading all, or most of, the records in a file, do not forget to Multifetch to improve performance.

As Jerome indicated, if you have a second criteria to limit the search, performance might not be too bad.

However, suppose there is no secondary criteria. You can still improve performance if the field you want to do “like” on is a descriptor field.

Using your example, you could do something like :

HI. HISTOGRAM EMPLOYEES NAME
IF NAME = MASK (*‘RIC’)
FIND EMPLOYEES WITH NAME = HI.NAME
:::::
END-FIND
END-IF
END-HISTOGRAM

Do not forget to to Multifetch the HISTOGRAM.

In a Natural logical condition which uses MASK, the asterisk (*) and percent sign (%) are synonyms.
So you “could” make your Natural look a little more SQL-like:
.
DEFINE DATA
LOCAL
1 EMPLOYEES VIEW OF EMPLOYEES
2 FIRST-NAME
2 NAME
2 CITY
1 #COUNT (I2) (HD=‘Count’)
END-DEFINE
*
READ EMPLOYEES
WHERE FIRST-NAME = MASK(%‘RIC’%)
ADD 1 TO #COUNT
DISPLAY #COUNT 3X EMPLOYEES
END-READ
END
.
** Please take note of Steve and Jerome’s comments about efficiency.

thank you all for your advice