Create an output record when zeros rows are passed thro it

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
vnspn
Participant
Posts: 165
Joined: Mon Feb 12, 2007 11:42 am

Create an output record when zeros rows are passed thro it

Post 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.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post 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.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rajee
Participant
Posts: 46
Joined: Thu Mar 13, 2008 7:06 am
Location: India

Post 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
keshav0307
Premium Member
Premium Member
Posts: 783
Joined: Mon Jan 16, 2006 10:17 pm
Location: Sydney, Australia

Post 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.
OddJob
Participant
Posts: 163
Joined: Tue Feb 28, 2006 5:00 am
Location: Sheffield, UK

Post 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.
vnspn
Participant
Posts: 165
Joined: Mon Feb 12, 2007 11:42 am

Post by vnspn »

Thanks all for your suggestions.

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