Getting count of records passed through a link

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

aaikat
Participant
Posts: 47
Joined: Tue Mar 07, 2006 2:49 am

Getting count of records passed through a link

Post by aaikat »

I am a new user of DSEE.Please advise me how should I get the count of records processed by a link. I dont find any built-in routine for that.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

If you want the information from inside the job, the transform stage variables @INROWNUM and @OUTROWNUM will work per instance. If you want the information from outside of the job, you can use a routine such as DSGetLinkInfo() or use the UNIX command line "dsjob -report" to get that data.
hhh
Participant
Posts: 86
Joined: Tue Aug 02, 2005 7:39 am

Re: Getting count of records passed through a link

Post by hhh »

you can use aggregator stage for same , there is utility called aggaregation type "Count Rows".

aaikat wrote:I am a new user of DSEE.Please advise me how should I get the count of records processed by a link. I dont find any built-in routine for that.
aaikat
Participant
Posts: 47
Joined: Tue Mar 07, 2006 2:49 am

Post by aaikat »

Hi ArndW,
As you have said we can use transform stage variables @INROWNUM and @OUTROWNUM.But they are incremental in nature.If I want to get the total count of records processed by a Transformer stage what shd I do.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Check out the DSGetLinkInfo function.
-craig

"You can never have too many knives" -- Logan Nine Fingers
aaikat
Participant
Posts: 47
Joined: Tue Mar 07, 2006 2:49 am

Post by aaikat »

I faced error while compiling a server routine code with the function DSGetLinkInfo. ( I tried for server routine as I didn't find place to write code in case of Parallel routine).I wrote the following code :

hJob = DSAttachJob(JobName, DSJ.ERRFATAL)

If NOT(hJob) Then
Call DSLogFatal("Job Attach Failed", "JobControl")
Abort
End

Ans = DSGetLinkInfo (hJob, StageName, LinkName, DSJ.LINKROWCOUNT)



I get the following error :-

Compiling: Source = 'DSU_BP/DSU.MyGetLinkCount', Object = 'DSU_BP.O/DSU.MyGetLinkCount'
?
0009 Ans = DSGetLinkInfo (hJob, StageName, LinkName, DSJ.LINKROWCOUNT)

^
',' unexpected, Was expecting: '!', ')', '=', "AND", "OR", "LT", "LE",
"GT", "GE", "NE", "EQ", "MATCH"
Array 'DSAttachJob' never dimensioned.
WARNING: Variable 'DSJ.ERRFATAL' never assigned a value.
Array 'DSGetLinkInfo' never dimensioned.

3 Errors detected, No Object Code Produced.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

1. You must include the line "$INCLUDE DSINCLUDE JOBCONTROL.H"
2. You will need to fill the values for StageName and LinkName to get values returned to you. {amended, added $INCLUDE to text}
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

Try this one and see if it works.

Code: Select all

$IFNDEF JOBCONTROL.H 
$INCLUDE DSINCLUDE JOBCONTROL.H 
$ENDIF

hJob = DSAttachJob(JobName, DSJ.ERRFATAL) 

If NOT(hJob) Then 
Call DSLogFatal("Job Attach Failed", "JobControl") 
Abort 
End 
Else 
Ans = DSGetLinkInfo (hJob, StageName, LinkName, DSJ.LINKROWCOUNT)
End
DetachResult = DSDetachJob(hJob)
Don't forget to pass teh stagename and linkname as Arguments to the routine. Or, just hardcode them and test them.

IHTH
Kris.
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

kris007 wrote:Try this one and see if it works.

Code: Select all

$IFNDEF JOBCONTROL.H 
$INCLUDE DSINCLUDE JOBCONTROL.H 
$ENDIF

hJob = DSAttachJob(JobName, DSJ.ERRFATAL) 

If NOT(hJob) Then 
Call DSLogFatal("Job Attach Failed", "JobControl") 
Abort 
End 
Else 
Ans = DSGetLinkInfo (hJob, StageName, LinkName, DSJ.LINKROWCOUNT)
End
DetachResult = DSDetachJob(hJob)
Don't forget to pass teh stagename and linkname as Arguments to the routine. Or, just hardcode them and test them.

IHTH
Kris.
:idea: The $IFNDEF JOBCONTROL.H & $ENDIF are not needed since they are already in the included header file
:idea: I Don't like aborting routines there is no need to abort anything
:idea: Adding checks to see if the routines you use were successfull is advisable
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
kris007
Charter Member
Charter Member
Posts: 1102
Joined: Tue Jan 24, 2006 5:38 pm
Location: Riverside, RI

Post by kris007 »

I agree with you. I just made changes to the routine posted by OP from the top of my head.

In fact, I practice writing routines the way you have described. Not aborting and adding checks.

Here's the routine with more changes.

Code: Select all

 
$INCLUDE DSINCLUDE JOBCONTROL.H 

hJob = DSAttachJob(JobName, DSJ.ERRNONE) 

If NOT(hJob) Then 
Ans=-99 
End 
Else 
Ans = DSGetLinkInfo (hJob, StageName, LinkName, DSJ.LINKROWCOUNT) 
End 
DetachResult = DSDetachJob(hJob)[code]
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Even though I don't do it, the ABORT can be kept in the routine, as the DSLogFatal should never return. But when testing the routine from the manager the execution is not part of a job and thus the DSLogFatal() call will return and then the ABORT will kick in.

But the original poster (OP) still needs to fill in values for StageName and LinkName in order to get a value back.
aaikat
Participant
Posts: 47
Joined: Tue Mar 07, 2006 2:49 am

Post by aaikat »

Thanks all of you.The code is working properly to get the count associated with a link.
My next question is 'Will I be able to use this server routine in a parallel job'. If 'yes', how?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

No, but you can use it in a Routine activity in the job sequence that runs the parallel job.

You can also look in the job log - every "active stage finishing" message carries row counts for links connected to that stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
aaikat
Participant
Posts: 47
Joined: Tue Mar 07, 2006 2:49 am

Post by aaikat »

Actually my requirement is to write the record count (processed by a link) into a table from within the job.How to do it then?
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

I would modify UtilityRunJob() to run my jobs and have it get row counts after the job finishes.
Mamu Kim
Post Reply