VMS Help  —  RDML72  Statements  DECLARE_STREAM
    Declares the context of a record stream and thereby is
    able to associate a stream name with a RSE. This provides
    Oracle Rdb with the context needed to place the elements of the
    START_STREAM...FETCH...END_STREAM in a single programming module
    in any order.

1  –  Examples

    The following programs demonstrate the use of the DECLARE_STREAM
    statement to specify a record selection expression that limits
    the records in the stream to those with a value of less than ten
    thousand in the SALARY_AMOUNT field.

1.1  –  C Example

    #include <stdio.h>
    #define TRUE 1
    #define FALSE 0

    DATABASE PERS = FILENAME "PERSONNEL";

    DECLARE_STREAM sal USING SH IN SALARY_HISTORY
         WITH SH.SALARY_AMOUNT LT 10000;

    int end_of_stream;

    main()
    {
    READY PERS;
    START_TRANSACTION READ_WRITE;

        START_STREAM sal;

        FETCH sal
         AT END
           end_of_stream = TRUE;
        END_FETCH;

        while (! end_of_stream)
           {
           MODIFY SH USING
             SH.SALARY_AMOUNT = SH.SALARY_AMOUNT * (1.5);
           END_MODIFY;

           FETCH sal
             AT END
               end_of_stream = TRUE;
           END_FETCH;
           }

        END_STREAM sal;

        COMMIT;
        FINISH;
    }

1.2  –  Pascal Example

    program anycond (input,output);
    DATABASE PERS = FILENAME 'PERSONNEL';

    var
    end_of_stream : boolean;

    DECLARE_STREAM sal USING SH IN SALARY_HISTORY
         WITH SH.SALARY_AMOUNT LT 10000;

    begin
        READY PERS;
        START_TRANSACTION READ_WRITE;

        START_STREAM sal;

        FETCH sal
         AT END
           end_of_stream := TRUE;
        END_FETCH;

        while not end_of_stream do
         begin
           MODIFY SH USING
             SH.SALARY_AMOUNT := SH.SALARY_AMOUNT * (1.5);
           END_MODIFY;

           FETCH sal
             AT END
               end_of_stream := TRUE;
           END_FETCH;

         end;

        END_STREAM sal;
        COMMIT;
        FINISH;
    end.

2  –  Format

  (B)0
  DECLARE_STREAM  qqqqqwqq>qqqqqqqqqqqqqqqqqwqqqqqqqqqqqqqqqqqqqqqqk
                       mqq> handle-options qj                      x
                                                                   x
  lqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
  x
  mqqqqqqqqqqqqqqqq>  declared-stream-name qqqqq> USING qqqq> rse qq>

  (B)0handle-options =

  q> ( qwqqqqqq>  REQUEST_HANDLE  qqqqq>  var qqqqqqqqwq> ) q>
        tqqqqqq> TRANSACTION_HANDLE qqq>  var qqqqqqqqu
        mqqqqqq> REQUEST_HANDLE q> var q> , qqqqqqqk  x
          lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj  x
          mqqqq> TRANSACTION_HANDLE q> var qqqqqqqqqqqj

2.1  –  Format arguments

    declared-stream-name   A name you give the stream you declare.
                           The stream name must be a valid operating
                           system name.

    rse                    A record selection expression. A phrase
                           that defines the specific conditions
                           that individual records must meet before
                           Oracle Rdb includes them in a record stream.

    handle-options         A request handle, a transaction handle, or
                           both.

    REQUEST_HANDLE var     The REQUEST_HANDLE keyword followed by a
                           host language variable. A request handle
                           identifies a compiled Oracle Rdb request.
                           If you do not supply a request handle
                           explicitly, RDML associates a unique
                           request handle for the compiled request.

    TRANSACTION_HANDLE     The TRANSACTION_HANDLE keyword followed by
    var                    a host language variable. A transaction
                           handle identifies a transaction. If
                           you do not supply a transaction handle
                           explicitly, RDML uses the default
                           transaction handle.
Close Help