Thursday 18 April 2013

Holding Previously Processed Row Values

We all know that in Powercenter  transformations in a mapping reads, process and loadsone record at a time. There might be situations where you want to compare the currently processing row values with the previously processed row values or to use in the calculations.
what will you do? Whats the trick thats works for you.

Variable ports ports do the trick here, Yes.
We can make powercenter to hold the previously processed records by making use of the Variable ports.
IF you want to hold the customer_id make following changes in the expressio ntransformation.
1.Take two variable ports above the customer_id say,v_custid and prev_cust_id.
The ports in expression will be

PORT            TYPE      EXPRESSION
prev_cust_id      v           v_custid
v_custid             v           customer_id
customer_id       i/o         customer_id

You are done! Yes, prev_cust_id holds previously processed customer_id.
How it works? lets see.

If customer_id has the values as 1,2,3.....

When the first record reaches the expression transformation the values will be
prev_cust_id      null
v_custid             1
customer_id       1

When the second record reaches the expression transformation the values will be

prev_cust_id      1
v_custid             2
customer_id       2

You can observe this by running the Debugger Instance.

You can do the same for any column for which you need the previously processed value.

Note:
The  order of the column defined above should be the same.




Hope this helps.

No comments:

Post a Comment