RDOHELP72.HLB  —  FOR  Examples
    Example 1

    Create a record stream with a FOR statement in RDO:

    RDO> START_TRANSACTION READ_ONLY
    RDO>
    RDO> FOR D IN DEPARTMENTS WITH D.DEPARTMENT_CODE = "SEUR"
    cont>  PRINT D.DEPARTMENT_CODE,
    cont>        D.DEPARTMENT_NAME,
    cont>        D.MANAGER_ID
    cont>  END_FOR
    RDO>
    RDO> COMMIT

    These statements:

    o  Create a record stream defined by a record selection
       expression

    o  Retrieve three field values from each record in that stream

    Example 2

    Create a record stream with the FOR statement in BASIC:

    &RDB&  START_TRANSACTION READ_ONLY

    &RDB&  FOR E IN EMPLOYEES CROSS
    &RDB&  S IN SALARY_HISTORY OVER EMPLOYEE_ID
    &RDB&       WITH E.EMPLOYEE_ID = EMPLOYEE_ID
    &RDB&       AND S.SALARY_END MISSING
    &RDB&    ON ERROR
                  GOTO 3000
    &RDB&    END_ERROR
    &RDB&    GET
    &RDB&       LAST_NAME = E.LAST_NAME;
    &RDB&       FIRST_NAME = E.FIRST_NAME;
    &RDB&       SALARY = S.SALARY_AMOUNT
    &RDB&    END_GET
    &RDB&  END_FOR

    &RDB&  COMMIT

    This program fragment retrieves the current salary for an
    employee specified by the value of the EMPLOYEE_ID variable.
    The example:

    o  Establishes a record stream consisting of the record in the
       EMPLOYEES relation with the ID number that the user supplies
       in the host language variable EMPLOYEE_ID, joined with the
       corresponding current SALARY_HISTORY record

    o  Points to an error-handling subroutine, in case of errors from
       Oracle Rdb

    o  Assigns the values from the FIRST_NAME and LAST_NAME fields
       of EMPLOYEES and the SALARY_AMOUNT field of SALARY_HISTORY to
       host variables
Close Help