COBOL/400 Language Help


MERGE Statement

Description
The MERGE statement combines two or more identically sequenced files (files that have already been sorted according to an identical set of ascending/descending keys) on one or more keys and makes records available, in merged order, to an output procedure or an output file. MERGE may appear anywhere in the Procedure Division except in a Declarative Section.

It is not necessary to sequence input files prior to a merge operation.

->->-MERGE file-name-1---------------------------------------->
 
    *------------------------------------------------*
    +                                  *-----------* +
    V                                  V           + +
->---*----*--*-ASCENDING--*---*-----*---data-name-1-*-*------>
    *-ON-*  *-DESCENDING-*   *-KEY-*
 
 
->--*------------------------------------------------*------->
   **---------*--SEQUENCE--*----*---alphabet-name-1-*
    *COLLATING*            *-IS-*
 
                    *-----------*
                    V           +
->-USING file-name-2 file-name-3-*--------------------------->
 
->--*-OUTPUT PROCEDURE-----*----*-procedure-name-1----------->1
   +        *-----------* *-IS-*
   +        V           +
   *-GIVING file-name-4-*----------------------------------->2
 
1->-*-------------------------------*-*----------------------><-
   *-*-THROUGH-*-procedure-name-2--* +
     *-THRU----*                     +
2->-----------------------------------*
 


[ Top of Page | Previous Page | Next Page | Table of Contents ]