[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 COPY TO
 Export records to a new database (.dbf) file or ASCII text file
------------------------------------------------------------------------------
 Syntax

     COPY [FIELDS <idField list>] TO <xcFile>
        [<scope>] [WHILE <lCondition>] [FOR <lCondition>]
        [SDF | DELIMITED [WITH BLANK | <xcDelimiter>] |
        [VIA <xcDriver>]]

 Arguments

     FIELDS <idField list> specifies the list of fields to copy to the
     target file.  The default is all fields.

     TO <xcFile> specifies the name of the target file.  The file name
     can be specified either as a literal file name or as a character
     expression enclosed in parentheses.  If SDF or DELIMITED is specified,
     .txt is the default extension.  Otherwise, .dbf is the default
     extension.

     <scope> defines the portion of the current database file to COPY.
     The default is ALL records.

     WHILE <lCondition> specifies the set of records meeting the
     condition from the current record until the condition fails.

     FOR <lCondition> specifies the conditional set of records to copy
     within the given scope.

     SDF specifies the output file type as a System Data Format ASCII
     text file.  Records and fields are fixed length.

     DELIMITED specifies the output file type as a delimited ASCII text
     file where character fields are enclosed in double quotation marks (the
     default delimiter).  Records and fields are variable length.

     DELIMITED WITH BLANK identifies an ASCII text file in which fields
     are separated by one space and character fields have no delimiters.

     DELIMITED WITH <xcDelimiter> identifies a delimited ASCII text file
     where character fields are enclosed using the specified delimiter.
     <xcDelimiter> can be specified either as a literal character or as a
     character expression enclosed in parentheses.

     See the tables below for more information regarding the format
     specifications for ASCII text files created using these arguments.

     VIA <xcDriver> specifies the replaceable database driver (RDD) to
     use to create the resulting copy.  <cDriver> is name of the RDD
     specified as a character expression.  If <cDriver> is specified as a
     literal value, it must be enclosed in quotes.

     If the VIA clause is omitted, COPY TO uses the driver in the current
     work area.  If you specify the VIA clause, you must REQUEST the
     appropriate RDDs to be linked into the application.

     Note:  If the DELIMITED WITH clause is specified on a COPY or APPEND
     command, it must be the last clause specified.

 Description

     COPY TO is a database command that copies all or part of the current
     database file to a new file.  Records contained in the active database
     file are copied unless limited by a <scope>, a FOR|WHILE clause, or a
     filter.

     If DELETED is OFF, deleted records in the source file are copied to
     <xcFile> where they retain their deleted status.  If DELETED is ON,
     however, no deleted records are copied.  Similarly, if a FILTER has been
     SET, invisible records are not copied.

     Records are copied in controlling index order if there is an index open
     in the current work area and SET ORDER is not zero.  Otherwise, records
     are copied in natural order.

     In a network environment, CA-Clipper opens the target database file
     EXCLUSIVEly before the COPY TO operation begins.  Refer to the "Network
     Programming" chapter in the Programming and Utilities Guide for more
     information.

     This table shows the format specifications for SDF text files:

     SDF Text File Format Specifications
     ------------------------------------------------------------------------
     File Element        Format
     ------------------------------------------------------------------------
     Character fields    Padded with trailing blanks
     Date fields         yyyymmdd
     Logical fields      T or F
     Memo fields         Ignored
     Numeric fields      Padded with leading blanks for zeros
     Field separator     None
     Record separator    Carriage return/linefeed
     End of file marker  1A hex or CHR(26)
     ------------------------------------------------------------------------

     This table shows the format specifications for DELIMITED and DELIMITED
     WITH <xcDelimiter> ASCII text files:

     DELIMITED Text File Format Specifications
     ------------------------------------------------------------------------
     File Element        Format
     ------------------------------------------------------------------------
     Character fields    Delimited, with trailing blanks truncated
     Date fields         yyyymmdd
     Logical fields      T or F
     Memo fields         Ignored
     Numeric fields      Leading zeros truncated
     Field separator     Comma
     Record separator    Carriage return/linefeed
     End of file marker  1A hex or CHR(26)
     ------------------------------------------------------------------------

     This table shows the format specifications for DELIMITED WITH BLANK
     ASCII text files:

     DELIMITED WITH BLANK Text File Format Specifications
     ------------------------------------------------------------------------
     File Element        Format
     ------------------------------------------------------------------------
     Character fields    Not delimited, trailing blanks truncated
     Date fields         yyyymmdd
     Logical fields      T or F
     Memo fields         Ignored
     Numeric fields      Leading zeros truncated
     Field separator     Single blank space
     Record separator    Carriage return/linefeed
     End of file marker  1A hex or CHR(26)
     ------------------------------------------------------------------------

 Examples

     .  This example demonstrates copying to another database file:

        USE Sales NEW
        COPY TO Temp

     .  This example demonstrates the layout of a DELIMITED file:

        COPY NEXT 1 TO Temp DELIMITED
        TYPE Temp.txt

        Result:

        "Character",12.00,19890801,T

     .  This example demonstrates the layout of an SDF file with four
        fields, one for each data type:

        USE Testdata NEW
        COPY NEXT 1 TO Temp SDF
        TYPE Temp.txt

        Result:

        Character     12.0019890801T

     .  This example demonstrates the layout of a DELIMITED file WITH
        a different delimiter:

        COPY NEXT 1 TO Temp DELIMITED WITH '
        TYPE Temp.txt

        Result:

        'Character',12.00,19890801,T

 Files   Library is CLIPPER.LIB.


See Also: APPEND FROM COPY FILE COPY STRUCTURE SET DELETED
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson