Hi,
I have a Key Columns that contains duplicates records. I need to generate Key whenever the value of the Key Column Changes. How to achive this using transformer stage and not surrogate key stage.
Example:
Id Addr
1 a1
1 a2
1 a3
2 b1
Result Expected:
Id Addr AId
1 a1 01
1 a2 01
1 a3 01
2 b1 02
R
Pav
How to Compare Current Record with Previous record
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 4
- Joined: Fri Apr 10, 2009 2:34 am
- Location: India
The simplest method would be to generate a keyChange column in a sort stage preceding the transformer. keyChange = 1 when a record has a new key value, 0 when the same as the previous record.
When you see keyChange = 1, generate a new Key otherwise use the same key as for the previous record.
Regards,
When you see keyChange = 1, generate a new Key otherwise use the same key as for the previous record.
Regards,
- james wiles
All generalizations are false, including this one - Mark Twain.
All generalizations are false, including this one - Mark Twain.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Welcome aboard.
There are over 250,000 answers to be found on DSXchange, including the answer to your question. In the menu at the top of the page is a link to the Search facility. (Tip: prefer Exact Search whenever possible.)
There are over 250,000 answers to be found on DSXchange, including the answer to your question. In the menu at the top of the page is a link to the Search facility. (Tip: prefer Exact Search whenever possible.)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
That's an overly complex solution. It can be done readily with two stage variables. The only thing that is important is the order of execution (a) of the stage variables and (b) of the data (what does "previous" mean when the data are partitioned?).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.