Zero count

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
datastagenewbie
Participant
Posts: 64
Joined: Tue Sep 23, 2008 9:54 am

Zero count

Post by datastagenewbie »

:?: I have a situation where i count the records in a file and when the file is empty I need the count to be zero. But In DataStage it is not outputting anything. :cry:
Please advise.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Yes, that seems like a reasonable requirement.

What do you get out of DataStage when there ARE records in the file? How are you calculating this?
Think about how any calculation could be performed if no records are passing through the job.

What you need to do is to detect whether the file is empty (perhaps in a Routine activity, perhaps in an Execute Command activity). Based on that result, either write 0 to the target or run the DataStage job.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
datastagenewbie
Participant
Posts: 64
Joined: Tue Sep 23, 2008 9:54 am

Post by datastagenewbie »

To get the count, I am creating a dummy key column and counting it in the aggregator.
As a workaround I am having a row generator generate a zero value, and add it to the count from the aggregator(above).
So, even if nothing is in the file the value will be zero.
datastagenewbie
Participant
Posts: 64
Joined: Tue Sep 23, 2008 9:54 am

Post by datastagenewbie »

ray.wurlod wrote:Yes, that seems like a reasonable requirement.

What do you get out of DataStage when there ARE records in the file? How are you calculating this?
Think about how any calculation could be performed ...
I am not a premium member, so I don't know if you already provided the solution or not...sometimes I wish I was a premium member. :-(
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

datastagenewbie wrote:sometimes I wish I was a premium member. :-(
That, at least, is easily remedied.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vinnz
Participant
Posts: 92
Joined: Tue Feb 17, 2004 9:23 pm

Re: Zero count

Post by vinnz »

datastagenewbie wrote::?: I have a situation where i count the records in a file and when the file is empty I need the count to be zero. But In DataStage it is not outputting anything. :cry:
Please advise.
Are you doing your counting in an Aggregator stage or outside of DataStage? Can you use an operating system command (you should have MKS installed) like 'wc -l' ?
prasad v
Participant
Posts: 174
Joined: Mon Mar 30, 2009 2:18 am

Post by prasad v »

I am also facing the same issue. Can anybody tell me the answer if it is resolved?

Regards
Prasad
Post Reply