Error while using Transforms RowProcCompareWithPreviousValue

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
asvictor
Participant
Posts: 31
Joined: Tue Sep 02, 2003 3:06 am
Location: Singapore
Contact:

Error while using Transforms RowProcCompareWithPreviousValue

Post by asvictor »

HI,

I was trying to use RowProcCompareWithPreviousValue and am getting wrong results it always returns 1 as a return value even if there is a difference in the Value. Is there any restriction in using this Transforms. Do I need to use only String as datatype or use only tables to compare?
I tried to take a Seq File and sort it and Compare the Previous value and assigning a running no for the Records.

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

Post by ray.wurlod »

Have you read the caveat in the long description of the Transform? In particular, are you using the same Transform more than once in the same process-chain in the job?

You may find it easier/better to use a pair of stage variables in a Transfomer stage to detect change; and this approach does not use COMMON, one of the contraindicators for using row buffering.

Variables might be called varHasChanged and varPrevValue. The varHasChanged variable is declared earlier than varPrevValue. varHasChanged is initialized to @FALSE, varPrevValue is initialized to anything you like. Derivation expressions are:

Code: Select all

varHasChanged:  InLink.colname <> varPrevValue AND @INROWNUM > 1
varPrevValue:   InLink.colname
Of course, this approach relies upon the input stream being sorted by values of colname.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Ray is correct. The compare routine uses @USER variables to store values which do not work if you call it more than once or have multiple transforms. Stage variables are far more reliable.

Kim.
Mamu Kim
thurmy34
Premium Member
Premium Member
Posts: 198
Joined: Fri Mar 31, 2006 8:27 am
Location: Paris

Post by thurmy34 »

Hi all,
Maybe should i create a new topic but i want to let you what i found with RowProcCompareWithPreviousValue.

I use it to eliminate duplicate records in a transformer.
The strange thing is that sometimes i had false duplicate.

Code: Select all

ex 
   330285131|20081130 
   330285131|20081230 --> 0
   330285131|20081231 --> 1 (witch it's wrong).
I changed to the two variables way but the results was the same.
I resolved the problem by changing the order of the "key"

Code: Select all

ex 
   20081130|330285131
   20081230|330285131 --> 0
   20081231|330285131 --> 0 (ok now).
Hope This Helps
Regards
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So... do you actually have a question or is this just an informational post? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
thurmy34
Premium Member
Premium Member
Posts: 198
Joined: Fri Mar 31, 2006 8:27 am
Location: Paris

Post by thurmy34 »

It's just informational like a How to.
Hope This Helps
Regards
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That's 8) just wanted to be sure we didn't leave you hanging.
-craig

"You can never have too many knives" -- Logan Nine Fingers
thurmy34
Premium Member
Premium Member
Posts: 198
Joined: Fri Mar 31, 2006 8:27 am
Location: Paris

Post by thurmy34 »

I appreciate
Post Reply