Thursday, February 21, 2013

NewLookupRow vs Update Dynamic Cache Condition vs Associated Expression

There are some neat new features in Informatica PowerCenter 9.1 Lookup Transformation: Update Dynamic Cache Condition and Associated Expression.



 I wanted to try and use them. Here are the details.

SCENARIO:
Each incoming row has a column named 'Version'. We want to check the dynamic cache in lookup to find out if it's newer or older than the cached one. If it is a new version, we want to store it - otherwise we want to discard it. The versions come in random order.

SOLUTION:
I set the Update Dynamic Cache Condition to check if incoming Version is larger that existing Version. I also set the Associated Expression on Sequence to be equal to itself.
NOTE: There is some strange behavior here - you can't simply check the 'Ignore in comparison' box. You need to swich to some other port, check the box, than swich to Associated Expression again.
I also marked it to be ignored in comparison (which shouldn't make any difference, in fact).


What are the results? First version has been inserted to DB, but it never got updated. What was wrong? I forgot to check the Insert Else Update box:


Now everything started to run smoothly. However I wondered what is the logic behind Update Dynamic Cache Condition vs NewLookupRow. After few experiments I came with the following.

CONCLUSION:

If Insert Else Update property is checked:
NewLookupRow =/= 0 when both are TRUE: Update Dynamic Cache Condition resolves to TRUE AND one of the ports is different than its Associated Port or the result of the Associated Expression, i.e.:

  • first, the Associated Expression is executed
  • second, the AE result is compared to port value
If one of the conditions mentioned above is false (eg. UDCC resolves to false OR there are no port differences) the NewLookupRow will be equal to 0.
In other words, it's not the AE that needs to be TRUE, but the result of comparison between port value vs result of AE.

If Insert Else Update property is NOT checked, NewLookupRow is equal to 1 for a new row and 0 for any existing - despite the result of Update Dynamic Cache Comparison or difference in ports.


No comments:

Post a Comment