compare values in transformer stage

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

ravi7487
Premium Member
Premium Member
Posts: 25
Joined: Sat Feb 05, 2011 10:03 pm

compare values in transformer stage

Post by ravi7487 »

Hi,

how can i remove duplicates in transformer stage using stage variables?

I have only one column in my source,
payment ID
100
100
101
103
102
101
104

after sorting and hash partitioning in transformer stage, Could you please explain me the logic?
Last edited by ravi7487 on Tue Aug 30, 2011 9:16 am, edited 1 time in total.
ds_sai
Participant
Posts: 27
Joined: Wed Oct 31, 2007 12:22 pm

Re: compare values in transformer stage

Post by ds_sai »

Is it possible for you to use the distinct function in the Source when you are getting all these values or do you have specific requirement to do this in transformer stage..
ravi7487
Premium Member
Premium Member
Posts: 25
Joined: Sat Feb 05, 2011 10:03 pm

Post by ravi7487 »

Thank you for replying, I have to use transformerstage and stage variables. Please letme know the logic. Thank you verymuch
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Is this an interview question?

WHY must you use a Transformer stage?

Have you performed a Search of DSXchange? Very similar questions have been asked and answered even quite recently, such as this one.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ravi7487
Premium Member
Premium Member
Posts: 25
Joined: Sat Feb 05, 2011 10:03 pm

Post by ravi7487 »

hh
Last edited by ravi7487 on Tue Aug 30, 2011 9:16 am, edited 1 time in total.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Switch the order of the stage variables.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ravi7487
Premium Member
Premium Member
Posts: 25
Joined: Sat Feb 05, 2011 10:03 pm

Post by ravi7487 »

Hi chulett, thanks for replying

now i gave as

If DSLink2.deptno = Lastvalue then 1 else 0 = Isdup
DSLink2.deptno= Lastvalue

constraint : Isdup=0

I could not remove duplicate values. Could you Please explain me the logic? Do I have to set any defualt value to Lastvalue?

Thanks
ravi7487
Premium Member
Premium Member
Posts: 25
Joined: Sat Feb 05, 2011 10:03 pm

Post by ravi7487 »

can anyone please let me know the logic to compate two values using stage variables?

col1

100
100
200
300
200
400

what will be the initial value of the Lastvalue in the below logic?

If DSLink2.deptno = Lastvalue then 1 else 0 = Isdup
DSLink2.deptno= Lastvalue

constraint : Isdup=0
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It has already been given, even in this thread.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ravi7487
Premium Member
Premium Member
Posts: 25
Joined: Sat Feb 05, 2011 10:03 pm

Post by ravi7487 »

Ray, Chulett told me to switch the order of the stage variables, so i put it as

now i gave as

If DSLink2.deptno = Lastvalue then 1 else 0 = Isdup
DSLink2.deptno= Lastvalue

constraint : Isdup=0

i still not able to remove duplicate values? could you please help? to remove the duplicate values, the comparision is always from current variable to previous variable, but, for the first current variable, what will be the previous variable?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

ravi7487 wrote:for the first current variable, what will be the previous variable?
Whatever you put in the Initial Value of the stage variable when you define it.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ravi7487
Premium Member
Premium Member
Posts: 25
Joined: Sat Feb 05, 2011 10:03 pm

Post by ravi7487 »

Thank you for clarifying, But what initial value should I put in for the previous value?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Whatever non-null value will not match with anything that might come in on the first record.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ravi7487
Premium Member
Premium Member
Posts: 25
Joined: Sat Feb 05, 2011 10:03 pm

Post by ravi7487 »

Please tell me the logic, I am not able to get it, thank you
ravi7487
Premium Member
Premium Member
Posts: 25
Joined: Sat Feb 05, 2011 10:03 pm

Post by ravi7487 »

Could you please tell me the logic how to compare two values in transformer?
Post Reply