Previous Topic: Literal MaskingNext Topic: Evaluation of Logical Expressions


Multiple WITH Clauses

A WITH clause can contain multiple logical expressions joined by AND or OR. CA Dataquery selects the data meeting the conditions stated in each expression of the WITH clause.

If expressions within the WITH clause are joined by AND, CA Dataquery retrieves data which matches all of the stated expressions. If expressions within the WITH clause are joined by OR, CA Dataquery retrieves data which matches at least one of the stated expressions.

Example

The following example illustrates the use of AND in a WITH clause.

    FIND 10 CAI-CUST-REC ROWS
         WITH STATE = 'TX' AND
              CITY = 'DALLAS' AND
              PH-EXCH = '248'

The result of this FIND statement is a set of 10 customer rows for customers located in Dallas, Texas, and within the 248 phone exchange.

Example

In the example below, a WITH clause contains expressions joined by OR.

    FIND ALL CAI-CUST-REC ROWS
         WITH CITY = 'DALLAS' OR
              AREA-CD = '214'

When you execute this FIND statement, CA Dataquery selects all the customer rows for Dallas or customers who are located within the area code 214.

You can group logical expressions together within parentheses to change the standard order of evaluation. CA Dataquery evaluates expressions within parentheses before any other expressions. You can specify up to five levels of parentheses in a FIND statement.

If NOT precedes an entire WITH clause contained within parentheses, it reverses the meaning of the operators within the parentheses. However, if more WITH clauses follow the parentheses, the NOT operator does not negate them.

Example

The following two examples illustrate the use of NOT. In the first example, CA Dataquery selects those customer rows which do not have a state address of TX, NY or CA.

    FIND 10 CAI-CUST-REC ROWS
         WITH STATE NOT ='TX' 'NY' 'CA'

In the example below, CA Dataquery selects those personnel rows which do not have a state address of TX, NY or CA, but do have a city address which contains DA.

    FIND 10 CAI-CUST-REC ROWS
          WITH STATE NOT = 'TX ' 'NY' 'CA'
          AND CITY CONTAINING 'DA'