Specifying *ADD when copying files

When you specify *ADD, each record copied is added to the end of the existing records in the member. It is important to note that this is always true, even for keyed files. However, with keyed files, the added records appear to be merged in key sequence when accessed through a keyed access path. When copying from query files, the relative record numbers of the resulting file may not correspond to those in the original file.

When *ADD is specified, the copy completes normally even if the from-file contains no records.

When three files are copied with MBROPT(*ADD) to a database file that is not keyed, the resulting to-file would look like Figure 13.

Figure 13. Result of Copies with MBROPT(*ADD) Specified

Graphic showing the result of copies with MBROPT(*ADD) specified

See Adding or changing source file sequence number and date fields (SRCOPT and SRCSEQ Parameters) for source file considerations in this operation, and Copying deleted records (COMPRESS Parameter) for considerations for deleted records.

If MBROPT(*ADD) is specified, records are always physically added at the end of the file, even if it is a keyed sequence file. In the following illustration, FILEDB1 is a keyed physical from-file, and FILEDB2 is a keyed physical to-file. The files are shown as they physically appear in storage. FILEDB2 already has three records in it.



Graphic of files as they physically appear in storage

If you specify MBROPT(*ADD), FROMKEY(1 2), and TOKEY(1 5), four records are added in key field order to the end of FILEDB2.



Graphic of records added to file

The added records, however, appear to be merged in the new file when viewed through a keyed sequence access path.



Graphic of records when viewed through a keyed sequence access path

There are several ways to select records for copying . One method is selection by relative record number. (See Selecting records by relative record numbers (FROMRCD and TORCD Parameters).) Using the preceding example, if you selected records to copy to a third file from FILEDB2 by relative record number, from number 3 through 5, you would copy the records with a key value of 24, 2, and 3, not 4, 5, and 9.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]