Row Count

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

pravin1581
Premium Member
Premium Member
Posts: 497
Joined: Sun Dec 17, 2006 11:52 pm
Location: Kolkata
Contact:

Post by pravin1581 »

pravin1581 wrote:
pravin1581 wrote:
gateleys wrote: That's because your design doesn't allow for a parallel execution. And you don't want to do it any other way.

Here's the analogy: Guy wants to shoot a deer, such that it pierces through its heart. Oh yes, and he wants it alive.

Sorry about the graphic explanation. Just thought its OK on a Halloween Eve.:twisted:
Thanks for the analogy, so I need to write a Before/After Subroutine and call via a routine activity in the job sequence after the job runs.

Thanks.
But I guess there is a problem in that, I need the informations in the file, No. of rejected recorsd needs to be a calculated field , In - Out and how will I pass the arguments such as Job Name, Link name, Stage Name in the job.

Any sort of help is solicited.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Help you with what, exactly? This?
pravin1581 wrote:how will I pass the arguments such as Job Name, Link name, Stage Name in the job.
After Job routines take a single argument: InputArg. If you need to pass in multiple values, send them in as a delimited string and parse it apart as one of the first steps in the routine - typically using the FIELD function.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pravin1581
Premium Member
Premium Member
Posts: 497
Joined: Sun Dec 17, 2006 11:52 pm
Location: Kolkata
Contact:

Post by pravin1581 »

chulett wrote:Help you with what, exactly? This?
pravin1581 wrote:how will I pass the arguments such as Job Name, Link name, Stage Name in the job.
After Job routines take a single argument: InputArg. If you need to pass in multiple values, send them in as a delimited string and parse it apart as one of the first steps in the routine - typically using the FIELD function.
But how will I call the routine in the routine activity and pass values to it and ultimately the information needs to be in the file..
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The Input Value field contains
MyJobName MyStageName MyLinkName

Within the after-job (or after-stage) subroutine you use Field() functions to parse these out from the single string.

Code: Select all

JobName = Field(InputArg, " ", 1)
StageName = Field(InputArg, " ", 2)
LinkName = Field(InputArg, " ", 3)
Then you can get the row count for that particular link.

Code: Select all

DSGetLinkInfo(DSJ.ME, StageName, LinkName, DSJ.LINKROWCOUNT)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:? What?

How do you call it in a Routine Activity stage? I'm flabbergasted by that question - you simply point to the name of the routine using the ellipsis (...) button. That or just drag the routine itself onto the canvas from the repository browser. Just like any other stage.

Pass values to it? You 'hard code' them - type them in. Not sure what else to say other than that.

The information needs to be in the file. So, write it to 'the file'. Either take your routine results and pass them to a simple job which writes them for you or open the file and write to it right there in your routine.

This isn't rocket science here.
-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 »

Before/after subroutines do not show up in the list of functions callable from the Routine activity, because they are not functions. You need to create an interlude function if you want to call a before/after subroutine from a Routine activity.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

If you plan on using the routine in a Sequence job via the Routine Activity stage rather than Before or After job - then don't create it as a 'Before/After' routine. That will simplify things and help with your parameter passing confusion.

Ray - I just tested your assertion and find that I can, indeed, pick Before/After routines in a Routine Activity stage just like any other. :?:
-craig

"You can never have too many knives" -- Logan Nine Fingers
pravin1581
Premium Member
Premium Member
Posts: 497
Joined: Sun Dec 17, 2006 11:52 pm
Location: Kolkata
Contact:

Post by pravin1581 »

chulett wrote::? What?

How do you call it in a Routine Activity stage? I'm flabbergasted by that question - you simply point to the name of the routine using the ellipsis (...) button. That or just drag the routine itself onto the canvas from the repository browser. Just like any other stage.

Pass values to it? You 'hard code' them - type them in. Not sure what else to say other than that.

The information needs to be in the file. So, write it to 'the file'. Either take your routine results and pass them to a simple job which writes them for you or open the file and write to it right there in your routine.


This isn't rocket science here.


Thanks for the reply. Following is the code that we are using to get the row count:

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)

