Selecting a specified number of records (NBRRCDS parameter)

 

When you specify a FROMKEY or FROMRCD parameter, you can specify the number of records (NBRRCDS parameter) to be copied instead of the TOKEY or TORCD parameter.

You cannot specify both the NBRRCDS and the TORCD or TOKEY parameters. The specified number of records is copied starting with the specified from-key value or from-record number.

You can use this parameter on the following commands: CPYF, CPYFRMDKT, CPYFRMQRYF, CPYFRMTAP, CPYTODKT, and CPYTOTAP.

You can specify the NBRRCDS parameter without specifying the FROMKEY or FROMRCD parameter. The copy command copies records by starting with the first record in the file.

The number of records specified is the number of records actually copied to the to-file, which include deleted records in the from-file if COMPRESS(*NO) is specified, but does not include records excluded by the INCCHAR and INCREL parameters. This example shows how you can use the copy command to copy 1000 records in the file EMP1 to the file EMP1T. The command copies records from the first member in EMP1 and replace the records in the first member in EMP1T.

CPYF   FROMFILE(PERSONNEL/EMP1) +
  TOFILE(TESTLIB1/EMP1T) MBROPT(*REPLACE) +
  NBRRCDS(1000)
You can also use the NBRRCDS parameter to examine a subset of records on a list:
CPYF   FROMFILE(PERSONNEL/EMP1) TOFILE(*PRINT) +
  FROMRCD(250) NBRRCDS(10) OUTFMT(*HEX)

When you successfully copy an open query file, the file position is unpredictable. If you want to run a different program with the same files or run another CPYFRMQRYF, position the file or close the file and open it with the same OPNQRYF command. You can position the file with the Position Database File (POSDBF) command. In some cases, you can use a high-level language program statement.

 

Parent topic:

Selecting the records to copy

 

Related concepts


Selecting records using a specified record format name (RCDFMT parameter)
Selecting records by record keys (FROMKEY and TOKEY parameters)