Page 1 of 1

Holding Previous Record Value

Posted: Tue Jan 23, 2007 3:20 am
by rkdatastage
Hi All

I had a Doubt in this, Kindly give me some thought process to resolve this

I had a flat file where it is having 1 column i had to load the data into target table/file , the validation that i had to check is that i had to compare the immdiate previous record against the current Value. What are the possible ways i can achive with in datastage Environment.

Ex :
Column 1
-----------
1
2
3
4
4
5
6
6
7
---------

for the first record i had to load it as it is to target , from second record on wards i had to check it against previous record, if it matches i had to reject the record.

Like 1, 2=1,3=2,4=3,4=4 i had to reject it

Expecting an valid support from the Group

Thanks in Advance
RK

Posted: Tue Jan 23, 2007 3:31 am
by ArndW
This is easily done by storing the value in a transform stage variable and then using that saved value for comparing the next record.

Code: Select all

ComparisonStageVar = In.CurrentRowColumnA > PreviousValue
PreviousValue = In.CurrentRowColumnA
These two stage variables show how such a comparison could easily be done in a transform stage.

Posted: Tue Jan 23, 2007 4:02 am
by bikan
Mate

Try using RowProcCompareWithPreviousValue Routine which is written by Datastage which will solve ur problem. The routine will give you the output as below

Example:

Input Returns

1 0
1 1
1 1
2 0
3 0
4 0
4 1
4 1
5 0

Posted: Tue Jan 23, 2007 4:03 am
by rkdatastage
Hi Andrew

Thanks for your prompt response

i had tested it and it is working fine

Thanks alot

RK

Posted: Tue Jan 23, 2007 4:05 am
by bikan
Mate

Try using RowProcCompareWithPreviousValue Routine which is written by Datastage which will solve ur problem. The routine will give you the output as below

Example:

Input Returns

1 0
1 1
1 1
2 0
3 0
4 0
4 1
4 1
5 0

Posted: Tue Jan 23, 2007 4:08 am
by rkdatastage
Hi Andrew

Thanks for your prompt response

i had tested it and it is working fine

Added to this one more query

suppose if i want to populate my reject table , which ever the records had equal

like
Column1
-----------
1
2
3
4
4
5
6
6
7
-----------

In earlier case it is loading the data into target as below
Column1
----------
1
2
3
4
5
6
7
---------------
In Reject table it is loading as below
Column1
----------
4
6
----------


My Query is i doesn't want to populate the values 4,6 into the target table

my reject table will have to have these values
Column1
-----------
4
4
6
6
---------------

How Can i Proceed

Thanks alot and thanking you in advance

RK

Posted: Tue Jan 23, 2007 4:47 am
by ray.wurlod
Not "Andrew", but "Arnd". Arnd W.

Your easiest solution is to insert all keys (Column 1 values) into an intermediate table (use a UV stage, re-creating the table). Then take two output links from this stage.

The one to the target has

Code: Select all

SELECT Column1 FROM table GROUP BY Column1 HAVING Count(Column1) = 1;
The one to the rejects table has

Code: Select all

SELECT Column1 FROM table GROUP BY Column1 HAVING Count(Column1) > 1;