Difference between Terminator and Exception Handler stages

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
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Difference between Terminator and Exception Handler stages

Post by abc123 »

I have 2 questions:

1)The Exception Handler CAN be used to execute a path (other job activities and execute command stages) in the job sequence after a certain exception occurs. Right?

2)An Exception Handler CANNOT be connected to a job activity/execute command activity stage whereas a Terminator can only be connected to a job activity/execute command activity stage, Right?

Thanks to anyone who responds.
uegodawa
Participant
Posts: 71
Joined: Thu Apr 27, 2006 12:46 pm

Post by uegodawa »

Exception Handler is for Unhandled Exceptions. Suppose you've a sequence of job activities. Each job actvity (called a DataStage Job) and trigger next job if the <JobName>.$Status = 1 (Finished) , But what if previous job aborted ?
In such situations exception handler can handle those unhandled exceptions in a job sequence or Simply you can hook a Terminator stage to the previous job which caused the problem.

If you want to use exception Handler ;
1. Same sequence create another set of links like

Exeception Handler -> Job Activity -> Terminator.

2. In your job activity you can call a job or a routine which handles those unhandled exceptions.

One suggestion: send an email to the support group saying job has been aborted by creating a server routine.

Hope this explains about Exception Handler.
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Post by abc123 »

The Exception Handler does not accept any input links whereas the Terminator stage does.

1)Does that mean that we put the Exception Handler anywhere on the sequencer?

2)Does this mean that whenever an exception occurs, that is an execution status other than OK in a job activity or execute command stage, the Exception Handler is executed? This will probably mean that there can only 1 Exception Handler in the entire sequencer job, right?

3)What would the role of the Terminator stage be?
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Post by abc123 »

Also, what is the difference between "Executed OK" and <JobName>.$Status = 1? I would think that "<JobName>.$Status = 1? (Finished)" is the same as "Executed OK and/or Execution finished with warnings".
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

abc123 wrote:The Exception Handler does not accept any input links whereas the Terminator stage does.

1)Does that mean that we put the Exception Handler anywhere on the sequencer?
Yes anywhere. When an exception occurs as explained, the control will be passed on to the exception handler, no matter where it is.
abc123 wrote: 2)Does this mean that whenever an exception occurs, that is an execution status other than OK in a job activity or execute command stage, the Exception Handler is executed? This will probably mean that there can only 1 Exception Handler in the entire sequencer job, right?
Yes, only one exception handler. Any unhandled exception. If you handled status 1, and 2. Then the control wont go to the exception handler if your job finished with status 2 as you have already handled that. Get the picture.
abc123 wrote: 3)What would the role of the Terminator stage be?
To forcefully terminate the sequence job.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
uegodawa
Participant
Posts: 71
Joined: Thu Apr 27, 2006 12:46 pm

Post by uegodawa »

1)Does that mean that we put the Exception Handler anywhere on the sequencer?

NOT sequencer stage. This just a new path as I explained. Please note that Exception Handler is the first stage in that path ( No Input Links)

Exception Handler -> Jobactivity -> Terminator.


2)Does this mean that whenever an exception occurs, that is an execution status other than OK in a job activity or execute command stage, the Exception Handler is executed? This will probably mean that there can only 1 Exception Handler in the entire sequencer job, right?

Exactly. You got the pount.

3)What would the role of the Terminator stage be?
Abort the sequence
uegodawa
Participant
Posts: 71
Joined: Thu Apr 27, 2006 12:46 pm

Post by uegodawa »

Also, what is the difference between "Executed OK" and <JobName>.$Status = 1? I would think that "<JobName>.$Status = 1? (Finished)" is the same as "Executed OK and/or Execution finished with warnings".

Goto the Triggers
Select Custom Expression
Under Expression box right-mouse select Activity Variable
Click on your job actvity, you might see $JobName, $JobStatus, $UserStaus

Where
$JobStaus =1 Finished Ok
$JobStaus =2 Finished Ok( with warnings)
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Post by gateleys »

Don't forget to set the Automatically handle failed jobs in the properties to take care of the aborted job(s) in the sequence.

gateleys
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Post by abc123 »

2 more questions:

1)
The 3 parameters, stage_label.$ErrSource, stage_label.$ErrNumber and stage_label.$ErrMessage, do they
get logged automatically in the log for the sequence job? I would assume that the Message Text in the
Terminator Activity stage also gets logged.

2)
How do you raise an error to test the error handling process?
uegodawa
Participant
Posts: 71
Joined: Thu Apr 27, 2006 12:46 pm

Post by uegodawa »

1)
stage_label.$ErrSource. This is the stage label of the activity stage that raised the exception (for example, the job activity stage calling a job that failed to run).

stage_label.$ErrNumber. Indicates the reason the Exception Handler activity was invoked, and is one of:

1. Activity ran a job but it aborted, and there was no specific handler set up.

-1. Job failed to run for some reason.

stage_label.$ErrMessage. The text of the message that will be logged as a warning when the exception is raised


2) You can abort a job which is invoked by job activity. For example suppose you're connecting to a database stage, just give a wrong user id or password for the DB stage, then that job will aborted and Exception handler will handle the situation.
Thanks,
Upul
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

An Exception Handler can be connected to anything. The Exception Handler may be triggered by failure of an activity for which no explicit failure handling is provided. An Exception Handler can only have an output, never an input. It is analogous to a signal handler in C.

A Terminator activity can be connected from anything. It must be the final activity in its sequence of processing. That is, a Terminator activity can only have an input.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
nvalia
Premium Member
Premium Member
Posts: 180
Joined: Thu May 26, 2005 6:44 am

Post by nvalia »

If you have 3 job activity stages in the Sequence job, and even if we handle the failure for 1 of the 3 jobs, the Exception Handler will NOT be triggered.

For the Exception Handler to be triggered, there cannot be ANY exception handling in any stage in the Sequence.

Also End the Exception Handler stage with a Terminator Activity stage to cleanly handle the failure (means the Seq job will show an Aborted state)
Post Reply