RDOHELP72.HLB  —  START_STREAM, Declared  Example
    The following program fragment shows how to use the DECLARE_
    STREAM statement with a declared START_STREAM statement. Note
    that although the START_STREAM, FETCH, and END_STREAM statements
    must come after the DECLARE_STREAM statement, they can be placed
    in any order within the program, as long as they are executed in
    the following order: START_STREAM, FETCH, END_STREAM.

    DATA DIVISION.
    WORKING-STORAGE SECTION.
                .
                .
                .

    &RDB&  INVOKE DATABASE FILENAME 'PERSONNEL'.

    &RDB&  DECLARE_STREAM EMPL_STREAM USING E IN EMPLOYEES
    -        SORTED BY E.LAST_NAME

       01  LAST_NAME  PIC X(14).
       01  FIRST_NAME PIC X(10).
       01  EMPLOYEE_ID PIC X(5).

    PROCEDURE DIVISION.
    INIT SECTION.
    INIT-PARAGRAPH.

    &RDB&  START_TRANSACTION READ_WRITE.

       PERFORM START-STREAM.

       PERFORM FETCH-STREAM.
       PERFORM GET-STREAM.
       DISPLAY LAST_NAME.
       DISPLAY FIRST_NAME.
       DISPLAY EMPLOYEE_ID.

       PERFORM FETCH-STREAM.
       PERFORM GET-STREAM.
       DISPLAY LAST_NAME.
       DISPLAY FIRST_NAME.
       DISPLAY EMPLOYEE_ID.

       PERFORM END_STREAM.

    &RDB&  FINISH.

       GOTO END-PROGRAM.

    END-STREAM.

    &RDB&  END_STREAM EMPL_STREAM.

    GET-STREAM.

    &RDB&  GET
    -       LAST_NAME = E.LAST_NAME;
    -       FIRST_NAME = E.FIRST_NAME;
    -       EMPLOYEE_ID = E.EMPLOYEE_ID;
    -      END_GET.

    FETCH-STREAM.

    &RDB&  FETCH EMPL_STREAM.

    START-STREAM.

    &RDB& START_STREAM EMPL_STREAM.

    END-PROGRAM.

       STOP RUN.
Close Help