COPY |
|
|
The COPY command copies selected records from one file to another, or within the same file. COPYI is normally a synonym but see the discussion below.
Format
COPY FROM {DICT} src.file {TO {DICT} tgt.file} {src.rec{,tgt.rec}} {options}
where
Any number of source and target record pairs may be specified. If all records in the file are to be copied, the keyword ALL may be used in place of specified record names.
If no source records are specified and the default select list is active, this list is used to determine the records to be copied. A confirmation prompt is issued before copying commences unless the NO.QUERY keyword is used.
The COPY command does not normally overwrite existing records. The keyword OVERWRITING allows this operation. Thus a command of the form COPY FROM src.file TO tgt.file ALL would only copy records that do not already exist in the target file.
Conversely, the keyword UPDATING copies records only if they already exist in the target file.
The DELETING keyword causes COPY to delete records from the source file after they have been successfully copied to the target file.
The TO.LOWERCASE and TO.UPPERCASE options can be useful when copying directory file items from a platform with a case insensitive file system (e.g.Windows) to a platform with a case sensitive file system (e.g. Linux), forcing the casing of the new record to be as specified.
The REPORTING keyword causes a message to be displayed for each record copied.
@SYSTEM.RETURN.CODE is returned as the number of records copied or a negative error code.
The COPY command can be used with data collections but if either of the source and target files is a data collection, both must be.
Users migrating from Pick style systems frequently use ALIAS to make COPY a synonym for COPYP, the Pick syntax copy command. QM also provides COPYI as a way to force use of the Information style syntax.
Example
COPY FROM NEWVOC TO VOC ALL OVERWRITING
This command copies all records from the NEWVOC file to the VOC, replacing existing records of the same name. This could be used, for example, if the VOC had been damaged by an accidental deletion of some standard records.
See also: |