Should I give the path of the file in the routine itself and how, it seems that we are forgetting about the rejected record calculation and that needs to done as In-Out , can that be incorporated in the routine as well.
ravibabu
Participant
Posts: 39
Joined: Tue Feb 13, 2007 12:18 am
Location: vijayawada

Post by ravibabu »

Hay,

Below is the routine for getting the count from the link.
Jobname and linklist is the args.


$INCLUDE DSINCLUDE JOBCONTROL.H

* Check for empty JobName
If JobName = "" Then Goto ERROR

* Attach the job
JobHandle = DSAttachJob(JobName,DSJ.ERRFATAL)

* Get the number of links to process
RowNum = Dcount(LinkList,'|')

* Initialize TotalRowCount
TotalRowCount = 0

* Loop for each Link to get the number of rows
For i=1 To RowNum
SLName = Field(LinkList,'|',i)
StageName = Field(SLName,',',1)
LinkName = Field(SLName,',',2)
RowCount = DSGetLinkInfo(JobHandle, StageName, LinkName, DSJ.LINKROWCOUNT)
If RowCount >= 0 Then TotalRowCount += RowCount
Next i

END:
Ans=TotalRowCount
Return(Ans)

ERROR:
Ans=0
Return(Ans)


steps:-

1) create the one multiple instance job in server edition.

like below.

-----------------------------------

oci(Dummy)------Trans------OCI
|
|
|
File ------>OCI


in trans---- create the stage variable like below.

DSAttachJob(JobName,DSJ.ERRFATAL)---->svarJobHandle
DSGetJobInfo(svarJobHandle,DSJ.JOBSTATUS)----->svarJobStatus
If RejCntLink <> "" Then mdsRowStatsCount(JobName, RejCntLink) Else 0-------->svarErrRowCnt
DSGetJobInfo(svarJobHandle,DSJ.JOBSTARTTIMESTAMP)----->svStartTime
DSGetJobInfo(svarJobHandle,DSJ.JOBLASTTIMESTAMP)------->svEndTime
DSDetachJob(svarJobHandle)------>svDetachJob
pravin1581
Premium Member
Premium Member
Posts: 497
Joined: Sun Dec 17, 2006 11:52 pm
Location: Kolkata
Contact:

Post by pravin1581 »

ravibabu wrote:Hay,

Below is the routine for getting the count from the link.
Jobname and linklist is the args.


$INCLUDE DSINCLUDE JOBCONTROL.H

* Check for empty JobName
If JobName = "" Then Goto ERROR

* Attach the job
JobHandle = DSAttachJob(JobName,DSJ.ERRFATAL)

* Get the number of links to process
RowNum = Dcount(LinkList,'|')

* Initialize TotalRowCount
TotalRowCount = 0

* Loop for each Link to get the number of rows
For i=1 To RowNum
SLName = Field(LinkList,'|',i)
StageName = Field(SLName,',',1)
LinkName = Field(SLName,',',2)
RowCount = DSGetLinkInfo(JobHandle, StageName, LinkName, DSJ.LINKROWCOUNT)
If RowCount >= 0 Then TotalRowCount += RowCount
Next i

END:
Ans=TotalRowCount
Return(Ans)

ERROR:
Ans=0
Return(Ans)


steps:-

1) create the one multiple instance job in server edition.

like below.

-----------------------------------

oci(Dummy)------Trans------OCI
|
|
|
File ------>OCI


in trans---- create the stage variable like below.

DSAttachJob(JobName,DSJ.ERRFATAL)---->svarJobHandle
DSGetJobInfo(svarJobHandle,DSJ.JOBSTATUS)----->svarJobStatus
If RejCntLink <> "" Then mdsRowStatsCount(JobName, RejCntLink) Else 0-------->svarErrRowCnt
DSGetJobInfo(svarJobHandle,DSJ.JOBSTARTTIMESTAMP)----->svStartTime
DSGetJobInfo(svarJobHandle,DSJ.JOBLASTTIMESTAMP)------->svEndTime
DSDetachJob(svarJobHandle)------>svDetachJob
We need to create a PX job.
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Post by abc123 »

Just curious. Why can't do an after-job shell script to get the counts?
Post Reply