Highlighted
Absent Member.
Absent Member.
264 views

Merge Statement

I was reading somewhere where the Merge statement is not often used with sequential files.  Is there an alternative or a best practice when using sort and merge statements?

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Merge Statement

Unlike the SORT statement which can resequence records from multiple files on key positions within the record to create a newly sequenced file, the MERGE statement works only on files that are already within a sorted sequence. It simply combines the records of the files into a new output file.

In a sequential file you do not write records based on a key, new records are simply written to the end of the file without regard for the content of the records. So sequential files are very unlikely to be in any sorted sequence to begin with unless you have some sort of a sequential record number that you increment when writing the records.

So I would say that while SORT can be very useful with Sequential files (or any type of file) MERGE really isn't.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.