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.

 

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

 

NO.QUERYSuppresses confirmation prompt when using a select list.

 

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.

 

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 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.

 

 

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