Search conditions

A search condition specifies a condition that is true or false about a given row or group. When the condition is true, the row or group qualifies for the results. When the condition is false or unknown, the row or group does not qualify.

Read syntax diagramSkip visual syntax diagrampredicateAND1ORpredicate
Notes:
  • 1 Predicates across different tables must be connected by AND.

Description

The result of a search condition is derived by application of the specified logical operators (AND, OR) to the result of each specified predicate. If logical operators are not specified, the result of the search condition is the result of the specified predicate.

AND and OR are defined in the following table, in which P and Q are any predicates:

Table 1. Truth table for AND and OR
P Q P and Q P or Q
True True True True
True False False True
False True False True
False False False False

Example

For the following search condition, AND is applied first. After the application of AND, the OR operators could be applied in either order without changing the result. IMS can therefore select the order of applying the OR operators.

  PATNUM > ? AND AGE > ? OR HOSPCODE = ? OR HOSPNAME = ?
For COBOL only:
  PATNUM>:VAR1 AND AGE>:VAR2 OR HOSPCODE=:VAR3 OR HOSPNAME=:VAR4