Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
|<br />
Existing<br />
Records<br />
Added<br />
Records<br />
FILEDB2<br />
Key<br />
9<br />
54<br />
24<br />
2<br />
3<br />
4<br />
5<br />
Relative<br />
Record<br />
Number<br />
FILEDB2<br />
Key<br />
Keyed Access<br />
View of To-<strong>File</strong><br />
There are several ways to select records for copying . One method is selection by<br />
relative record number. (See “Selecting records by relative record numbers<br />
(FROMRCD and TORCD Parameters)” on page 93.) Using the preceding example,<br />
if you selected records to copy to a third file from FILEDB2 by relative record<br />
number, from number 3 through 5, you would copy the records with a key value<br />
of 24, 2, and 3, not 4, 5, and 9.<br />
Specifying *UPDADD when copying files<br />
1<br />
2<br />
3<br />
4<br />
5<br />
6<br />
7<br />
Keyed Database<br />
To-<strong>File</strong> in Arrival<br />
Sequence<br />
2<br />
3<br />
4<br />
5<br />
9<br />
24<br />
54<br />
RV2H081-0<br />
When you specify *UPDADD on the CPYF command, a from-file key value builds<br />
before the from-file record moves into the to-file. The from-file builds this key<br />
value by using the key specifications of the to-file. Before the key value is built, the<br />
system performs any necessary field or data mapping, data conversion, or record<br />
selection. The system checks the to-file to see if this key value already exists in it<br />
(duplicate key of the from-file data). If the key value does exist in the to-file,the<br />
from-file record that contains the key value updates that to-file record.<br />
The following apply if you specify MBROPT(*UPDADD) on the CPYF command:<br />
v The to-file must be a local database physical file that contains a primary or<br />
unique key.<br />
v You may not specify CRTFILE(*YES). The to-file must exist before you run CPYF.<br />
v CPYF cannot copy from multiple formats.<br />
v Detected duplicate keys are not skipped but updated with the new from-file<br />
record value. Duplicate key errors (CPF5026) are not included as ERRLVL errors.<br />
v CPF5027 will be included as an ERRLVL error. This error can occur if another<br />
process has a record that is locked. To avoid this error, you may want to<br />
pre-allocate the to-file within your job before performing the CPYF. You can use<br />
the WAITRCD parameter on the CRTPF and CHGPF commands to limit the<br />
length of time that the commands spend waiting for a record lock to be released<br />
in the to-file.<br />
v All existing FMTOPT values are allowed. However, when using<br />
MBROPT(*UPDADD), take care to avoid updating records that you do not want<br />
to update. Also avoid updating the same record multiple times when it is not<br />
desired.<br />
v Nulls are not used in determining duplicate key values if FMTOPT(*NOCHK) is<br />
specified or if the from-file is a device file.<br />
v You must have the minimum following authorities to the to-file:<br />
Chapter 4. Copying files 87