DataStage Sequence Job -- UserVariable to Activity

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
Tornquist
Participant
Posts: 22
Joined: Tue May 28, 2013 2:35 pm

DataStage Sequence Job -- UserVariable to Activity

Post by Tornquist »

I would like to have a variable passed into a job that says if another job either succeeded or failed. My original thought was to have a job activity branch based on failure or success and have a userVariable set on either path. That doesn't work though, because I can't have two userVariable activities reference the state of the same variable.

I also seem to unable to grab the exit condition programatically from within any of the other activities as well. I had considered checking to see if the error code was zero for the activity.

My end goal is to have a series of parallel jobs run and then pass a list (in the form of a string) of the names of all of the successful jobs into another job that will update a table based on that information.

I would like the end result to be a single variable that either says 'Table_Name' or 'Failed' based on the result. I can be flexible though.

Are there any suggestions on how to accomplish this? Thanks in advance for your help.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I don't see a need for the UserVariable stage here. Typical use would be to establish values once at the beginning of a Sequence and then downstream activities would have access to them. Prime example would be a looping sequence job.

I'm not quite sure I follow your ultimate design here. Triggers can check activity status, for example a Job Activity stage has constants like DSJS.RUNOK or DSJS.RUNWARN that can be referenced. Others have specific "status" values that can be interrogated downstream. However, I'm not sure you really want to be tying them all into a Sequence job just so you can determine their completion status.

Why not design a separate post process of some sort? I tend to prefer separate processing for things like this so your metrics / status / whatever gathering doesn't affect and or disrupt the actual loads. We're getting into ETLStats territory here but a Server job could iterate through a list of jobs, check their latest run status and update a table with the results. Even a script could generate the values for you into a flat file which any job could load. The lists of job names to check could be table driven, for example. Just off the top of my head stuff... certainly multiple ways to solve this.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Tornquist
Participant
Posts: 22
Joined: Tue May 28, 2013 2:35 pm

Post by Tornquist »

I'm not going to disrupt actual loads, this is all ETL work. Essentially what I'm trying to do is keep a table of last sync dates for the concerned tables. I only want to sync new information in the tables, which is why I am keeping a record. If a table sync correctly and the job doesn't fail, then I need to update the date in the table to avoid syncing the records I just moved again.

The sequence job manages all of the necessary processes. I wanted a variable to be set up so that I can modify it based on the completion state and pass that to the job that updates the date table.

Is there a way to use the constants RUNOK and RUNWARN within a userVariable stage to change the status of a variable? I believe that would accomplish what I want to do.
Tornquist
Participant
Posts: 22
Joined: Tue May 28, 2013 2:35 pm

Post by Tornquist »

Based on this site: http://www.myonlinetrainings.com/study- ... rocess.htm

It looks like I can use one UserVariable stage to modify another. I tried setting a variable before my main ETL job then having the job branch based on "Failure" or "Otherwise. On the failure path I have another stage that references the variable of the first UserVariable stage and tries to change it by using the form: UserVariableStage1.Variable1 = 'New Value' but either the stage isn't working, or that path isn't being taken for some reason.

Should it be possible to do it that way?
Tornquist
Participant
Posts: 22
Joined: Tue May 28, 2013 2:35 pm

Post by Tornquist »

This is what I'm trying so far:

Image
Tornquist
Participant
Posts: 22
Joined: Tue May 28, 2013 2:35 pm

Post by Tornquist »

The problem can be solved by having a single userVariable activity that processes USERPROFILE_Status.$JobStatus after the job has completed.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Good that you've got this working. I honestly don't think you really need UserVariable stages here but don't have any way to play around and confirm/deny.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Tornquist
Participant
Posts: 22
Joined: Tue May 28, 2013 2:35 pm

Post by Tornquist »

You don't need the uservariable stages, it would be possible to build the full string of updated tables in one step. Eventually this job will run 25+ ETL jobs though, so it's much easier to maintain if I break it into small pieces.
Post Reply