Page 1 of 2

RowCount from the DSGetLinkInfo always return zero

Posted: Wed Sep 06, 2006 8:33 am
by grace
I am trying to get the rowcount by using
JobRowCount = DSGetLinkInfo(JobHandle,StageName,LinkName,DSJ.LINKROWCOUNT ) in an after job subroutine , but it always returns zero while I can see from the log that there are rows being processed, I saw many people get a good result by using the DSGetLinkInfo on this forum, not sure if there is a setting issue, any help is appreciated.

Posted: Wed Sep 06, 2006 9:06 am
by kduke
It takes several calls to get this to work. You need a valid JobHandle by using DSAttach(). StageName has to be a valid stage name. Same with LinkName.

Posted: Wed Sep 06, 2006 9:18 am
by grace
Thanks a lot for your quick response!!

I am using JobHandle = DSJ.ME, so there is no need for DSAttach(), right? The stageName & LinkNames are valid.

Posted: Wed Sep 06, 2006 9:30 am
by ArndW
I think that the reason you aren't getting an output is that the "DSJ.ME" might not be valid in the after-job routine. Can you put a DSLogInfo() call into the routine and output the value of DSJ.ME? You could also do a "CALL DSLogInfo('My job name is "':DSGetJobInfo(DSJ.ME,DSJ.JOBNAME),'')"

Posted: Wed Sep 06, 2006 4:25 pm
by ray.wurlod
The DSJ.ME constant is valid in an after-job subroutine. If you have doubt include the following three lines at the top of your code.

Code: Select all

$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF
Check that the stage name and link name are correctly spelled and use correct case in the DSGetLinkInfo() call. What exact version of DataStage is this?

Posted: Thu Sep 07, 2006 9:47 am
by grace
Thank you for all your response!
Yes, the DSJ.ME is valid in an afterjob routine.
But I am still not get any rowcount back, even when I tried to write the job report out to a file using the statement below:
ReportText =DSMakeJobReport(JobHandle,2,"CRLF")
I can see the job/stages/links names are in the file correctly, but the rowcount is 0, any idea?

Posted: Thu Sep 07, 2006 11:11 am
by ArndW
I've used the routine many times in the past, it does work. But if you have a spelling or capitalization error it is unforgiving and gives you the results that you are getting. As Ray has already suggested check the Stage and the Link names. Even if the Stage is spelled correctly, does it actually link to that Link Name?

Posted: Thu Sep 07, 2006 12:00 pm
by panchusrao2656
I did face this issue when i use a passive stage name as stage name.Try using an active stage name.

Posted: Thu Sep 07, 2006 12:18 pm
by kris007
You are supposed to use the active stage name. It is neatly documented in the help.

Posted: Thu Sep 07, 2006 12:20 pm
by prabu
grace wrote:Thank you for all your response!
Yes, the DSJ.ME is valid in an afterjob routine.
But I am still not get any rowcount back, even when I tried to write the job report out to a file using the statement below:
ReportText =DSMakeJobReport(JobHandle,2,"CRLF")
I can see the job/stages/links names are in the file correctly, but the rowcount is 0, any idea?
can you try feeding the value in the After-Job subroutine[job properties i mean] instead of your wrapper .

Code: Select all

2;C:\Tmp

Posted: Thu Sep 07, 2006 12:58 pm
by grace
Not sure what's the difference between the passive stage name & the active stage name.
Can you explain it?

Posted: Thu Sep 07, 2006 2:32 pm
by kris007
Passive Stages are stages which read/write data from/to files, database tables, datasets etc. eg: sequential files, database stages etc

Active Stages are stage which perform some kind of action(transformation) on data. eg: Transformer stage.

Posted: Thu Sep 07, 2006 4:01 pm
by ray.wurlod
Can you post the code of your after-job subroutine, maybe we can find your glitch.

Code: Select all

hJob = DSJ.ME
Message = "Link row counts:"
StageList = Convert(",", @FM, DSGetJobInfo(hJob, DSJ.STAGELIST))
Loop
   Remove StageName from StageList Setting MoreStages
   LinkList = Convert(",", @FM, DSGetStageInfo(hJob, StageName, DSJ.LINKLIST))
   Loop
      Remove LinkName From LinkList Setting MoreLinks
      RowCount = DSGetLinkInfo(hJob, StageName, LinkName, DSJ.LINKROWCOUNT)
      Message<-1> = LinkName : ": " : RowCount
   While MoreLinks
   Repeat
While MoreStages
Repeat
Call DSLogInfo(Message, "MyJob")

Posted: Fri Sep 08, 2006 7:42 am
by grace
I just realized that even I can get the rowcount from the link, it won't serve the project needs.
What we are trying to do is that get the actual rowcount that being inserted/updated/deleted in the table, the count from the link is what being passed down.
So I am thinking to get the rowcount from the result of DSMakeJobReport(), but not sure why the rowcount being returned is zero too, although it has all the other info(stage,link, etc.)
Does anyone know other ways to get the rowcount being processed?

Here is my code:

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

ErrorCode = 0

*Input params
DirName = Field(InputArg,';',1)
TableName = Field(InputArg,';',2)
JobType = Field(InputArg,';',3)

JobHandle = DSJ.ME

FileName = TableName:"_":JobType:"_":"Stat.DAT"

ReportText =DSMakeJobReport(JobHandle,2,"CRLF")


Openpath DirName to t.fvar then
write ReportText to t.fvar, FileName else
call DSLogWarn("Failed to write file ":FileName:" to directory ":DirName, "DoJobReport")
end
end
else
call DSLogWarn("Failed to open directory ":DirName, "DoJobReport")
end

close t.fvar
ErrorCode = 0 ;* set this to non-zero to stop the stage/job

Posted: Fri Sep 08, 2006 8:14 am
by kumar_s
Trun on your statistics and check whether you are getting the number of rows passed per second in the green link, once the job is finished.
If not you need to turn on the Monitor.