Custom Trigger code in Sequence

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
Juls
Participant
Posts: 51
Joined: Tue Sep 14, 2004 9:17 am

Custom Trigger code in Sequence

Post by Juls »

Hi,

In my sequence job I have a job activity stage that Runs Job1. Job1 in its job control calls Job2. I need to have Custom trigger on this Activity stage to say if status of Job2 is failed or warnings then go to Email Notification stage. I was successful in extracting the status of this activity, which will give me the status of job1. But when I tried to add code to this custom trigger to check for status of job2 it doesn't work.

Here is the code I have on the trigger.
Also, I need to have the Job2 name to be build out of param
paramJobName = Job2

This part works ok and gives me status of Job1 since this is what act_INSERT stage calls
act_INSERT.$JobStatus = DSJS.RUNFAILED or act_INSERT.$JobStatus = DSJS.RUNWARN

This part is what I want to get status of Job2
or DSGetJobInfo("job_INSERT_":paramTableName, DSJ.JOBSTATUS) = DSJS.RUNFAILED or DSGetJobInfo('job_INSERT_':paramTableName, DSJ.JOBSTATUS) = DSJS.RUNWARN

Hope I was clear.

Thanks,
Juls
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

First off, I (personally) would never code specific status codes into custom triggers like that, there's really no need. You're much better off using the defined triggers in this case - most cases, actually.

Have one link that goes forward to the next step with a 'Ran OK' trigger. For your error path, use the 'Otherwise' trigger. This will catch all problems with running the job, not just the two you listed.

The second part is a little confusing. What exactly do you mean that 'Job2' is called in the 'Job Control' of Job1? In any case, you can't drop code like that into triggers, it's not something that's supported. If you really need to do something like that to dig into another job not explicitly run by the Sequencer job, I'd suggest coding a Routine that does the check for you and then run that via the Routine Activity stage and check its return code.

However, an explanation of what you are doing might reveal 'more better' ways of handling this. :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 »

chulett wrote:The second part is a little confusing. What exactly do you mean that 'Job2' is called in the 'Job Control' of Job1? However, an explanation of what you are doing might reveal 'more better' ways of handling this. :wink:
Job1 is called to run by job activity in a sequence.

The purpose of job1 is to call job2 to run.

Job1 finishes ok, but job2 may have errors. I need to check status of job2 after job1 finishes (which means job2 finished). And based on status of job2 continue from this job activity.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ok, silly question time... why can't the Sequencer simply run Job2? What functionality does Job1 provide other than running Job2?

Depending on how Job1 is designed, it may be able to check on the status of Job2 itself and, if there is a problem, drop a warning of some kind in its own log. The Sequencer would notice that.
-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 »

chulett wrote:Ok, silly question time... why can't the Sequencer simply run Job2? What functionality does Job1 provide other than running Job2?

Depending on how Job1 is designed, it may be able to check on the status of Job2 itself and, if there is a problem, drop a warning of some kind in its own log. The Sequencer would notice that.
Job1 dynamically calculates the size of the DB table fields (SQL text/blob data type) and passes it as a parameter to job2. (This is workaround for large blob fields for DRS stage from Ascential). Job2 can then run.


I like the idea of dropping a warning from Job1.
IT WORKS GREAT!!!
I am all set
Thanks a lot.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Excellent! :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply