Database Tour new tab Documentation Contents Index

Field Mappings File

 

Field mappings files contain source-to-target field mappings for export and import operations. Use them whenever you need the same field mappings to be used more than once. They can be also used when exporting data from command line or action files.

There are two supported formats of field mappings files: XML (recommended) and plain text.

XML Format

This format is flexible and extendable and therefore is recommended to use whenever possible.

Such field mappings files can be created either in the Export dialog on the Field Mappings step or manually using a text editor. When creating the files manually please note that they must conform to XML standards and contain byte order marks at the beginning if needed.

The file contains an optional common part and a series of field mappings. The common part may include some technical information like application name and version, and key fields for special cases of exporting data to databases and SQL script.

Each mapping must contain 2 parts: source and target.

The source part must contain a FieldName attribute with the physical name of the source field or a dynamic expression.

The target part can have a variable number of attributes (either FieldName or FileName or both must be filled).

XML Format Example

Example of the Access-to-Oracle field mappings file in XML format:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Source-to-Target mappings for Payments aggregation --> 
<FieldMappings>
  <Software>Database Tour Pro</Software>
  <KeyFields>PAYMENT_ID</KeyFields>
  <Items>
    <FieldMapping>
      <Source>
        <FieldName>PaymentId</FieldName>
      </Source>
      <Target>
        <FieldName>PAYMENT_ID</FieldName>
        <FieldType>INTEGER</FieldType>
        <PrimaryKey>1</PrimaryKey>
      </Target>
    </FieldMapping>
    <FieldMapping>
      <Source>
        <FieldName>Department</FieldName>
      </Source>
      <Target>
        <FieldName>DEPARTMENT</FieldName>
        <FieldType>VARCHAR2</FieldType>
        <FieldSize>20</FieldSize>
        <FieldDescription>Department Name</FieldDescription>
      </Target>
    </FieldMapping>
    <FieldMapping>
      <Source>
        <FieldName>ActualityDate</FieldName>
      </Source>
      <Target>
        <FieldName>ACTUALITY_DATE</FieldName>
        <FieldType>DATE</FieldType>
        <FieldDescription>Date of Payment</FieldDescription>
      </Target>
    </FieldMapping>
    <FieldMapping>
      <Source>
        <FieldName>PaymentSum</FieldName>
      </Source>
      <Target>
        <FieldName>PAYMENT_SUM</FieldName>
        <FieldType>NUMBER</FieldType>
        <FieldSize>12</FieldSize>
        <FieldScale>2</FieldScale>
        <FieldDescription>Payment Amount</FieldDescription>
      </Target>
    </FieldMapping>
    <FieldMapping>
      <Source>
        <!-- dynamic expressions are possible: -->
        <FieldName>vle_expr(0.1 * dataset_field_val(1, 'PaymentSum'))</FieldName>
      </Source>
      <Target>
        <FieldName>COMMISSION_SUM</FieldName>
        <FieldType>NUMBER</FieldType>
        <FieldSize>12</FieldSize>
        <FieldScale>2</FieldScale>
        <FieldDefaultValue>0</FieldDefaultValue>
        <FieldSQLSpecification>NUMBER(12, 2) DEFAULT 0<
        <FieldDescription>Commission Amount</FieldDescription>
      </Target>
    </FieldMapping>
    <FieldMapping>
      <Source>
        <FieldName>Notes</FieldName>
      </Source>
      <Target>
        <FieldName>NOTES</FieldName>
        <FieldType>VARCHAR2</FieldType>
        <FieldSize>400</FieldSize>
        <FieldSQLSpecification>VARCHAR2(400)</FieldSQLSpecification>
        <FieldDescription>Notes regarding the payment</FieldDescription>
        <!-- we use value of the unique PaymentId field to ensure we get a unique file path for each record: -->
        <FileName>vle_expr(extract_file_path(target_file_name(1)) + 'notes' + to_string(dataset_field_val(1, 'PaymentId')) + '.txt')</FileName>
      </Target>
    </FieldMapping>
  </Items>
</FieldMappings>

See the full list of available attributes.

Text Format

Such files consist of series of SourceFieldName=TargetFieldName pairs, one mapping per line. It is recommended that field names not contain equal signs. Instead of source field names, dynamic expressions can be used (see example below). Lines with a semicolon at the beginning are ignored as comments. Blank lines are allowed.

Such files can have any extension and can be created in any text editor. When creating the files please include byte order marks at the beginning if needed.

Text Format Example

Example of the field mappings file in text format:

;Source-to-Target mappings for Payments exporting
Department=DEPARTMENT
ActualityDate=ACTUALITY_DATE
PaymentCount=PAYMENT_COUNT
PaymentSum=PAYMENT_SUM
;dynamic expressions are possible:
vle_expr(0.1 * dataset_field_val(1, 'PaymentSum'))=COMMISSION_SUM

Notes
Target FieldName attributes, if contain characters, uncommon for field names in the target database (i.e. spaces etc.), should be enclosed in double quotes or square brackets according to the rules of the target database.