Record Count in Transformer

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
sg33
Participant
Posts: 25
Joined: Wed Nov 24, 2010 3:07 am
Location: India

Record Count in Transformer

Post by sg33 »

Hi ,
I have the job like ....
seq. file.....>transformer......>dataset

I want to count the number of records coming from the source .How can I do that in the transformer stage .

P.S :I don't want to use DSgetlinkinfo() and Aggregator stage or any script
Best Regards
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Count them... for what purpose? To what end?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

System variable @INROWNUM contains this count. Note that it is per-node.
You can not get the final count until the final row has been processed (on the current node).
Last edited by ray.wurlod on Sun Jan 15, 2012 12:57 pm, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Re: Record Count in Transformer

Post by PhilHibbs »

sg33 wrote:P.S :I don't want to use DSgetlinkinfo() and Aggregator stage or any script
Then you are pretty much out of luck. Aggregator is the way to do this. Does each row need to know the row count, for instance for computing averages, or a sequence string like "1 of 1000", "2 of 1000" etc., or do you just want one row output with the count? Why do you not want to use an Aggregator?

There's no way for the Transformer to know that the current row is the last one. You could write a routine to write the @INROWNUM to a file in overwrite mode and then pick up the value afterwards, then read the file. The Transformer would have to run in Sequential mode, not Parallel.
Phil Hibbs | Capgemini
Technical Consultant
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Re: Record Count in Transformer

Post by chulett »

PhilHibbs wrote:There's no way for the Transformer to know that the current row is the last one.
Actually, that was added in the 8.5 release, from what I recall.

As you noted, we'd still like to know the "why" of all this, then perhaps we can give a cogent answer.
-craig

"You can never have too many knives" -- Logan Nine Fingers
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

It's the LastRow() function in 8.5.
Choose a job you love, and you will never have to work a day in your life. - Confucius
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Post by PhilHibbs »

qt_ky wrote:It's the LastRow() function in 8.5.
Nice to know. Thanks.
Phil Hibbs | Capgemini
Technical Consultant
v2kmadhav
Premium Member
Premium Member
Posts: 78
Joined: Fri May 26, 2006 7:31 am
Location: London

Post by v2kmadhav »

Would doing a count and passing it as a param to this job be something that interests you ?
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Post by PhilHibbs »

v2kmadhav wrote:Would doing a count and passing it as a param to this job be something that interests you ?
That would involve scripting, or at least shell, we do that with

Code: Select all

wc -l
but the OP is on windows.
Phil Hibbs | Capgemini
Technical Consultant
v2kmadhav
Premium Member
Premium Member
Posts: 78
Joined: Fri May 26, 2006 7:31 am
Location: London

Post by v2kmadhav »

Sorry my bad.. Didnt see the OS.

not sure about the reqmt but.. Since you using the sequential file... you could add the "rowNumberColumn" option and see if that helps you..
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The included MKS Toolkit would allow the use of UNIX commands.

I'd still recommend waiting for the OP to come back and clarify their needs before people keep playing this endless guessing game.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply