Command COPY TO Professional

Copies a table to another target table on ADS server.

Syntax
COPY TO <cFilename> [FOR <cForCondition>] [VIA <cDBE>]
Parameters
<cFilename>
<cFilename> specifies the name of the new file where the exported records are written to. The name must contain the drive and path if they are necessary. It can be specified either as a literal file name or a character expression in parentheses. If the file name is specified without a file extension, the default extension predetermined by the ADSDBE is used.

the specified path has to be visible from the ADS servers point of view. The complete operation will be handled by the ADS server.

<cForCondition>
<cForCondition> is an optional logical expression. Only records for which <cForCondition> returns the value .T. (true) are exported/copied from the source file.
<cDBE>
<cDBE> optionally specifies the database engine (DBE) used to manage the files in the desired workarea. It is a character string containing the name of the DBE. If <cDBE> is not specified, the DBE defined as the default with DbeSetDefault()is used. If the option SDF or DELIMITED is specified, or <cDBE> does not refer to ADSDBE the Xbase++ native COPY TO implementation is used.
Description

COPY TO allows to copy a table on the ADS server. This will be completely handled and processed remotely which in turn reduces network traffic and is less timeconsuming.

The command COPY TO will be entirely processed on the ADS server. This makes it necessary that both, source and target table, must be ADS driven tables and the FOR condition can be executable on the ADS server. If one of those preconditions can not be fulfilled the COPY TO command will be executed on the client (see \SOURCE\SYS\DBBULK.PRG). The same applies if options like REST, WHILE or ALL as supported by Xbase++ are used. This is because the ADS server does not provide such a functionality. For more details about COPY TO see the Xbase++ Online Documentation.

The COPY TO command does not respect any SCOPE setting on the source table.

Examples
#include "ads.ch" 
#include "adsdbe.ch" 


// Load ADSDBE as default database engine. 
PROCEDURE DbeSys 
   IF !DbeLoad( "ADSDBE" ) 
      Alert( "ADSDBE could not be loaded!" ) 
   ENDIF 
   DbeSetDefault( "ADSDBE" ) 
RETURN 



PROCEDURE Main 
   // Connect to database server. 
   LOCAL cConnect := "DBE=ADSDBE;SERVER=\\ALASKA\VOL1" 
   LOCAL oSession := DacSession():new( cConnect ) 

   IF !oSession:isConnected() 
      Alert( "Connection to server could not be established!" ) 
      QUIT 
   ENDIF 

   // open table on ADS server 
   USE Test NEW SHARED 

   // copies source table "Test" to "MyBackup" 
   COPY TO MyBackup FOR Age > 34 

   // Close databases and disconnect from server. 
   DbCloseAll() 
   oSession:disconnect() 
RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.