how to assign next value to the current record

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
rajendharreddy
Participant
Posts: 46
Joined: Tue Aug 21, 2007 5:39 am
Location: Bangalore, India

how to assign next value to the current record

Post by rajendharreddy »

Hi,

I need help on the following requirement.

I have input in the following format.

Input
-----

A|B
a|5
b|8
c|17
d|35

I need the output in the following format. I need to load B column data into new column (i.e. C) and push one row above.

Output
-------

A|B|C
a|5|8
b|8|17
c|17|35
d|35|

I know we can get this by using stage variables. I tried but i couldn't complete.

Can anybody help me on the same.

Thanks..
Raghavendra
Participant
Posts: 147
Joined: Sat Apr 30, 2005 1:23 am
Location: Bangalore,India

Post by Raghavendra »

First sort the data then using a copystage send the rows to two links.

On the first link add a new column (KEY) with generated numbers from 1.
On the second link add another column(KEY) with generated numbers from 0.

Join both the links using generated column (KEY) as a key column. The First Link will be Primary link.

Hope this solves your problem.
Raghavendra
Dare to dream and care to achieve ...
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You can sort the data in reverse order and use stage variables to get previous rows value.
Post Reply