For example, you create a mapping with the following objects:
For the Lookup transformation, you enable dynamic lookup caching and define the following lookup condition:
IN_CUST_ID = CUST_ID
By default, the row type of all rows entering the Lookup transformation is insert. To perform both inserts and updates in the cache and target table, you select the
Insert Else Update
property in the Lookup transformation.
Initial Cache Values
When you run the mapping, the Integration Service builds the lookup cache from the target table.
The following table shows the initial values of the lookup cache:
PK_PRIMARYKEY
CUST_ID
CUST_NAME
ADDRESS
100001
80001
Marion James
100 Main St.
100002
80002
Laura Jones
510 Broadway Ave.
100003
80003
Shelley Lau
220 Burnside Ave.
Input Values
The source contains rows that exist and rows that do not exist in the target table. The Integration Service passes the source rows into the Lookup transformation.
The following table shows the source rows:
SQ_CUST_ID
SQ_CUST_NAME
SQ_ADDRESS
80001
Marion Atkins
100 Main St.
80002
Laura Gomez
510 Broadway Ave.
99001
Jon Freeman
555 6th Ave.
Lookup Values
The Integration Service looks up values in the cache based on the lookup condition. It updates rows in the cache for existing customer IDs 80001 and 80002. It inserts a row into the cache for customer ID 99001. The Integration Service generates a new key (PK_PRIMARYKEY) for the new row.
The following table shows the rows and values returned from the lookup:
PK_PRIMARYKEY
CUST_ID
CUST_NAME
ADDRESS
100001
80001
Marion Atkins
100 Main St.
100002
80002
Laura Gomez
510 Broadway Ave.
100004
99001
Jon Freeman
555 6th Ave.
Output Values
The Integration Service flags the rows in the Lookup transformation based on the inserts and updates it performs on the dynamic cache. The Integration Service eventually pass the rows to a Router transformation that creates a branch for insert rows and another branch for update rows. Each branch contains an Update Strategy transformation. The Update Strategy transformations flag the rows for insert or update based on the value of the NewLookupRow port.
The output values of the lookup/output and input/output ports depend on whether you choose to output old or new values when the Integration Service updates a row. However, the output values of the NewLookupRow port and any lookup/output port that uses the sequence ID is the same for new and updated rows.
If you choose to output new values, the lookup/output ports output the following values:
NewLookupRow
PK_PRIMARYKEY
CUST_ID
CUST_NAME
ADDRESS
2
100001
80001
Marion Atkins
100 Main St.
2
100002
80002
Laura Gomez
510 Broadway Ave.
1
100004
99001
Jon Freeman
555 6th Ave.
If you choose to output old values, the lookup/output ports output the following values:
NewLookupRow
PK_PRIMARYKEY
CUST_ID
CUST_NAME
ADDRESS
2
100001
80001
Marion James
100 Main St.
2
100002
80002
Laura Jones
510 Broadway Ave.
1
100004
99001
Jon Freeman
555 6th Ave.
When the Integration Service updates rows in the lookup cache it uses the primary key (PK_PRIMARYKEY) values for rows in the cache and the target table.
The Integration Service uses the sequence ID to generate a primary key for the customer that it does not find in the cache. The Integration Service inserts the primary key value into the lookup cache and it returns the value to the lookup/output port.
The Integration Service outputs the values from the input/output ports that match the input values.
If the input value is NULL and you select the Ignore Null property for the associated input port, the input value does not equal the lookup value or the value out of the input/output port. When you select the Ignore Null property, the lookup cache and the target table might become unsynchronized if you pass null values to the target. You must verify that you do not pass null values to the target.