String function

In the DIRA2 query language there is a set of functions that work on the alphanumerical fields. The functions work on the whole field or on a portion of it. One can define the boundary of the character field that he needs with the notation: FIELD(start:end), like in the FORTRAN language. If you want to work on the second and third character of the field ACOD1 he can write ACOD1(2:3) to select these characters of the string.

The functions that work on string fields are:

The two functions MATCH and EMATC are used to find a substring in a field and return a logical value with the convention 0 = FALSE and -1 = TRUE.

The two arguments required in the function MATCH are: the field name and the substring that one searches for. If one needs the records that contain the string "STAR" in the field NOTE he can use the function in the following way:


With the function EMATC one can search for a regular expression in the catalogue fields. This function is an extension of the previous and accepts wild chart in the second argument.

The wild charts are:

CHART Comment
%Means a character
*Means a string
\Means: do not translate the following character

Then if one wants to find the records that, in the field NOTE, start with the string ABC, then are composed by two characters and end with GH he can use the statement:


Otherwise if one want to select the strings that start with ABC and end with GH without defining the number of characters in between he can use the statement:


If the characters * or % are those one wants to find in the field, the \ character avoids that they are used as wild charts. Then one can select all the records that start with % character using the statement:

EMATC( NOTE, " \%*")

Previous: Arithmetic operators and functions
Up: Query language
Next: Relational Expressions
Previous Page: Arithmetic operators and functions
Next Page: Relational Expressions