To expand on David's comment--

CPYF FROMFILE(myotherfile) TOFILE(myfile) +
MBROPT(*REPLACE)

If FROMFILE is keyed, the data will be copied in order by the key. "[I]f the key is on clientnumber and I add client 1" as the last record added "to the end of myotherfile, then client 1 will be the first record of myfile."

CPYF FROMFILE(myotherfile) TOFILE(myfile) +
MBROPT(*REPLACE) FROMRCD(1)

If you add the FROMRCD(1) parameter, it tells the operating system to copy the records beginning at the physical start of the first clump of data, and ending at the last record in the last clump of data in FROMFILE. This is sometimes called "Arrival Sequence," or "Relative Record Number Sequence." Since "client 1" was chronologically the last record added, it will be the last record in the TOFILE.

"Arrival Sequence" may not be an accurate name if your file reuses deleted records-- that "Client 1" record you added may not be physically the last record in the file. There may have been a record deleted part way through the file at some time, leaving a 'hole' that the operating system will fill with the next record added.

In any event, FROMRCD(1) may result in a 'faster' copy, especially if records were not added to the file in order by the key sequence of the physical file. This is because instead of having to say "Where's Client 1.... there it is! Where's Client 2.... there it is! Where's Client 3.... there it is!" the operating system can say "Here's a record, here's a record, here's a record..."

Sometimes, if the operating system reports the physical file as 'damaged,' it may not be able to read the file in key sequence. In that case, create a new copy of the file USING THE SOURCE CODE, then try reading the file using FROMRCD(1). If the damage is just to the index, reading the records in their physical order may still be possible. You do not want to use CRTFILE(*YES), because that may copy the damage as well as the data!

--Paul E Musselman
PaulMmn@xxxxxxxxxxxxxxxxxxxx



At 11:11 AM +0100 3/26/10, David FOXWELL wrote:
Here's a subtlety with cpyf :

CPYF FROMFILE(myotherfile) TOFILE(myfile) +
MBROPT(*REPLACE)

If the fromfile is keyed, then the data may be organized differently in the tofile. Eg if the key is on clientnumber and I add client 1 to the end of myotherfile, then client 1 will be the first record of myfile.

If I add FROMRCD(1), client 1 will be the last record of myfile.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.