Page 1 of 1

Previous Record Values

Posted: Mon Oct 25, 2004 5:11 pm
by c341
Hi
I need to know how to get the previously processed records value.
In transformer I have condition ...Current value - Previous value.
Thank You
Regards - c341

Posted: Mon Oct 25, 2004 7:58 pm
by rasi
Hi

You have set of routines under sdk/RowProc folder.

In that you can use RowProcGetPreviousValue to get the previous value for that column. Also you can do a compare using RowProcCompareWithPreviousValue.

Thanks
Siva

Posted: Mon Oct 25, 2004 8:23 pm
by ray.wurlod
You can use a pair of stage variables, and rely on the fact that stage variables are processed in the order in which they are defined in their grid.
Techniques have been posted before, search them out. Quick example:

Code: Select all

svIsChanged    If (InLink.ColName<> svPrevValue) Then 1 Else 0
svPrevValue    InLink.ColName
In this example, when stage variable svIsChanged is being evaluated, stage variable svPrevValue still contains the value of InLink.ColName from the previous row.
A more appropriate derivation for svIsChanged is

Code: Select all

If (InLink.ColName <> svPrevValue)  And (@INROWNUM <> 1) Then 1 Else 0
or, more simply

Code: Select all

InLink.ColName <> svPrevValue And @INROWNUM <> 1 

Posted: Tue Oct 26, 2004 9:20 am
by dsxdev
Rigthly said you can use Stage variables to hold prevoius record's value and use it in current record. Stage variable are caluculated in the order they are defined.If you set default value for a stage variable you avoid teh @INROWNUM also

Code: Select all

If (InLink.ColName <> svPrevValue) Then 1 Else 0

Posted: Tue Oct 26, 2004 3:50 pm
by ray.wurlod
You need to be totally sure that any initial value that you assign to a stage variable will never, ever appear in data. Including @INROWNUM <> 1 is a mechanism that I call "idiot proofing".