DSGetLinkInfo

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
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

You can use DSSetUserStatus routine within your Basic function
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I've done something similar by passing in the Job Name, Stage Name and Link Name as parameters to the routine and then passing the row count out as the Answer.

You would need to attach to the job, use that handle to get the link information and then detach from the job. This lets you use it in a Routine Activity stage in the Sequencer and then use $ReturnValue for the downstream parameter value.
-craig

"You can never have too many knives" -- Logan Nine Fingers
SonShe
Premium Member
Premium Member
Posts: 65
Joined: Mon Aug 09, 2004 1:48 pm

Post by SonShe »

Sainath.Srinivasan wrote:You can use DSSetUserStatus routine within your Basic function
Thanks for the help. It worked.
SonShe
Premium Member
Premium Member
Posts: 65
Joined: Mon Aug 09, 2004 1:48 pm

Post by SonShe »

Sainath.Srinivasan wrote:You can use DSSetUserStatus routine within your Basic function
Hi Craig,

Thanks for the help. I used DSSetUserStatus and it worked. But I would like to know your approach as well. In a server routine I don't know how to return the rowcount as ans. I believe I have to write a transform routine to be able to do that. Please help me in my understanding. I have just started writing routines and learning a lot of stuffs with help from the DSXchange forum. Secondly, in the RoutineActivity stage how the returnvalue captures the rowcount value.

Thanks.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You can create a routine of the Transform Function type and then run it outside of your DataStage jobs via a Sequencer and the Routine Activity stage. It's a little more generic of a routine, would allow multiple input arguments and would look something like this:

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H

rJobHandle = DSAttachJob(JobName, DSJ.ERRNONE)

If NOT(rJobHandle) Then
   Ans = -99
End Else
   Ans = DSGetLinkInfo(rJobHandle, StageName, LinkName, DSJ.LINKROWCOUNT)
End

DetachResult = DSDetachJob(rJobHandle)
Bare bones, but it should give you the idea of what I'm talking about. JobName, StageName and LinkName are the three arguments and the row count is passed out as the answer. Negative answers indicate a problem and can be picked up by a custom trigger.

Drop a Routine Activity stage between your two Job Activity stages. Then the value of the row count parameter in the second job can be set to:

Code: Select all

RoutineStageName.$ReturnValue
Replace the 'RoutineStageName' part with whatever you actually call the stage in the job. Pass in the information from the upstream job as arguments to the routine and (if everything is ok) your row count gets passed to the second job.
-craig

"You can never have too many knives" -- Logan Nine Fingers
SonShe
Premium Member
Premium Member
Posts: 65
Joined: Mon Aug 09, 2004 1:48 pm

Post by SonShe »

Thank you Craig. It is very clear to me now.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

In a server routine I don't know how to return the rowcount as ans .

Be careful with casing. The name of the return variable is Ans, it is not ans.

Apart from assigning a value to Ans you do not need to do anything more; look at the bottom of the Routine editing page, and you will see that DataStage automatically includes RETURN(Ans) for you.

The value that you assign to Ans becomes the value returned by the function. It is vital that there is no code path through your Routine in which Ans is left in an unassigned state.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply