Pick Up only last row...

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
murur
Participant
Posts: 19
Joined: Wed Apr 14, 2004 7:55 am

Pick Up only last row...

Post by murur »

I have 3 output link in one transformer stage. In one link I want to take only the last row. I need to ignore all other rows. Is there any way to exclude all rows except the last row using constraint or any other method.....
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Via a constraint? No, there really isn't a mechanism to recognize the 'last' row... unless you make sure it is something recognizable by adding a dummy/trailer record of your own, for instance.

A couple of other approaches. Can you sort the data so that the row you want comes first instead of last? Then a simple constraint can help you out. Something else to do is use the Aggregator to get the LAST value for the fields you are interested in. Also, if there is some way for you to count the records before the job starts, then pass in the record number of the last row as a parameter and constrain for it...
-craig

"You can never have too many knives" -- Logan Nine Fingers
ds_developer
Premium Member
Premium Member
Posts: 224
Joined: Tue Sep 24, 2002 7:32 am
Location: Denver, CO USA

Post by ds_developer »

Write that link to a hashed file with a hard coded key. The last row will be the only one remaining in the file. Then write the one hashed file record where you want it.

John
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or do that! :lol: Always more than one way to skin a DataStage cat.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Write that link to a sequential file, then read it again with tail -1 as the filter command.

Poor skinless cat!! :lol:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

The last record in a hash file may not be the last one written. Based on if cache is turned on or off this changes. Ray's method should be faster too.
Mamu Kim
raj_cipher
Participant
Posts: 90
Joined: Mon Dec 08, 2003 4:48 am
Location: Chennai

Post by raj_cipher »

kim,

could u elaborate on that?
Think Ahead,
Raj.D
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

If cache is turned on then it will not overwrite a record. It uses the first one in. I think this is still true for Ds7.
Mamu Kim
Post Reply