Before job subroutine

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
das_nirmalya
Participant
Posts: 59
Joined: Thu Mar 20, 2008 12:11 am

Before job subroutine

Post by das_nirmalya »

if i use a unix shell script as a before job subroune in job property. how can i use output of this unix script in a transformer used in that job.

i.e i want to use the output value for some comparision etc
nsd
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Without writing a routine there is no way you can achieve what you ask in a server job. This is because the Transformer stage executes in a separate process to the job process (which executes the before-job subroutine). You need to "park" the value somewhere - maybe a file, maybe the job's user status area - and recover it within the routine executed by the Transformer stage.
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 »

You can't. Do it in a separate session, store that value in some manner such that you can retrieve it later and pass it in as a job parameter.
-craig

"You can never have too many knives" -- Logan Nine Fingers
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Post by PhilHibbs »

Is there not a DS routine that you can call that sets Job Parameters?

Update: A quick search reveals the DSSetParam function, but can this be called while a job is running?

Update2: I've tried and this appears to not work. Params probably get initialised before the Before Job Routine is called. Boo!
Phil Hibbs | Capgemini
Technical Consultant
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Exactly, you 'set params' before starting the job, after it starts it is too late.

Now, don't tell anyone but I have seen people that have 'hacked' things (or otherwise have an intimate knowledge of the internal structures) and thus know how to sneak under the wire and actually update the current value of a parameter before job. Neither a Best Practice nor a supported methodology that be.
-craig

"You can never have too many knives" -- Logan Nine Fingers
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Post by PhilHibbs »

It seems tremendously inconvenient that there is no way for a Job to perform a single computation at the start that is later used either in multiple places (Transformers) or for multiple rows. As I understand it, you can't call a Routine in the initialisation of a Stage Variable either.

Correction: You can call a Routine in the initialisation! This will probably do for my situation.
Phil Hibbs | Capgemini
Technical Consultant
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Bingo! :D
-craig

"You can never have too many knives" -- Logan Nine Fingers
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Post by PhilHibbs »

So, getting back to the OP's requirement, you could call a DS Routine in the initialisation of a Stage Variable, and in that DS Routine, read the output of the shell script that has been redirected to a file.
Phil Hibbs | Capgemini
Technical Consultant
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sure, more than likely. I mean, you can do it but you would only be able to use the value in Transformers. If you needed it in a source query in an passive stage, for example, that would need to be an actual job parameter.
-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 »

You could also use a before-stage subroutine in the Transformer stage to do the same thing and, since it's in the same process, transfer values through system variables such as @USER0 through @USER4 back into the Transformer stage. But the OP's stated requirement (and thread subject) was "before job subroutine".
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