Page 1 of 2

Passing parameter out of datastage job

Posted: Thu Mar 23, 2006 3:10 pm
by Juls
I am looking for a way to pass parameter value out of a server job to be used as value in parameter of another server job.
I realize that this is not possible to do easily and I don't want to put a value into hash value and then retrieve it using UtilityHashLookup in sequence job. I was thinking to do something along the line of setting a variable.. but isn't it only available within that one sequence job?

Does anyone has any suggestions or done something similar?

Thanks,
Juls

Posted: Thu Mar 23, 2006 3:35 pm
by chulett
Search the forum or the online help for USERSTATUS. This can be set with a single value inside a Server job and then easily picked up in a Sequencer and passed in as a parameter to a downstream job.

Re: Passing parameter out of datastage job

Posted: Fri Mar 24, 2006 5:59 am
by parag.s.27
Juls wrote:I am looking for a way to pass parameter value out of a server job to be used as value in parameter of another server job.
I realize that this is not possible to do easily and I don't want to put a value into hash value and then retrieve it using UtilityHashLookup in sequence job. I was thinking to do something along the line of setting a variable.. but isn't it only available within that one sequence job?

Does anyone has any suggestions or done something similar?

Thanks,
Juls
Hi,

You can set user variables for multiple jobs in a single sequence job, by usin USER VARIABLE Stage. But those values will not be available to another sequence untill u again define those in that sequence.

so the summary is you can define user variables for a sequence, in which there can be multiple jobs.

Also you can set user defined environment variables by selecting job parameters tab

Posted: Fri Mar 24, 2006 6:52 am
by kumar_s
chulett wrote:Search the forum or the online help for USERSTATUS. This can be set with a single value inside a Server job and then easily picked up in a Sequencer and passed in as a parameter to a downstream job.
Hi Craig,
I have never tried with UserStatus. May I know how to use it?
What kind of expression we can give in the trigger for Job Activity for 'UserStatus - Conditional'?

Posted: Fri Mar 24, 2006 7:12 am
by chulett
The simplest way is via a Custom Routine that just takes a value in and calls DSSetUSerStatus using that value. You can then either decide to pass the input argument back as the 'answer' or pass back a '0', depending on exactly how you would use it. For example:

Code: Select all

Call DSSetUserStatus(Arg1)
Ans=0
-or-

Code: Select all

Call DSSetUserStatus(Arg1)
Ans=Arg1
The first can be used in a 'dead end' Stage Variable, while the second can just be plugged into a derivation as a 'pass through' solution. Anything going into either one is written to the User Status area of the job.

Retrieving it is pretty straight forward. If you want to code it yourself, you would use the DSGetJobInfo function, a job handle and the DSJ.USERSTATUS InfoType. In a Sequence job it's all pretty much automatic - from the 'Insert Job Parameter' picker doo-hicky, you'll see (amongst other things) an option on every upstream job to retrieve the JobActivityStageName.$UserStatus from the job the named Job Activity stage runs.

Some caveats using this. First is that the area it stores in you can think of as a single record hashed file. You can only store one 'value' there and the last thing you write is what you will retrieve. Now, I've used it to store delimited strings and then have standard routines to pull and parse them out into their component pieces - so keep that in mind. Only 'one value' is not as restricitive as it sounds right off the bat.

Anything that resets a job destroys the User Status area. That would mean things like Resetting or Recompiling a job clears the User Status area until the job is run again... something else to keep in mind.

Not sure what your Trigger question has to do with this topic as triggers aren't involved here as you can see. However, to answer it - it can be any legitimate expression. In essence anything that resolves to either true or false... and when true will trigger the link.

Hope this helps!

Posted: Fri Mar 24, 2006 11:58 am
by Juls
Thanks,

But where in the server job will I call DSSetUSerStatus if I want to set it to the value that I calculate in a Transformer stage? Basically I want the USERSTATUS to be equal to a Derivation I have in a Transformer stage. When job runs the derivation has a result that is being written to a DB table that I also want to be assigned as the value of the USERSTATUS to be used in my sequence job later.

Hope I am making sense.

Posted: Fri Mar 24, 2006 4:34 pm
by ray.wurlod
Create a routine that passes its argument unchanged but also loads it into the user status area.

Code: Select all

FUNCTION UpdateUserStatus(Arg1)
Call DSSetUserStatus(Arg1)
Ans = Arg1
RETURN(Ans)
Pass your value through this function during its derivation.

Posted: Fri Mar 24, 2006 5:51 pm
by chulett
Now, that bit of advice sounds really familiar. :wink:

Posted: Sat Mar 25, 2006 1:07 am
by ray.wurlod
Timestamped 3 hours before yours. Something weird is happening. Or maybe my dial-up line is even slower than I thought!

Posted: Sat Mar 25, 2006 1:54 am
by chulett
Odd... seems you posted that over nine hours after I did. I don't see any timestamp issues, but then my acoustic coupler is probably seated a little tighter than yours. :wink:

Posted: Mon Mar 27, 2006 2:44 pm
by Juls
Thanks a lot!
I got it working also using a transformer stage variable:
1) I assigned the value to the transformer stage variable
2) wrote an after routine that pulls the value of this stage variable and assigns it to USERSTATUS.
3) in the sequence job I call another routine that I wrote that extracts the user status.

Now a new question.... can I persist that same user status value in between 2 sequence jobs that are called a 3rd top sequence job?

Posted: Mon Mar 27, 2006 2:52 pm
by chulett
Juls wrote:3) in the sequence job I call another routine that I wrote that extracts the user status.
This part shouldn't have been necessary. You should have been able to use StageName.$UserStatus directly.
Juls also wrote:Now a new question.... can I persist that same user status value in between 2 sequence jobs that are called a 3rd top sequence job?
If I am following, you can just keep passing it down...

Posted: Mon Mar 27, 2006 9:31 pm
by balajisr
Juls also wrote:Now a new question.... can I persist that same user status value in between 2 sequence jobs that are called a 3rd top sequence job?
If I am following, you can just keep passing it down...[/quote]

Or you can set it to user variable and access the user variable anywhere in the job sequence.

Posted: Mon Mar 27, 2006 9:50 pm
by chulett
No need for an additional stage if it's already available in the User Status area of one of the jobs in the Sequence job. Besides, that wasn't the question.

Juls asked about accessing it from two sub-sequence jobs called from a third top level sequence job. The User Variables stage won't help here. If the user status value is set in the top level sequence, you just need to pass it to both sub-sequence jobs in order to use it in any of their jobs.

If the value is set in one sub-sequence and needs to be accessed in another, that second sub-sequence will need a Routine Activity stage that can retrieve the User Status area from any named job in order to bring that value over into the second sub-sequence. Assuming, of course, that the job that sets it in the other sub-sequence has run by then.

Posted: Mon Mar 27, 2006 10:00 pm
by balajisr
Thanks for the clarification craig.