/cpy

Copy one or more entity occurrences from a source database or XML file to another.

/cpy   {/apf}   {/whr=OccurrenceSpecification}   {/com=CommitFrequency}   {/int=MessageFrequency}   {/nos}   Source  Target  {Mapping}

Sub-Switches

  • /apf—append the data to an existing XML file. Only applicable if Target is XML file. For more information, see /apf.
  • /whr—copy selected occurrences. Only applicable if Source is a database. For more information, see /whr.
  • /com—commit after specified number of occurrences (if supported by the database). Default is 100.For more information, see /com.
  • /int—frequency with which a message is displayed, expressed as a number of occurrences. Default is 100.For more information, see /int.
  • /nos—no supersede. Do not replace existing occurrences. Use only if Target is a database. For more information, see /nos.

Parameters

  • Source—source of data to be copied. One of:
    • Database path and entity: Path:Entity.Model

      Path can specify a connector path (such as XML, DEF, ORA), or a user-defined path (such as $ORA or $MyData).

      Either or both of Entity and Model can contain wildcards, for example DEF:ENT*.MOD*.

    • XML file: {ZipArchive:}Filename

      For example, myxmlfile.xml or ziparchive.zip:myxmlfile.xml

      When a ZipArchive is specified, it is created in the Zip64 format.

  • Target—destination database path or XML file.
    • Database objects: Path:

      Entity and/or model names following the path are ignored.

    • XML file: xml: or {ZipArchive:}Filename
  • Mapping—entity mapping instructions; one of the following:
    • MapFile—name of a file containing the map instructions. For more information, see Mapping Files.
    • #—use target Repository definitions to map all entities
    • #Entity—use target Repository definitions to map the specified entity
    • #TargetEntity=SourceEntity—use target Repository definitions to map a source entity to a target entity

Use With

ide—Uniface IDE

Description

The /cpy command copies one or more entity occurrences from a source database or file to another. Assignment settings determine the actual locations of Source, Target, and MapFile.

When copying data into a database, Uniface does not know anything about the contents of the source data and performs a physical conversion. The copy process does not consider referential integrity constraints, so it is possible to copy the data from one entity without its related entities. As a developer, you need to ensure that the correct data is copied to ensure referential integrity.

Caution: Do not use /cpy to export and import Repository definitions. This can cause corruption of the Uniface Repository. Use the export and import functionality instead. For more information, see Export and Import Facilities and Repository Versioning.

If the data source is a database, you can specify which entities and occurrences to copy using the /whr option.

If the data target is an XML file, you can append data to it using the /apf switch. However, if an XML file was originally created with Uniface's export functionality, it is not possible to append data to it with /cpy.

Using Map Files

The mapping instructions in Mapping describe the entities and fields you want to copy from the Source to the Target.

By default, entities are copied using descriptors in the Source to map entities to the Target, but you can override this and provide your own mapping rules.

If you specify the # options, the entity descriptors in the Target are used instead of those in the Source.

Alternatively, you can also specify your own mappings in a map file. For more information, see Mapping Files.

Copying from a Database to an XML File

The following example copies contents of the DOCUMENT.BOOK entity from Sybase (using the three-character identifier of the connector) to an XML file named document.xml:

/cpy syb:document.book xml:

The following example copies contents of the SALESREP entity from the path $MyData (which is mapped in the assignment file to Oracle) to an XML file named sales.xml:

/cpy $MyData:salesrep.company xml:

Copying from a Database to Another Database

The following example copies the contents of the CUSTOMER entity from SQLite to Oracle, passing a password to Oracle:

/log=ora:|myid|mypass /cpy SLE:customer.sales ora:

Copying from an XML File to a Database

The following example copies the data in the file data.xml to a Sybase table:

/asn=testing /log=syb:testing|kaye|hoopoe /cpy data.xml syb:

Copying Using Wildcards

The following example copies all occurrences of EMPLOYEES whose name starts with the letter A and who have an employee number between 100 and 400 to the file employees.xml:

/cpy /whr="empname=A*;empno>100&<400" def:employees.company xml:

Copying Using a Map File

The following example uses the mapping instructions in the file map2 to copy data from an XML file to a Sybase table:

/cpy xml:track syb: map2

The following example copies data from an XML file to the default database, specifying that map file functionality is to be used:

/cpy xml:accounts.xml def: #

Related Topics