2 Sort Statements and Functions

The QFIND statement

The QFIND statement selects a subset of records from the data base thread.

QFIND item, relation, value [ ;expr ]

or:

QFIND item,"IN", value1, value2 [ ;expr]

or:

QFIND iitem,"MATCHES",regular expression

The parameters are:

item
A numeric expression specifying an (index) item number or string expression specifying (index) item name. The specified (index) item must be in the first dataset of the THREAD list.
relation
A string expression specifying the test to be performed on the given index item.
">" or "GT" - greater than

">=" or "GE" - greater or equal

"=" or "EQ" - equal

"<=" or "LE" - less or equal

"<" or "LT" - less than

MATCHES - matches regular expression

The "IN" relation will check for a value range starting at value1 and including up to value2.
If item specifies a search item, relation must be = or EQ.
value
Any string or numeric expression. See DBFIND for how to specify (index) item lookup values.
expr
Optional expression evaluated for each group of records in the thread. If the expression evaluates non-zero, the records are transfered into a workfile. See FIND statement for details.
regular expression
See next page.
Using a FIND statement, the first data set in THREAD will be read in sequential order. This may take a long time, depending on the number of entries in the dataset. QFIND allows quick access using either index items or search items.

QFIND will always add pointers to the workfile but not process pointers already in the workfile, which means it is possible to add the pointers of multiple subsets into a workfile using QFIND.

Specifying the conditional expression results in the same workfile as using a QFIND/FIND sequence but reduces overhead.

Here you will find some sample sequences using QFIND.

QFIND "ORDER-NO","=","1234" QFIND "TEST", ">=",15 QFIND "ACCOUNT","IN",10000,12000;Account_type=15 QFIND "CUS-MC","MATCHES","M[a-f]*"

Regular Expressions

Elements:

[
starting delimiter of character class expression
[
ending delimiter of character class expression
!
negation expression (only as 1st character of character class)
-
range expression (only inside a character class)
?
any character
*
any string (including the empty string)
#
numeric character (same as [0-9])
The backslash character (\) loses its special meaning within the delimiters, except in the following combinations:

\b - becomes backspace

\t - becomes tab

\r - becomes cr

\n - becomes lf

\f - becomes ff

\s - becomes space

The above combinations conform to the HP-UX standard, and are extremely practical.

Evaluation

An evaluation is only possible with index items, and then only for leading string segments. Index items without leading string segments cannot be accessed.

A regular expression must exactly describe the contents of the leading string segments. There is no implicit "*" at the end (as in DBFIND 2/3). For example, the value "AAA "(trailing space) does not match the search expression "AAA".

Examples of regular expressions:

A[BCD]
Index value starts with A, followed by either a B, C or D.
BOB?*
Index value starts with BOB, followed by at least one character.

Eloquence Sort Manual - 19 DEC 2002