Assign Value if duplicate 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 if duplicate record

Post by Cherukuri »

Hi,

Please find question below:

Input data:

PlateNo ItemNo ItemID GroupId SeqNo
LS10 AB 25 251 1
LS10 AB 25 251 2
LS5 CD 27 253 1
LS5 CD 27 253 2

Should populate output as :

PlateNo ItemNo ItemID GroupId SeqNo IDCL
LS10 AB 25 251 1 2
LS5 CD 27 253 1 2

if the values for the fileds PlateNo,ItemNo,ItemID,GroupId,SeqNo are same then IDCL new column should create
and the 2nd dublicate record seqNo value should be populate in IDCL.

Please can any one help me on this.

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

Post by ray.wurlod »

This is a very simple Pivot, based on the first three columns as pivot key.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Cherukuri
Participant
Posts: 46
Joined: Wed Jul 25, 2007 2:43 am
Location: India
Contact:

Post by Cherukuri »

Could you please explain more..Thank you.
Cheru
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

If you look at this link it describes how to make a vertical or horizontal pivot. Once you read that and have tried to make the pivot work and still have a question then we should continue here.
bhasds
Participant
Posts: 79
Joined: Thu May 27, 2010 1:49 am

Post by bhasds »

Hi Cherukuri,

If you are still looking for any logic which can be used in transformer then the below two should give you desired out put-

ONE.

step1-read those 5 columns in a single column in seq file stage and passs to the transformer

step2-take two stage variable in transformer-

Code: Select all

If Trim(colname,Field(colname," ",Dcount(colname," ")),"T") <> SV2 Then Colname Else SV1 :" ":Field(colname," ",Dcount(colname," "))                                                               SV1

Trim(colname,Field(colname," ",Dcount(colname," ")),"T")        SV2(initialise with "")
stpe3- in derivationconstraint-

Code: Select all

Dcount(SV1," ") > Dcount(DSLink105.col1," ")
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or you could just pivot it as this one is as simple as they get so why complicate it?
-craig

"You can never have too many knives" -- Logan Nine Fingers
bhasds
Participant
Posts: 79
Joined: Thu May 27, 2010 1:49 am

Post by bhasds »

TWO

step1- same as ONE
step2-

Code: Select all

If Trim(colname,Right(DSLink105.col1,1),"T") <> SV2 Then colname Else SV1 :" ":Right(colname,1)                SV1

Trim(colname,Right(colname,1),"T")            SV2
step3- Same as ONE.

However, as said by Craig you can still do it through Pivot enterprise stage.
Post Reply