Assign value for more then one record

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
Cherukuri
Participant
Posts: 46
Joined: Wed Jul 25, 2007 2:43 am
Location: India
Contact:

Assign value for more then one record

Post by Cherukuri »

Hi,

I have a requirement as shown below:

Input Records:

Coulmn1 Column2
123 AF
XC RG
qw aa
POP aa
RT NN
FM AF


OutPut Records:

Coulmn1 Column2
123 XX
XC RG
qw XX
POP XX
RT NN
FM XX


If values for Column2 input file has repeated vlaue like more then one then those records should replace with 'XX', if unique then the same records.

Please help how can we do this.

Thanks and Regards,
Cheru
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

Quick question first - what is your source?
Cherukuri
Participant
Posts: 46
Joined: Wed Jul 25, 2007 2:43 am
Location: India
Contact:

Post by Cherukuri »

My Source is a .txt File.

thanks and Regards,
Cheru
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

Hmm.

2 ways spring to mind.

Option 1
1. Sort by Column 2, then by column 1. Add a keyChange columns
2. In a transformer, on the input link re-sort by column 2, keychange asc.
3. In a stage variable (sv1), hold the value of column 2 where keychange = 0
4. In another stage variable have the logic: If keyChange = 0 then 'XX' else if input.column2 = sv1 then 'XX' else input.Column2

Option 2
1. Split off column2 through an aggregator and perform a count on column2.
2. Join the count column back to the data stream using column 2 as the key.
3. In a transformer, check if the count column is greater than 1, and if true then set output to 'XX'

Or something like that.
Post Reply