Holding Previous Record Value

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
rkdatastage
Participant
Posts: 107
Joined: Wed Sep 29, 2004 10:15 am

Holding Previous Record Value

Post 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
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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.
bikan
Premium Member
Premium Member
Posts: 128
Joined: Thu Jun 08, 2006 5:27 am

Post 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
rkdatastage
Participant
Posts: 107
Joined: Wed Sep 29, 2004 10:15 am

Post by rkdatastage »

Hi Andrew

Thanks for your prompt response

i had tested it and it is working fine

Thanks alot

RK
bikan
Premium Member
Premium Member
Posts: 128
Joined: Thu Jun 08, 2006 5:27 am

Post 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
rkdatastage
Participant
Posts: 107
Joined: Wed Sep 29, 2004 10:15 am

Post 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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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;
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply