30.06.2013 Views

File Management - IBM

File Management - IBM

File Management - IBM

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

94 <strong>File</strong> <strong>Management</strong> V4R5<br />

Selecting records by record keys (FROMKEY and TOKEY<br />

Parameters)<br />

Note: You can use this parameter on the CPYF command only.<br />

You can specify record keys to copy only from a keyed database file. You can copy<br />

records:<br />

v From a specified key value (FROMKEY parameter) to a specified key value<br />

(TOKEY parameter) OR<br />

v Until a specified number of records (NBRRCDS parameter) is reached (see<br />

“Selecting a specified number of records (NBRRCDS Parameter)” on page 98<br />

If the command reaches the end of the file before it reaches the specified ending<br />

key value or number of records, the copy completes normally.<br />

If no record in the from-file member has a key that is a match with the FROMKEY<br />

value, but there is at least one record with a key greater than the specified value,<br />

the first record copied is the first record with a key greater than the FROMKEY<br />

value. If the specified key value is greater than any record in the member, the<br />

command sends an error message and does not copy the member.<br />

You can specify *BLDKEY on the FROMKEY and TOKEY parameters to use a list<br />

of character and numeric values in their natural display form for the fields in a<br />

key. The command converts each element to the corresponding key field data type.<br />

The command then provides the composite key value (a key that is comprised of<br />

more than one field) to the database.<br />

If you specify fewer values than the complete database key contains, the command<br />

builds a partial key and passes it to the database. If you specify more values than<br />

the database key contains, an ending error occurs. The command always applies<br />

values to the consecutive fields that are in the extreme left of the key so that it is<br />

impossible to skip key fields.<br />

The command pads character fields on the right with blanks. The command<br />

adjusts numeric fields to the implied decimal point in the key field with the correct<br />

zero padding.<br />

All regular rules for specifying numeric fields in an external character format<br />

apply. The command does not allow a floating-point value of *NAN (Not a<br />

Number).<br />

See “Example: build-key function” on page 96 and “Example: using FROMKEY and<br />

TOKEY” on page 96 for specific coding examples.<br />

It is also important to understand “Key string comparisons made by the copy<br />

operation” on page 95 in order to interpret various warning messages.<br />

Note: If you use record keys to select records, you cannot use relative record<br />

numbers (FROMRCD/TORCD parameters) to select records on the same<br />

CPYF command.<br />

You should not specify COMPRESS(*NO) when selecting records by record key<br />

from a keyed physical file. Because the keyed access path of a file does not contain<br />

deleted records, the copy command never copies them, so the compression is<br />

automatic.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!