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?

  • 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.