How to get mutiple records values into a single record value

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
mohanraj
Participant
Posts: 48
Joined: Sat Mar 25, 2006 12:40 am
Location: bangalore

How to get mutiple records values into a single record value

Post by mohanraj »

I have an input columns in the following format :

columnA column B
111 ABC is working
123 ZYX is working
111 in Pune
123 in Delhi

I would like my output to be

columnA columnB
111 ABC is working in Pune
123 ZYX is working in Delhi


What kind of stage variables will allow me to accomplish the above transformations ?

Thanks in Advance
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

mohanraj wrote:What kind of stage variables ... ?
Provided data are partitioned on ColumnA and sorted on ColumnA using a stable sort, then you can use standard stage variables to assemble your required output string. Follow the Transformer stage with a Remove Duplicates that allows only the last row of each group to pass.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ysrini9
Participant
Posts: 108
Joined: Tue Jul 12, 2005 2:51 am

Post by ysrini9 »

Hi ,
I believe below mentioned logic will work.
you can use 4 stage variables in Transformer stage i.e.,
s1:ColumnB
s2:if ColumnA<>s4 then s1 else s3:s1
s3:s2
s4:Column A



Thanks & Regards
Srini Y
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

What's the purpose of stage variable s1 ?

As far as I can tell, it does not do anything.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ysrini9
Participant
Posts: 108
Joined: Tue Jul 12, 2005 2:51 am

Post by ysrini9 »

Stage variable 1 for reading ColumnB.

I tried on the above logic ,It's working fine.
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

ysrini9 wrote:Stage variable 1 for reading ColumnB.

I tried on the above logic ,It's working fine.
You missed his point, column B is freely available without assigning it to a stage variable first.

Haven't actually thought about it before but could you have

Code: Select all

s2:if ColumnA<>s4 then ColumnB else s[b]2[/b]:ColumnB
(that is, a reference to itself in its previous incarnation)

PS, suspect a " " needs to go in there too...
mohanraj
Participant
Posts: 48
Joined: Sat Mar 25, 2006 12:40 am
Location: bangalore

Post by mohanraj »

Thanks a lot Everyone :)
Post Reply