Page 1 of 1

Create an output record when zeros rows are passed thro it

Posted: Tue Apr 22, 2008 10:07 am
by vnspn
Hi,

We have a requirement where we aggregate a few records and write the record count out to a sequential file. When zero records are passed through the Aggregator, the output of the Aggregator does not write any record on the output file. But we have a need where we have to write the record count value as "0" (zero) in such a case.

Please let us know if anyone have handled such kind of thing before.

Thanks.

Posted: Tue Apr 22, 2008 11:04 am
by kcbland
Easy. Always pass one row by fabricating one. You can do this many ways, just make sure it doesn't skew counts or averages.

Posted: Tue Apr 22, 2008 9:02 pm
by Rajee
hi,

I did it in the after job subroutine through unix command by checking for the word count in the file.if the wordcount in the file is 0 then i appended 0 to the file.
But now i need the same to be implemented in windows server for which I am not able to find the command to do the above check.
Kindly anyone let me know about how it can be done for windows server.

Thx,
Rajee

Posted: Tue Apr 22, 2008 10:21 pm
by keshav0307
you can have another file with a column having all values for which you want count in the source file.
after aggregator outer join with this file.

Posted: Wed Apr 23, 2008 7:18 am
by OddJob
I had a similar issue and used a join stage - full outer join.

One input to the join would be from the Aggregator - you'll need to add a new column e.g. Key, hard coded to value of 1 using a transformer.

The other input to the join comes from a row generator that creates one record with the same field Key, again hard coded to 1.

The outer join will always produce 1 record because of the row generator, you can then test for null from the aggregator's count field and default to zero as required. Make sure the count field is nullable.

Posted: Wed Apr 23, 2008 12:17 pm
by vnspn
Thanks all for your suggestions.

I did it by using a Row Generator and then a full outer Join.