Stage variable on duplicates..

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
meena
Participant
Posts: 430
Joined: Tue Sep 13, 2005 12:17 pm

Stage variable on duplicates..

Post by meena »

Good Morning..
I am designing a job which has to handle duplicates.

Job design: Extract data from sequential file to load into oracle table( using DRS Stage) and a transformer stage to check for constraint & for some transformations logic.

Logic: For handling duplicates I am working on stage variables and on a constraint in the transformer stage:

Stage variable=in.field1
Stage variable1=in.field2
Stage varaible2=in.field3
Stage variable3=If (in.field1=Stage variable and in.field2=Stage variable1 and in.field3=Stage variable2) then 1 else 0

And

Constraint in transfomer: Stage variable3<>1
I also checked with Stage variable3=0..

All rows goes into reject file instead of duplicates. I have worked with this logic earlier but know I am facing problem to implement.

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

Post by ray.wurlod »

To remember the previous row you need to record the value AFTER performing the comparison.

Code: Select all

svIsChanged  <==  (InLink.TheColumn <> svPrevValue) And (@INROWNUM > 1)
svPrevValue  <==  InLink.TheColumn
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Why complicate it so much? Three variables like so:

svNewKey: in.field1 : '|' : in.field2 : '|' : in.field3
svIsDup: svNewKey = svOldKey
svOldKey: svNewKey


Make sure you have a decent initial value for the stage variables and you handle nulls in svNewKey if any of the three fields are nullable. Then your constraint could be:

Not(svIsDup)

Isn't that easier to understand?
-craig

"You can never have too many knives" -- Logan Nine Fingers
meena
Participant
Posts: 430
Joined: Tue Sep 13, 2005 12:17 pm

Post by meena »

Thanks Ray & Craig,

Both logics worked for me.

regards,
Meena
ganesh123
Participant
Posts: 70
Joined: Tue Feb 20, 2007 3:22 pm
Location: NJ,USA
Contact:

Post by ganesh123 »

Please mark the topic resolved.
If women didn't exist, all the money in the world would have no meaning.
-- Aristotle Onassis
Post Reply