Library View Topics Framed Contents Revised Topics Previous Topic Next Topic Search Search ResultsPrevious Topic MatchNext Topic Match Notes List Notes Print Download No PDF Handheld DisconnectedHandheld ConnectedHelp

6.2.23 MERGE Statement



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_|_______________________________________________________|        |
   |                                                                                             |
   |_____________________________________________________________________________________________|
file-name-1
The name given in the SD entry that describes the records to be merged.

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.


X As an IBM extension, any file-names in a MERGE statement can be
X specified in the same SAME RECORD 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:



Previous Topic Next Topic © Copyright IBM Corp. 1991, 1998

IBM Library Server Copyright 1989, 2005 IBM Corporation. All rights reserved.





Return to library:   z/OS | z/OS.e | TPF | z/VSE | z/VM | IBM Hardware | IBM System z Redbooks
Glossary:   IBM terminology
Publications:   How to order publications
Readers:   Download IBM Library Reader | Download IBM Softcopy Reader | Download Adobe® Acrobat® Reader®
Library management:   Download IBM Softcopy Librarian
Contacts:   Contact z/OS


Adobe, the Adobe logo, Acrobat, the Acrobat logo, and Acrobat Reader are registered trademarks of Adobe Systems incorporated.