When you specify *UPDADD on the CPYF command, a from-file key value
builds before the from-file record moves into the to-file. The from-file builds
this key value by using the key specifications of the to-file.
Before the key value is built, the server performs any necessary field
or data mapping, data conversion, or record selection. The server checks the
to-file to see if this key value already exists in it (duplicate key of the
from-file data). If the key value does exist in the to-file, the from-file
record that contains the key value updates that to-file record.
The following rules apply if you specify MBROPT(*UPDADD) on
the
CPYF command:
- The to-file must be a local database physical file that contains a primary
or unique key.
- You cannot specify CRTFILE(*YES). The to-file must exist before you run
CPYF.
- CPYF cannot copy from multiple formats.
- Detected duplicate keys are not skipped but updated with the new from-file
record value. Duplicate key errors (CPF5026) are not included as ERRLVL errors.
- CPF5027 will be included as an ERRLVL error. This error can occur if another
process has a record that is locked. To avoid this error, you might want to
pre-allocate the to-file within your job before performing the CPYF. You can
use the WAITRCD parameter on the CRTPF and CHGPF commands to limit the length of time that the commands
spend waiting for a record lock to be released in the to-file.
- All existing FMTOPT values are allowed. However, when using MBROPT(*UPDADD),
take care to avoid updating records that you do not want to update. Also avoid
updating the same record multiple times when it is not what you want.
- Nulls are not used in determining duplicate key values if FMTOPT(*NOCHK)
is specified or if the from-file is a device file.
- You must have the minimum following authorities to the to-file:
- Object operational (*OBJOPR)
- Add (*ADD)
- Update (*UPD)