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.

physically exist in storage. Because records are always added to the end of the file,<br />

the relative record number represents the order in which records arrived in the file.<br />

A keyed sequence copy selects and transfers records by key value from a keyed<br />

physical file. This may result in a different physical order in the to-file. The to-file<br />

will be a reorganized version of the from-file. The relative record number of a<br />

specific record may change when a file is copied by key value:<br />

Relative Record Number Arrival Sequence Keyed Sequence<br />

1 1011 0016<br />

2 0762 0762<br />

3 0810 0810<br />

4 3729 1011<br />

5 0016 3729<br />

You can copy a keyed physical file in arrival sequence by specifying the<br />

FROMRCD or TORCD parameter on the COPY commands. When you do this, the<br />

keyed sequence access path is not used to retrieve the records in key sequence. The<br />

records are retrieved in arrival sequence. This is helpful when the physical relative<br />

record location in the file is significant and needs to remain the same as it is in the<br />

original file. Specifying FROMRCD(1) is a good way to copy all the records in<br />

arrival sequence. Copying a physical file in arrival sequence instead of keyed<br />

sequence is also faster.<br />

The kind of copy you run is determined by the type of from-file and the method of<br />

selecting records to copy. In general, files are copied using their keyed sequence, if<br />

they have one, otherwise, their arrival sequence. For more information on the<br />

selection methods, refer to “Selecting the records to copy” on page 92.<br />

A copy from a keyed file to a keyed file usually places records at the end of the<br />

to-file in key field order, by the from-file key, regardless of their physical order in<br />

the from-file. But if you select records in the from-file by relative record number<br />

(using the FROMRCD or TORCD parameter), they are physically placed at the end<br />

of the to-file in relative record number order, regardless of their keyed sequence in<br />

the from-file. The following example shows the result of a COPY command that<br />

specifies from record 3 to record 5:<br />

FROM-FILE TO-FILE<br />

Relative Record<br />

Relative<br />

Number<br />

Record<br />

Key<br />

Number Key<br />

1 1011 . —<br />

2 0762 . —<br />

3 0810 < Arrival 1401 0810<br />

4 3729<br />

< Sequence<br />

< Copy<br />

1402 3729<br />

5 0016 1403 0016<br />

When the to-file has a keyed sequence, the records appear in correct order in the<br />

to-file when using the keyed sequence access path. A copy by relative record<br />

number always copies by arrival sequence.<br />

Chapter 4. Copying files 77

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

Saved successfully!

Ooh no, something went wrong!