Library /sys$common/syshlp/DTRHELP.HLB  —  Commands Statements Clauses, REDUCE Statement, Examples
       The following example searches through the YACHTS domain and, for
       each type of RIG, lists the prices of all boats that cost over
       $35,000:

       DTR> DEFINE PROCEDURE RIG_QUERY
       DFN> FIND YACHTS
       DFN> REDUCE CURRENT TO RIG
       DFN> PRINT SKIP, RIG, ALL PRICE OF YACHTS WITH
       DFN>      PRICE GT 35000 AND RIG = Y.RIG OF Y IN CURRENT
       DFN> END_PROCEDURE
       DTR> :RIG_QUERY

        RIG    PRICE

       KETCH  $36,951
              $51,228
              $41,350
              $39,500
              $36,950
              $54,970
              $50,000
              $80,500

       MS     $35,900

       SLOOP  $37,850
              $39,215
              $37,850
              $48,490

       DTR>

       Note the format of this PRINT statement:

       PRINT print-list, ALL print-list OF rse-1 OF rse-2

       RSE-1 is: ALL PRICE OF YACHTS WITH PRICE GT 35000 AND RIG = Y.RIG
       RSE-2 is: Y IN CURRENT

       RSE-2 controls the printing of the first print list (SKIP, RIG)
       and RSE-1 controls the printing of the second print-list (PRICE).

       You can use the REDUCED TO statement to match values of a date
       field for the month and year.

       The following example uses the domain PAYABLES described in
       the DEC DATATRIEVE User's Guide. Records in PAYABLES have the
       same TYPE field as in YACHTS, a date field (INVOICE_DUE), and a
       field for wholesale price (WHSLE_PRICE). The example shows how to
       display the records in PAYABLES where INVOICE_DUE is later than
       January 1, 1983. The records are separated according to the month
       they are due. The REDUCED TO statement is used to identify the
       unique values of month and year for PAYABLES. Then the records
       are searched for matches to these values.

       DTR> SHOW MONTHLY_RPT
       PROCEDURE MONTHLY_RPT
       READY PAYABLES
       FIND PAYABLES WITH INVOICE_DUE AFTER "JAN 1, 1983"
       REDUCE CURRENT TO FORMAT INVOICE_DUE USING YYNN
       FOR A IN CURRENT
          BEGIN
            PRINT SKIP, "Invoices Due for the Month of"|||
              FORMAT A.INVOICE_DUE USING M(9), SKIP
            FOR PAYABLES WITH FORMAT INVOICE_DUE USING YYNN =
              FORMAT A.INVOICE_DUE USING YYNN SORTED BY INVOICE_DUE
            PRINT INVOICE_DUE, TYPE, WHSLE_PRICE
          END
       END_PROCEDURE

       DTR> :MONTHLY_RPT

       Invoices Due for the Month of January

       INVOICE                         WHSLE
         DUE      VENDOR   ITEM_TYPE   PRICE

        1/02/83 ALBERG     37 MK II   $28,500
        1/25/83 SALT       19          $4,850
        1/31/83 AMERICAN   26-MS      $15,150

       Invoices Due for the Month of February

        2/12/83 WINDPOWER  IMPULSE     $1,500
          .        .        .            .
          .        .        .            .
          .        .        .            .

       Invoices Due for the Month of April

        4/01/83 BAYFIELD   30/32      $13,000
        4/01/83 IRWIN      37 MARK II $29,999
        4/15/83 ALBIN      VEGA       $14,250

       DTR>
Close Help