Passing parameter out of datastage job

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

Juls
Participant
Posts: 51
Joined: Tue Sep 14, 2004 9:17 am

Passing parameter out of datastage job

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
parag.s.27
Participant
Posts: 221
Joined: Fri Feb 17, 2006 3:38 am
Location: India
Contact:

Re: Passing parameter out of datastage job

Post 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
Thanks & Regards
Parag Saundattikar
Certified for Infosphere DataStage v8.0
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post 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'?
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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!
-craig

"You can never have too many knives" -- Logan Nine Fingers
Juls
Participant
Posts: 51
Joined: Tue Sep 14, 2004 9:17 am

Post 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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
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 »

Now, that bit of advice sounds really familiar. :wink:
-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 »

Timestamped 3 hours before yours. Something weird is happening. Or maybe my dial-up line is even slower than I thought!
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 »

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:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Juls
Participant
Posts: 51
Joined: Tue Sep 14, 2004 9:17 am

Post 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?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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...
-craig

"You can never have too many knives" -- Logan Nine Fingers
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post by balajisr »

Thanks for the clarification craig.
Post Reply