RDOHELP72.HLB  —  FOR  segmented string FOR, More
    If you have invoked a database, you have the necessary privileges
    to use the FOR Statement with Segmented Strings.

    Oracle Rdb defines a special name to refer to the segments of a
    segmented string. This value expression is equivalent to a
    field name; it names the "fields" or segments of the string.
    Furthermore, because segments can vary in length, Oracle Rdb also
    defines a name for the length of a segment. The statement inside
    the segmented string FOR loop must use these names to refer to
    the segments of the string. These names are:

    RDB$VALUE          The value stored in a segment of a segmented
                       string
    RDB$LENGTH         The length in bytes of a segment

    Within a single context, such as the context of a single request, if
    an arithmetic expression contains the MISSING operator, the resulting
    expression will evaluate to MISSING. In the following example,
    A.FIELD_1 contains missing (unknown) values, and the query correctly
    interprets the values in A.FIELD_1 as missing (unknown), causing the
    expression A.FIELD_3 = VARIABLE + A.FIELD_1 to evaluate to MISSING:

    RDO> FOR A IN RELATION_A
    cont>  MODIFY A USING
    cont>  A.FIELD_3 = VARIABLE + A.FIELD_1
    cont>  END_MODIFY
    cont> END_FOR

    However, in nested queries that use multiple database requests, such
    as the following example, if B.FIELD_2 contains missing (unknown)
    values, the expression A.FIELD_3 = VARIABLE + B.FIELD_2 returns
    different results.  The second query (which begins with FOR A)
    retrieves a value, in this case the value defined as the field's
    MISSING_VALUE,  from B.FIELD_2 for its record selection expression
    (RSE).  However, because of RDO language limitations, the second query
    cannot use the fact that the field B.FIELD_2 has an unknown value and
    instead uses the missing value defined for the field with the DEFINE
    FIELD or CHANGE FIELD statement. Using this value for B.FIELD_2 instead
    of treating the value as unknown means that the A.FIELD_3 = VARIABLE +
    B.FIELD_2 expression does not evaluate to MISSING.

    RDO> FOR B IN RELATION_B
    cont> FOR A IN RELATION_A WITH A.FIELD_1 = B.FIELD_1
    cont>  MODIFY A USING
    cont>   A.FIELD_3 = VARIABLE + B.FIELD_2
    cont>  END_MODIFY
    cont> END_FOR
    cont> END_FOR

    The workaround is to use the SQL interface to Oracle Rdb. You can use
    the SQL indicator variables to detect the NULL attribute of the column
    (field) and therefore set the appropriate value for the column.
Close Help