COPY

COPY

Top  Previous  Next

 

The COPY command copies selected records from one file to another, or within the same file.

 

 

Format

 

COPY FROM {DICT} src.file {TO {DICT} tgt.file} {src.rec{,tgt.rec}} {options}

 

where

 

src.fileis the file from which the records are to be copied.

 

tgt.fileis the file to which the records are to be copied. If omitted, records are copied within the src.file.

 

src.recis the name of the record to be copied.
tgt.recis the name of the record to which src.rec is to be copied. If omitted, the record is not renamed.

 

optionsare taken from the following:

 

ALLCopy all records from src.file to tgt.file. This option cannot be used with named records or a select list.

 

BINARYCopy data in binary mode, suppressing translation between field marks and newlines when copying between a hashed file and a directory file in either direction. This mode is implied if both are directory files unless the TEXT option is used.

 

DELETINGDelete the record(s) from src.file after copying.

 

NO.QUERYSuppresses confirmation prompt when using a select list. The NO.SEL.LIST.QUERY mode of the OPTION command can be used to imply this option.

 

OVERWRITINGOverwrite existing record(s) of the same name in tgt.file. Without this option, records which already exist are not copied. This option may not be used with UPDATING.

 

REPORTINGDisplay the id of each record as it is copied.

 

TEXTCopy data in text mode, translating between field marks and newlines when copying between a hashed file and a directory file in either direction. This option is also needed to override implied binary mode when copying between directory files where the newline representation of the source and target are different (e.g. Windows to Linux).

 

TO.LOWERCASEForce target record ids to be lowercase.

 

TO.UPPERCASEForce target record ids to be uppercase.

 

UPDATINGOnly copy records if they already exist in the target file. This option may not be used with OVERWRITING.

 

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 collections, both must be.

 

 

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:

COPYP