Selecting records by relative record numbers (FROMRCD and TORCD parameters)
You can use the FROMRCD and TORCD parameters to copy files with specifying their record numbers. Note that you can use these parameters on the CPYF command only. Relative record numbers can be specified for a copy from any file type except a keyed logical file. A keyed physical file can be copied in arrival order if relative record numbers are specified for the FROMRCD or TORCD parameter. Records can be copied:
If the command reaches the end of the file before it reaches the specified ending record number or number of records, the copy completes normally.
- From a specified record number (FROMRCD parameter) to a specified record number (TORCD parameter) OR
- Until a specified number of records (NBRRCDS parameter) has been copied
When a relative record number is specified, records are copied, starting with the specified relative record number, in the order in which they physically exist in the database file being copied from. This is true even if the physical file has a keyed sequence access path. You can use the COMPRESS parameter with the FROMRCD and TORCD parameters to further define which records you want to select for copying.
If the from-file is a physical file or a logical file with an arrival sequence access path, the TORCD value is a relative record number that counts both the deleted and undeleted records ahead of it. If the from-file is a device file or inline data file, the TORCD value is a record number that includes only undeleted records (even for an I-format diskette file).
Deleted records retain their position among records that are not deleted. However these records do not necessarily retain their relative record number when they are copied if they are in the specified subset and COMPRESS(*NO) is specified. If you specify COMPRESS(*YES), the command skips the deleted records and does not copy them. In this case, when the record number that is specified (FROMRCD parameter) is a deleted record, copying starts with the first undeleted record that follows. This example shows how you can use the command to copy records from relative record number 500 to relative record number 1000 in the file EMP1 to the file EMP1T.
CPYF FROMFILE(PERSONNEL/EMP1) + TOFILE(TESTLIB1/EMP1T) MBROPT(*REPLACE) + FROMRCD(500) TORCD(1000)If you use record numbers to select records, you cannot use record keys (FROMKEY/TOKEY parameters) to select records on the same CPYF command.
For information about using the FROMRCD and TORCD parameters with distributed files, see DB2® Multisystem.
Parent topic:
Selecting the records to copy
Related concepts
Specifying *ADD when copying files