Page 1 of 1

Pick Up only last row...

Posted: Fri Apr 30, 2004 1:04 pm
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.....

Posted: Fri Apr 30, 2004 1:46 pm
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...

Posted: Fri Apr 30, 2004 3:03 pm
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

Posted: Fri Apr 30, 2004 4:12 pm
by chulett
Or do that! :lol: Always more than one way to skin a DataStage cat.

Posted: Fri Apr 30, 2004 5:50 pm
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:

Posted: Mon May 03, 2004 8:54 am
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.

Posted: Mon May 03, 2004 12:38 pm
by raj_cipher
kim,

could u elaborate on that?

Posted: Mon May 03, 2004 1:12 pm
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.