CDO$HELP.HLB  —  fld-properties  COMPUTED_BY, Description
    The COMPUTED BY field property evaluates an expression, allowing
    a product that uses CDO to determine the value of a field at
    runtime.

    The expression must be a valid CDO expression. CDO checks the
    expression for correct syntax and field references.

    The product must be able to interpret the CDO expression.

    When you specify a conditional expression in the COMPUTED BY
    field property, you can define a field that is equivalent to a
    COBOL level 88 condition. The computed by expression must be in
    one of the following forms:

    o  if [name EQ literal1] THEN 1 ELSE 0

    o  if [(name GE literal1 AND name LE literal2) OR (name GE
       literal3 AND name LE literal4)]... THEN 1 ELSE 0

    Use NULL IF to substitute NULL when two value expressions are
    equal.

    Use COALESCE to return the first non-NULL value from a series of
    value expressions.

    There is a limited subset of valid COMPUTED BY fields that are
    acceptable in COBOL syntax for inclusion through the COPY FROM
    DICTIONARY clause. They have the following format:

    COMPUTED BY IF expression THEN 1 ELSE 0

    Where expression is:

    {                                                   }
    {            { number }                             }
    { fld-name = {        }                             }
    {            { string }                             }
    {                                                   } OR ...
    {             { number }                 { number } }
    { fld-name GE {        } AND fld-name LE {        } }
    {             { string }                 { string } }
    {                                                   }

    For example, the following COMPUTED BY fields are defined:

    DEFINE FIELD Y_TRUE
         COMPUTED BY IF (Y = "TRUE") THEN 1 ELSE 0.
    DEFINE FIELD Z_NULL
        COMPUTED BY IF (Z = 0) THEN 1 ELSE 0.
    DEFINE FIELD W_ALPHABETIC COMPUTED BY
        IF ((W GE "A") AND (W LE "Z")) OR ((W GE "a") AND (W LE "z"))
        THEN 1 ELSE 0.
    DEFINE FIELD X_3_DIGITS
        COMPUTED BY IF (X GE 100) AND (X LE 999) THEN 1 ELSE 0.

    They are translated as the following COBOL level 88 conditions:

    02 Y ...
       88 Y_TRUE VALUE IS "TRUE".
    02 Z ...
       88 Z_NULL VALUE IS 0.
    02 W ...
       88 W_ALPHABETIC VALUES ARE "A" THRU "Z", "a" THRU "z".
    02 X ...
     88 X_3_DIGITS VALUES ARE 100 THRU 999.

                               RESTRICTION

       The COMPUTED BY field property can reference only one field.
       The fld-name parameter must be the same field name in all
       instances. When included in COBOL, the COMPUTED BY field
       will be translated as a level 88 condition associated with
       the field that was referenced.
Close Help