There are situations where you need to keep a source and target in sync. One method to do this is to truncate and reload. However this method is not that efficient for a table with millions of rows of data. You really only want to:
- insert rows from the source that don’t exist in the target
- update rows that have changed
- delete rows from the target that no longer exist in the source
Can you do this efficiently in a single informatica mapping?
Here is a picture of the informatica mapping:
Here is the detailed informatica mapping:
- Insert Source and Source Qualifier from Source
- Insert Source and Source Qualifier from Target
- Sort Source and Target in Source Qualifiers by Key Fields
- Insert Joiner Transformation using a Full Outer Join and select Sorted Input option
- Insert a Router Transformation with 3 groups
- Insert - ISNULL(Target_PK)
- Delete - ISNULL(Source_PK)
- Default - used for Update
- Insert an Update Transformation coming form the Delete Group using DD_DELETE
- Connect this transformation to the Target
- Insert a Filter Transformation coming from the Update Group (Modify as needed to compare all non-key fields)
(
DECODE(Source_Field1, Target_Field1, 1, 0) = 0
OR
DECODE(Source_Field2, Target_Field2, 1, 0) = 0
)
- Insert an Update Transformation coming from the Filter Transformation using DD_UPDATE
- Connect this transformation to the Target
- Connect the Insert Group in the Router Transformation to the Target