Data Copy Facility

Uniface enables you to copy and convert your application data to and from different formats, including XML files and other databases.

The copy facility can be useful when you need to:

  • Move data from one database to another, for example from MySQL to Oracle.
  • Convert data from one application model to another

You can access the copy facility in the following ways:

  • From the Uniface or IDE command line, use the /cpy command line switch to copy or convert data from or to the database.
  • In your own components, use the $ude ("copy") or entitycopy ProcScript commands. (These commands are equivalent.)
  • In the Uniface IDE, click the Main Menu ( ≡ ) and choose Import XML... and select the file to import.
  • In a runtime environment, you can use Uniface Resource Manager (URM) to copy data to an XML file (optionally in a UAR file), or to another database. For more information, see urm entitycopy.

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.

Copying Data

The data copy facility copies records from a source to a target. Both source and target may be an XML file or tables in a database. Copying is a physical transformation of database rows, in which data is automatically converted to the target format.

Data can only be copied if the database table in which it is stored is modeled in Uniface as an entity. Uniface copies the entity definitions as well as the user data so that the table can be reconstructed if it does not exist in the target database.

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.

Copying Data to and from Files

When copying data, you can specify XML files as Source or Target. Be aware of the following:

  • Using the copy facility, it is not possible to append data to a file created by the Uniface export facility.
  • You can use assignments to locate XML files in the appropriate directory. For more information, see File Assignments and Redirection.
  • XML files may be located in .zip files. For more information, see Zip Files.
  • Uniface .zip files and archives are created in the Zip64 format, which is required for zip files that are 4GB or larger.

    Tip: If required, you can convert a Zip64 archive that is smaller than 4GB to the normal Zip format using the Uniface Resource Manager (URM). For example: urm copy zip64archive.zip:* ziparchive.zip: For more information, see urm copy.

  • On some systems, Uniface cannot distinguish a period (.) in a directory name from a period in the file name within the FileName parameter. This means that if a period occurs anywhere in the file name, Uniface assumes that the file name already has an extension.
  • The default format of source or target files is XML. The Source can be a TRX file (a proprietary file format supported by earlier versions of Uniface), but this file format is not supported for Target.

Copying Data between Databases

When copying data, it is automatically converting to the target format. Uniface keeps the rich definitions defined in the modeled entities. These contain a high-level, logical description of database tables that is not affected by deployment decisions. The abstraction prevents loss of value.

For example, it is possible to convert a complicated Sybase database to an Oracle database, without losing any of the richness of the original database definition. With the exception of any DBMS-specific programming that, by definition, would need porting to a new environment, the Uniface application will function identically.

All data types are converted, even if the target DBMS does not support certain features of the source DBMS. For example, if a segmented string field has been used in the source DBMS and the target DBMS does not support segmented strings, Uniface creates the equivalent of a segmented string in the target DBMS and assumes responsibility for managing that field.

When creating a new table in the target DBMS, Uniface chooses the optimum storage format for each field in that table. In this way, it is possible to use all the functionality of the DBMS without compromising the modeled object definitions. For example, a modeled date field can be mapped to the optimum storage formats for dates in every supported DBMS, thus ensuring optimum behavior in the DBMS with the data. Some DBMSs store the date as a fixed-length character string, others use a binary datetime format. In Uniface it does not matter how it is stored.

The copy/conversion facility is customizable, enabling you to select the entities and occurrences you want to copy, and override default entity mapping instructions with your own mappings.

Related Topics