Page 1 of 1

Posted: Tue Jan 25, 2005 8:59 am
by Sainath.Srinivasan
You can use DSSetUserStatus routine within your Basic function

Posted: Tue Jan 25, 2005 9:28 am
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.

Posted: Tue Jan 25, 2005 9:43 am
by SonShe
Sainath.Srinivasan wrote:You can use DSSetUserStatus routine within your Basic function
Thanks for the help. It worked.

Posted: Tue Jan 25, 2005 9:48 am
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.

Posted: Tue Jan 25, 2005 10:30 am
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.

Posted: Tue Jan 25, 2005 11:02 am
by SonShe
Thank you Craig. It is very clear to me now.

Posted: Tue Jan 25, 2005 4:57 pm
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.