Last record missing while using the stage variables to compa

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
kusuma
Participant
Posts: 13
Joined: Fri Sep 05, 2003 7:36 am
Location: India

Last record missing while using the stage variables to compa

Post by kusuma »

Hi all,

I have input data in sorted order which looks like

Key Code
100 cd1
200 cd2
200 cd3
300 cd4
400 cd5
400 cd6
400 cd7....

My output should be

Key Code
100 cd1
200 cd2,cd3
300 cd4
400 cd5,cd6,cd7....

In order to accomplish this logic I am using the stage variables. It is working fine but the last Key is missing in the output data. I know this is because I am comparing the previous record after reading the next record(that is the basic meaning of compare :) ) and then writing to the output. This way when I reach the last record I compare it with last but one record and write the last but one record to my output. Because there is nothing to compare with the last record, it is just ignoring the last record/Key.

Is there a function or a way to capture the last key in the DataStage Transformer?

Thanks
Kusuma
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

u can use pivot stage
hi sam here
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

u can also search in the forum for vertical pivot or click here viewtopic.php?t=97681&highlight=vertical+pivot
hi sam here
kusuma
Participant
Posts: 13
Joined: Fri Sep 05, 2003 7:36 am
Location: India

Re: Last record missing while using the stage variables to c

Post by kusuma »

I guess, I can not use Pivot Stage.

Sam thanks for the vertical pivot link.
kusuma wrote:Hi all,

I have input data in sorted order which looks like

Key Code
100 cd1
200 cd2
200 cd3
300 cd4
400 cd5
400 cd6
400 cd7....

My output should be

Key Code
100 cd1
200 cd2,cd3
300 cd4
400 cd5,cd6,cd7....

In order to accomplish this logic I am using the stage variables. It is working fine but the last Key is missing in the output data. I know this is because I am comparing the previous record after reading the next record(that is the basic meaning of compare :) ) and then writing to the output. This way when I reach the last record I compare it with last but one record and write the last but one record to my output. Because there is nothing to compare with the last record, it is just ignoring the last record/Key.

Is there a function or a way to capture the last key in the DataStage Transformer?

Thanks
Kusuma
Post Reply