• Aucun résultat trouvé

field-name ~ t~SS-EQUAL l

Dans le document Digital Equipment tion (Page 42-48)

~ LESS_EQUAL~ val-exp

True if the value offield name is less than or equal to the value expression.

field-name

~ ~~TWEEN~

val-exp-1 [AND] val-exp-2

True if the value offield name is between value expression 1 and value expression 2. Value expression 1 must be less than value expression 2.

(continued on next page)

Table 2-3: Relational Operators Preceded by Field Name (Cont.)

Boolean Expression Formats and Evaluations field-name {NOTBT } val-exp-1 [AND] val-exp-2

NOT BETWEEN

True if the value offield name is not between value expression 1 and value expression 2. Value expression 1 must be less than value expression 2.

field-name {CONT } val-exp CONTAINING

True if the value offield name contains the value expression as a substring.

field-name {NOTCONT } val-exp NOT CONTAINING

True if the value offield name does not contain the value expression as a substring.

field-name IN table-name

True if the value offield name is a code string in table name.

field-name NOT IN table-name

True if the value offield name is not a code table name.

ANYrse

True if the record stream is not empty.

Note that you can specify more than one value expression only after the =, EQ, EQUAL, and NOT EQUAL operators. DATATRIEVE displays an error message if you specify more than one value expression after any other operator:

DTR> SET NO PROMPT(@) DTR> READY YACHTS(@)

DTR> FIND A IN YACHTS WITH BEAM EQ 8, 10, 11(@) [70 records found]

DTR> FIND B IN YACHTS WITH BEAM NE 12, 13 t 14(@) Expected end of statelTlent, encountered II , I I

DTR>

In a Boolean expression, you can also use a prompting value expression or a vari-able name in place of a field name. You cannot, however, use any other value expressions in place of the field name. Generally, you use relational operators to compare field values to value expressions.

The order and value associated with numeric and alphanumeric characters is determined by the ASCII collating sequence. Appendix B lists printing ASCII characters and their corresponding values. Because lowercase letters have a higher ASCII value than uppercase letters, DATATRIEVE treats lowercase let-ters in character string literals as greater than uppercase letlet-ters.

In Boolean expressions using the CONTAINING relational operator, the com-parison of the value expression and the field value is not case-sensitive. That is,

uppercase letters and lowercase letters are treated the same, whether or not you enclose a character string literal in quotation marks.

The following examples show the use of relational operators to compare field val-ues to value expressions:

DTR> SET NO PROMPTOOl DTR> READY YACHTSOOl

DTR> FIND YACHTS WITH BEAM EQ 9 t 10 t 1400l

The IN relational operator compares the contents of a field with the code strings in a dictionary table. This comparison is useful for validating data you assign to fields or variables. You can, for example, write a record definition that uses a table to validate the data before it is stored:

DTR> DEFINE RECORD PHONE_REC USINGOOl DFN> 01 PHONE.OOl

DFN> 02 NAME PIC }< (20) • ool

DFN> 02 NUMBER PIC 9(7) EDIT_STRING IS >nO(->nO(}C(5D) DFN> 02 LOCATION PIC }«9).OOl

OF N > 02 0 EPA R T MEN T PIC >(}<ool

DFN> I.lALID IF DEPARTMENT IN DEPT_TABLE.(5D) DFN> ;(5D)

DTR>

The relational operator ANY checks whether a record stream is empty. This operator is useful for work with lists in hierarchical records. The record selection expression following ANY generally specifies the name of a list or sublist:

DTR> SET NO PROMPTOOl DTR> READY FAMILIESOOl

DTR> PRINT FAMILIES WITH ANY KIDS WITH AGE 2000l

(continued on next page)

JILL 20

JEROME RUTH 4 ERIC 32

CISSY 24

NANCY ..,..,

L..L.

MICHAEL 20

DTR> PRINT FAMILIES WITH ANY KIDS WITH KID_NAME CONT "RAL"m NUMBER KID

FATHER MOTHER KIDS NAME AGE

JIM ANN 2 URSULA 7

RALPH 3

DTR>

For more information on lists and hierarchies, see Chapter 15 of the DATATRIEVE-ll User's Guide.

2.3.2 Boolean Operators

DATATRIEVE recognizes four Boolean operators: AND, OR, BUT, and NOT.

With AND, OR, and BUT, you canjoin two or more Boolean expressions together to form a single Boolean expression. NOT allows you to reverse the value ofa Boolean expression.

When you link Boolean expressions with AND or BUT, the resulting expression is true only if all the Boolean expressions linked with AND or BUT are true.

When you link Boolean expressions with OR, the resulting expression is true if anyone of the Booleans linked with OR is true. When you precede a Boolean expression with NOT, the resulting expression is true ifthe,Boolean expression following NOT is false:

DTR> SET NO PROM PTm DTR> READY YACHTSm

DTR> PRINT YACHTS WITH BUILDER = "PEARSON" AND LOA 30m LENGTH

OVER

MANUFACTURER MODEL RIG ALL WEIGHT BEAM PRICE

PEARSON 30 SLOOP 30 8t320 08

DTR> FIND YACHTS WITH BUILDER "PEARSON" OR LOA [21 records found]

DTR> PRINT FAMILIES WITH FATHER NOT EQ "JIM" ANDm CON> ANY KIDS WITH AGE GT 3100

NUMBER KID

FATHER MOTHER KIDS NAME AGE

JEROME RUTH 4 ERIC 32

CISSY 24

NANCY 22

MICHAEL 20

HAROLD SARAH 3 CHARLIE 31

HAROLD 35

SARAH 27

30m

2.3.3 Compound Boolean Expressions

Use parentheses to group Boolean expressions into compound Boolean expressions:

DTR> SET NO PROMPTOO DTR> PRINT YACHTS WITHOO

CON> (MODEL "28" AND BU I LDER = "TANZER") ORm CON> (MODEL = "BALLAD" AND BUILDER = "ALBIN")m

MANUFACTURER MODEL

ALBIN BALLAD

TANZER 28

DTR>

RIG SLOOP SLOOP

LENGTH OI.JER

ALL WEIGHT BEAM 30 7,276 10 28 6,800 10

PRICE

$27,500

$17,500

DATATRIEVE evaluates Boolean expressions in parentheses before evaluating other Boolean expressions. If a Boolean expression contains Boolean operators as well as parentheses, DAT ATRIEVE evaluates the compound expression in the following order:

1. Expressions enclosed in parentheses 2. Expressions preceded by NOT 3. Expressions combined with AND 4. Expressions combined with OR

Table 2-4 shows how DATATRIEVE evaluates compound Boolean expressions.

Table 2-4: Compound Boolean Expressions

Expressions and Evaluations bool-1 AND bool-2 AND bool-3

True if all three Boolean expressions are true bool-1 AND (bool-2 OR bool-3)

True if Boolean 1 is true and either Boolean 2 or Boolean 3 is true (bool-1 AND bool-2) OR bool-3

True if Boolean 1 and Boolean 2 are true or if Boolean 3 is true (bool-1 AND bool-2) OR (bool-3 AND bool-4)

True ifboth Boolean 1 and Boolean 2 are true or ifboth Boolean 3 and Boolean 4 are true NOT (bool-1 OR bool-2) AND bool-3

True if both Boolean 1 and Boolean 2 are false and Boolean 3 is true

Dans le document Digital Equipment tion (Page 42-48)