



The MERGE statement combines two or more identically sequenced files (that is, 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 output file.
A MERGE statement can appear anywhere in the Procedure Division except in a Declarative Section.
___ Format __________________________________________________________________________________
| |
| <__________________________________________________ |
| <_____________ | |
| >>__MERGE__file-name-1____ ____ __ _ASCENDING__ __ _____ ____data-name-1_|_|______________> |
| |_ON_| |_DESCENDING_| |_KEY_| |
| |
| >__ __________________________________________________ __USING__file-name-2_______________> |
| |_ ___________ __SEQUENCE__ ____ __alphabet-name-1_| |
| |_COLLATING_| |_IS_| |
| |
| <_____________ |
| >____file-name-3_|________________________________________________________________________> |
| |
| >__ _OUTPUT PROCEDURE__ ____ __procedure-name-1__ _______________________________ _ _____>< |
| | |_IS_| |_ _THROUGH_ __procedure-name-2_| | |
| | |_THRU____| | |
| | <_____________ | |
| |_GIVING____file-name-4_|_______________________________________________________| |
| |
|_____________________________________________________________________________________________|
No file-name can be repeated in the MERGE statement.
No pair of file-names in a MERGE statement can be specified in the same SAME AREA, SAME SORT AREA, or SAME SORT-MERGE AREA clause.
When the MERGE statement is executed, all records contained in file-name-2, file-name-3,..., are accepted by the merge program and then merged according to the key(s) specified.
Subtopics:
© Copyright IBM Corp. 1991, 1998
Adobe, the Adobe logo, Acrobat, the Acrobat logo, and Acrobat Reader are registered trademarks of Adobe Systems incorporated.