Copying files that contain datalinks

 

You can specify CRTFILE(*YES) on the CPYF and CPYFRMQRYF commands when you copy files that contain datalinks. If the from-file is an SQL table, view, or index that contains a datalink, these commands create an SQL table.

Datalinks can be mapped only to other datalinks. Therefore, if you specify *NONE, *MAP, or *DROP on the FMTOPT parameter, the from-file and to-file must have corresponding datalinks. Truncation is not allowed. Shorter datalinks, however, can be converted to longer datalinks.

A file can be linked only once on a system. Therefore, a copy that will perform mapping or that requires the formats to be identical (that is, *NONE, *MAP, or *DROP is specified on the FMTOPT parameter) will not be successful if corresponding from-file and to-file fields are both FILE LINK CONTROL. Copies that are performed using the *NOCHK parameter option are not restricted, but errors will occur if a datalink that references a linked file is copied to a datalink that is FILE LINK CONTROL. When you specify CRTFILE(*YES) on the CPYF or CPYFRMQRYF command, and the from-file contains a FILE LINK CONTROL datalink field, the following statements are true, depending on how you specify the FMTOPT parameter:

The following table shows LINK scenarios associated with the CPYF command when different FMTOPT values are used.

LINK status for from-field to to-field when FMTOPT parameter is *MAP or *NONE How linking is performed
FILE LINK CONTROL to FILE LINK CONTROL Not allowed. Files can be linked only once.
NO LINK CONTROL to FILE LINK CONTROL (with no truncation) Linking is performed.
FILE LINK CONTROL to NO LINK CONTROL (with no truncation) No linking is performed.
NO LINK CONTROL to NO LINK CONTROL (with no truncation) No linking is performed.

 

Parent topic:

Copying complex objects

 

Related information


CPYF command
CPYFRMQRYF command