CDO$HELP.HLB  —  Expressions  relational_operators
    Relational operators specify the relationship of value
    expressions and perform the following kinds of operations:

    o  Compare a value with a range

    o  Match a pattern

    o  Test for missing fields

1  –  Description

    CDO uses mathematical relational operators and pattern testing
    relational operators in its conditional expressions.

    Mathematical relational operators are symbols that allow you
    to compare values. Pattern testing relational operators are
    keywords that allow you to test for a pattern of values. Unlike
    the mathematical relational operators, each pattern testing
    relational operator has its own unique syntax.

    Pattern Testing Relational Operators lists the pattern testing
    relational operators.

    Table 5-6 Pattern Testing Relational Operators

    Clause         Relational Operation

    BETWEEN        True if the first value expression is less than or
                   equal to the second value expression and greater
                   than or equal to the third value expression.

    CONTAINING     True if the string specified by the second string
                   expression is found within the string specified
                   by the first string expression. CONTAINING is not
                   case sensitive.

    MATCHING       True if the second value expression matches a
                   substring of the first value expression. MATCHING
                   is not case sensitive. It uses the following
                   wildcard characters:

                   o  Asterisk (*)- Matches any string of zero or
                      more characters

                   o  Percent sign (%)-Matches any single character
                      in that position

    STARTING       True if the first characters of the first string
    WITH           expression match the second string expression.
                   STARTING WITH is case sensitive.

    The logical operators AND, OR, and NOT let you compare two or
    more conditional expressions and optionally reverse the value of
    a conditional expression. The result of using a logical operator
    is another conditional expression.

    Mathematical Relational Operators lists the mathematical
    relational operators. These operators allow you to compare
    values. In all cases, if either value expression in a conditional
    expression is null, the value of the entire condition is null.

    Table 5-7 Mathematical Relational Operators

    Permitted
    Symbols    Relational Operation

    EQ or =    True if the two value expressions are equal.

    NE or <>   True if the two value expressions are not equal.

    GT or >    True if the first value expression is greater than the
               second.

    GE or >=   True if the first value expression is greater than or
               equal to the second.

    LT or <    True if the first value expression is less than the
               second.

    LE or <=   True if the first value expression is less than or
               equal to the second.

    Use either the alphabetic symbol or the mathematical symbol
    from the Permitted Symbols column, but do not use both when you
    specify a relational operator.

    See the documentation for the languages and products that use
    the repository to determine how that product evaluates character
    string literals. In some cases, character string literals are
    compared according to the ASCII collating sequence. Under ASCII,
    lowercase letters have a greater value than uppercase letters,
    and the letters near the beginning of the alphabet have a lesser
    value than those near the end.

    For products that compare character string literals according to
    the ASCII collating sequence, the following statements are true:

    o  a > A

    o  a < z

    o  A < Z

    To determine how CDO conditional expressions linked by logical
    operators are evaluated, see the documentation for the product
    that will be evaluating the conditional expression.

    See the documentation for languages and products that use the
    repository to determine how they evaluate character string
    literals.

                                 CAUTION

       The NOT operator applies to conditional expressions. Do not
       use the NOT operator and an equal sign instead of the NE
       or <> relational operators. The following statement is not
       valid:

                    WITH SALARY_AMOUNT IN S NOT = 30000

       Use one of the following alternatives:

                    WITH NOT (SALARY_AMOUNT IN S = 30000)
                    WITH SALARY_AMOUNT IN S NE 30000
                    WITH SALARY_AMOUNT IN S <> 30000

2  –  Examples

    1.LAST_NAME CONTAINING "ith"
      LAST_NAME NOT CONTAINING "son"

      In this example, if LAST_NAME has the string ith, CDO evaluates
      the CONTAINING clause as true; if LAST_NAME does not contain
      the string son, CDO evaluates the CONTAINING clause as true.

    2.SALARY_AMOUNT IN SH > 50000

      In this example, the conditional expression is true if the
      value in the SALARY_AMOUNT field is greater than 50,000.

    3.NOT SALARY_AMOUNT IN SH < 50000

      In this example, the conditional expression is true if the
      value in the SALARY_AMOUNT field is less than 50,000.

    4.DEFINE FIELD SEX
      VALID IF (SEX CASE_SENSITIVE EQ "M") OR (SEX CASE_SENSITIVE EQ "F").

      In this example, the DEFINE FIELD uses a case sensitive
      relational operator in the VALID IF clause to test whether the
      code to be entered in the field SEX is M or F. The conditional
      expression is true if the value for the field SEX is M or F
      (not m or f).

    5.LAST_NAME MATCHING "*ON"

      In this example, the conditional expression is true if the
      field LAST_NAME has ON as the last two letters. You can use
      this expression to find all records with LAST_NAME fields
      satisfying this condition.

    6.LAST_NAME IN FULL_NAME IN E MISSING

      In this example, the conditional expression is true if the
      LAST_NAME field in the FULL_NAME record of the EMPLOYEES
      relation is missing.

    7.LAST_NAME IN FULL_NAME IN E ALPHABETIC

      In this example, CDO evaluates the field expression as true
      when the LAST_NAME field from the FULL_NAME record of the
      EMPLOYEES relation is alphabetic.

    8.SALARY_AMOUNT NOT MISSING

      In this example, the conditional expression is true if the
      SALARY_AMOUNT field has a value that is not null.

    9.SALARY_AMOUNT MATCHING "4*"

      This example shows the matching clause used with numeric data
      types. In this example, the matching clause finds all the
      salaries that start with the number 4.

    10SALARY_AMOUNT BETWEEN 40000 AND 49999

      This example finds all salaries in a range by using the BETWEEN
      clause.
Close Help