HiRDB Datareplicator Version 8 Description, User's Guide and Operator's Guide
![[Contents]](FIGURE/CONTENT.GIF)
![[Glossary]](FIGURE/GLOSS.GIF)
![[Index]](FIGURE/INDEX.GIF)
![[Back]](FIGURE/FRONT.GIF)
3.3.11 Creating a merge table
An error results at the target system if you attempt to import update information extracted from multiple tables at the source system into a single table at the target (importing n tables into 1 table) or if you attempt to import data when the source system's database is not a structured or relational database. Such an error occurs because of duplication of key values or because there are no corresponding rows according to the mapping key. To resolve these limitations, the target Datareplicator enables you to convert INSERT to UPDATE when a key subject to INSERT is duplicated in the update information or to convert UPDATE to INSERT when there is no corresponding UPDATE row. This is called creation of a merge table.
You specify merge table creation in the import table definition. For details about how to specify an import table definition, see the load statement in 5.10 Import definition.
- Organization of this subsection
- (1) Prerequisites for a merge table
- (2) Merge table processing
- (3) Importing a merge table into a table containing a repetition column
- (4) Notes about the data that is imported into a merge table
(1) Prerequisites for a merge table
A merge table supported for import processing must satisfy the following conditions:
- It must be a general table, not a time-ordered information table.
- It must be a non-FIX table. If it has the FIX attribute, the null value storage option is not specified with DELETE. This condition is not applicable if a merge table is not created from n tables.
- Import processing must use an SQL process. You cannot create a merge table for import processing if data has been edited by an import information editing UOC routine.
- The mapping keys must be the same (applicable to a merge table from n tables). There must also be a unique index of all or part of the mapping key, and there must be no unique index for non-mapping key columns.
- PURGE TABLE cannot be executed on the extracted table (applicable to a merge table from n tables).
- There can be no updating of the mapping key (applicable to a merge table from n tables).
(2) Merge table processing
A merge table is created according to the following rules:
- If UPDATE data is not found, it is stored as INSERT data.
- If INSERT data results in a key value duplication, the data is stored as UPDATE data.
- For data subject to DELETE, either the corresponding row is deleted or the null value is placed in the corresponding column, depending on an import definition option.
(3) Importing a merge table into a table containing a repetition column
If you execute UPDATE specifying an element number for a table containing a repetition column, only the updated element data is sent as the update information, not the entire element data in the corresponding column. In this case, Datareplicator compensates the table with the null value so that there will be enough data items for INSERT during merge table import processing. The following table shows this compensation method:
| SQL |
Element # < minimum element # |
Minimum element # < element # <maximum element# |
Maximum element # < element # |
| INSERT |
Compensation not needed |
| UPDATE SET |
Column specified |
Compensation not needed |
| Element specified |
NULL compensated |
NULL compensated |
Not compensated |
| UPDATE ADD |
NULL compensated |
Impossible |
Not compensated |
| UPDATE DELETE |
Imported as NULL column value |
- Note
- Element # indicates the element number. Maximum element # and Minimum element # indicate the maximum and minimum element number contained in the update information for the corresponding repetition column.
(4) Notes about the data that is imported into a merge table
- When concatenation operation data is imported into a merge table and there is no corresponding row for UPDATE (SQLCODE=100), only the concatenation operation data is imported by INSERT.
- Do not import into a merge table BLOB-type or BINARY-type data to which backward deletion updating is applied. Inconsistency might result between the source and target databases.
All rights reserved. Copyright (C) 2007, 2013, Hitachi, Ltd.