You can use a dynamic lookup cache to insert and update rows in the target. When you use a dynamic lookup cache, you can insert and update the same rows in the cache that you insert and update in the target.
For example, you need to update a table that contains customer data. The source data contains rows of customer data to insert or update in the target. Create a dynamic cache that represents the target. Configure a Lookup transformation to lookup customers in the dynamic cache.
The following figure shows a mapping that has a Lookup transformation with a dynamic lookup cache:
The Router transformation splits into two branches. The Router transformation passes insert rows into one branch and update rows into the other branch. Each branch contains an Update Strategy transformation that writes rows to the target. Both branches contain the same target.
When the mapping starts, the Integration Service builds the lookup cache from customer target table. When the Integration Service reads a row that is not in the lookup cache, it inserts the row in the cache.
The Lookup transformation returns each row to a Router transformation. Based on whether the row is marked for insert or update, the Router transformation directs the row to one of the Update Strategy transformations. The Router transformation determines whether rows are marked for insert or update based on the NewLookupRow property. The Update Strategy transformations mark each row as insert or update before passing it to the target.
The customer target table changes as the mapping runs. The Integration Service inserts new rows and updates existing rows in the lookup cache. The Integration Service keeps the lookup cache and customer target table synchronized.
To generate keys for the target, use Sequence-ID in the associated port. The Integration Service uses the sequence ID as the primary key for each new row inserted into the target table.
You increase session performance when you use a dynamic lookup cache because you build the cache from the database once.