The MERGE statement combines two or more identically sequenced files on a set of specified keys, and during the process makes records available, in merged order, to an output procedure or to an output file.
A MERGE statement may appear anywhere in the Procedure Division except in the declaratives portion.
file-name-1 must be described in a sort-merge file description entry in the Data Division.
data-name-1 may be qualified. data-name-1 must reference either a record-name associated with file-name-1or a data item in a record associated with file-name-1.If more than one record description entry is associated with file-name-1, the data items referenced by different specifications of data-name-1 need not all be associated with the same record description entry.
The data item referenced by data-name-1 must not be a group item that contains a variable-occurrence data item.
file-name-2, file-name-3, and file-name-4 must be described in a file description entry in the Data Division.
No two files specified in any one MERGE statement may reside on the same multiple file reel (or reels).
File-names must not be repeated within the MERGE statement.
The words THRU and THROUGH are synonymous.
No pair of file-names in a MERGE statement may be specified in the same SAME AREA, SAME RECORD AREA, SAME SORT AREA or SAME SORT-MERGE AREA clause.(See the I-O-CONTROL paragraph.)
If the file referenced by file-name-1 contains variable-length records, the size of the records contained in the files referenced by file-name-2 and file-name-3 must not be shorter than the shortest record nor longer than the longest record described for file-name-1. If the file referenced by file-name-1 contains fixed-length records, the size of the records contained in the files referenced by file-name-2 and file-name-3 must not be longer than the longest record described for file-name-1.
If the GIVING phrase is specified and the file referenced by file-name-4 contains variable-length records, the size of the records contained in the file referenced by file-name-1 must not be shorter than the shortest record nor longer than the longest record size specified for file-name-4. If the file referenced by file-name-4 contains fixed length records, the size of the records contained in the file referenced by file-name-1 must not be longer than the fixed record size specified for file-name-4.
The general rules applying to the MERGE statement are as follows:
These implicit functions are performed such that any associated USE procedures are executed; however, the execution of such a USE procedure must not cause the execution of any statement manipulating the file referenced by, or accessing the record area associated with, file-name-4.On the first attempt to write beyond the externally defined boundaries of the file, any USE procedure specified for the file is executed; if control is returned from that USE procedure or if no such USE procedure is specified, the processing of the file is terminated as described above.
MERGE Statement Example
COBOL Related Interview Questions
|VSAM Interview Questions||IBM - VSAM Interview Questions|
|IBM-CICS Interview Questions||JCL Interview Questions|
|IBM DB2 Interview Questions||IBM-JCL Interview Questions|
|DB2 Using SQL Interview Questions||IBM-JCL&VSAM Interview Questions|
|IBM Mainframe Interview Questions||COBOL, CICS, JCL, VSAM, DB2 Interview Questions|
|DB2 SQL Programming Interview Questions||IMS/DB Interview Questions|
|Mainframe DB2 Interview Questions|
Procedure Division Statements
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.