ENFORM User's Guide

Restricting Selected Information
Developing an ENFORM Query
3–30 058058 Tandem Computers Incorporated
Restricting Selected
Information
Restrict the information selected for the report or the FIND file by using the WHERE
clause. The WHERE clause allows you to define a condition or a set of conditions that
a data base record must meet before it is selected to contribute to the output record.
The WHERE clause in the following query causes ENFORM to select only those record
occurrences from employee whose salary field contains a value greater than 35000:
OPEN employee;
LIST empname, job, salary
WHERE salary GREATER THAN 35000;
Report:
EMPNAME JOB SALARY
------------------ -------------- ------
ROGER GREEN MANAGER 39500
JERRY HOWARD MANAGER 37000
JACK RAYMOND MANAGER 36000
THOMAS RUDLOFF MANAGER 38000
.
.
.
When a user variable is used in a WHERE clause to restrict the record occurrences
retrieved, the query processor always uses either the initial value (defined in a SET
statement) or the default value of zero (if no SET statement exists for the user variable)
for the value of the user variable. For example, consider the following query:
OPEN order;
DECLARE user-var;
SET user-var TO 10;
LIST ordernum,
user-var :=(ordernum + user-var)
WHERE user-var > 10;
This query always returns zero target records even though in every target record the
value of user-var (ordernum + 10 ) is greater than 10. ENFORM does not return any
target records because it uses the initial value (10) of user-var for the WHERE clause;
therefore user-var is always equal to 10. If the WHERE clause contains:
WHERE user-var = 10
all the records in order are returned because the value of user-var in the WHERE clause
is always equal to 10.