Opens a stream that has been declared previously with the DECLARE_STREAM statement. A declared START_STREAM statement allows you to place the elements of the START_STREAM statement in any order within the program as long as they appear after the DECLARE_ STREAM statement and are executed in the order: START_ STREAM, FETCH, END_STREAM. Example RDO> START_STREAM EMP_STREAM
1 – Format
(B)0[m[4mSTART_STREAM[m qq> declared-stream-name qwqqqqqqq>qqqqqwqq> mq> on-error qj
1.1 – declared-stream-name
The name of the stream that you create. This name must be the same name you use in the associated DECLARE_STREAM statement.
1.2 – on-error
The ON ERROR clause. This clause specifies the action to be taken if an Oracle Rdb error occurs during the START_STREAM operation.
2 – More
You must have the Oracle Rdb READ access to the specified relations to use this statement. Because the declared START_STREAM statement and the undeclared START_STREAM statement both begin with the keyword START_ STREAM followed by a stream name, make sure you do not split the undeclared START_STREAM stream statement over two lines in such a way that Oracle Rdb will interpret it as a declared START_STREAM statement. For example, ending the first line of the following undeclared START_STREAM statement with the keyword USING indicates to Oracle Rdb that the statement is not complete: RDO> START_STREAM EMP_STREAM USING cont> E IN EMPLOYEES SORTED BY E.LAST_NAME You could also use a continuation character to indicate to RDO that the undeclared START_STREAM statement is not complete. Without the continuation character, the following declared START_ STREAM statement could be interpreted as a declared START_STREAM statement: RDO> START_STREAM EMP_STREAM - cont> USING E IN EMPLOYEES SORTED BY E.LAST_NAME Because an association is made between the DECLARE_STREAM statement and the START_STREAM statement by the declared stream name clause in both statements, it is not permissible to specify the RSE in the declared START_STREAM statement. Instead, include the RSE in the DECLARE_STREAM statement. You can issue several declared START_STREAM statements in a module. As long as you use the same declared stream name, they will all refer to the same stream. RDO does not allow a record stream from which data values cannot be fetched by DBKEY (views that retrieve values from streams defined using the SQL GROUP BY or UNION clauses) to be declared or started. Such attempts produce the following exception: VWNOFETCH view 'view-name' cannot be fetched within a stream
3 – 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.