count rows in a sequential file

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
PeterPol
Premium Member
Premium Member
Posts: 73
Joined: Wed Mar 08, 2006 8:59 am

count rows in a sequential file

Post by PeterPol »

Hello,

I want to calculate the number of rows in a sequential file by using the Count rows option in the aggregator stage.
Unfortunately, I get no rowcount when the sequential file is empty.

Any idea how to solve this?

Peter
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Execute Command activity in job sequence to dir the file and get the size from that, on the basis of which you can decide to execute the job or not.

Clearly, if DataStage processes 0 rows, there's nothing there to count.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Maveric
Participant
Posts: 388
Joined: Tue Mar 13, 2007 1:28 am

Post by Maveric »

You can use an 'External Source' stage. give the command to be executed as 'wc -l'. this returns the value as an integer. output will be a single column, single row (count). this sometimes might return two rows of same data. just change the spaces before and after '-' and try. it is only one space but not sure if it is before or after the '-'. Not sure about Aggregator stage though. this is not exactly wat you wanted but just another way of getting the source count. hope it helps.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

:roll: Didn't realize that Windows has a wc command, or that server jobs have an External Source stage. I suspect that neither is true.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Maveric
Participant
Posts: 388
Joined: Tue Mar 13, 2007 1:28 am

Post by Maveric »

:oops: my mistake. will never again post without reading the question properly. Anyway the command is wc -l Filepath\filename. this is for parallel job and Unix.
PeterPol
Premium Member
Premium Member
Posts: 73
Joined: Wed Mar 08, 2006 8:59 am

Post by PeterPol »

Hello,

This one works for my situation:

- Use Sybase OC stage to create a single row (SELECT 1)
- Use the Link Collector stage to append the source rows of the sequential file with this extra row.
- Use the Aggregator stage to count the number of rows
- Subtract one of this count to get the number of rows in the sequential file.

Peter
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Clever. Resolved?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
coolstar4en
Participant
Posts: 1
Joined: Tue Dec 25, 2012 8:18 pm

Post by coolstar4en »

Thansk PeterPol and everyone who replyed this topic,I got same problem today and resolved after reading this topic.

thank you all!
Post Reply