Copy operation on files not in check-pending status
When the parent or dependent file has an established constraint relationship that is not in check-pending status, the rules described in this topic apply.
- If the from-file has an established constraint relationship, then you can copy all of the records from it whether it is a parent or dependent file.
- If the to-file has an established or enabled constraint relationship, then the following rules apply to keep the constraint relationship from entering check-pending status:
- A parent file cannot have its member cleared of records.
- A parent file cannot have more than one parent key value in the parent key access path of the same value (key must remain unique). That is, if the to-file is a parent file in a constraint relationship, then the copy does not allow duplicate key records to be copied into it.
- A dependent file's foreign key values that are not null must always have a corresponding parent key value. That is, if the to-file is a dependent file in a constraint relationship, the copy operation does not allow non-null foreign key records that do not have a corresponding parent key record to be copied into the dependent file.
The copy operation ensures that the data in the parent or dependent to-file is not damaged. Records can be copied to the to-file provided they do not cause the constraint relationship to go into check-pending status. If a user attempts to copy a record that does not meet the constraint relationship rules, the copy operation will end unless the ERRLVL parameter has been specified (CPYF and CPYFRMQRYF commands only) with a value greater than zero.
To circumvent the above rules, you can disable the involved constraints before the copy operation, perform the copy, and then re-enable the constraints. However, the file is in check-pending status if constraint rules are still not met.
Parent topic:
Preventing errors when copying files
Related concepts
Prevention of copy errors that result from constraint relationships