Determine if a ExeCmd is invoked inside Exception Block

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
eli.nawas_AUS
Premium Member
Premium Member
Posts: 39
Joined: Tue Apr 15, 2014 9:14 am

Determine if a ExeCmd is invoked inside Exception Block

Post by eli.nawas_AUS »

Hi

I have shell script that is called by ExeCmd. This ExeCmd stage can be called by either inside Exception Block or outside Exception Block. It executed fine as it really just do some logging.

What i now need is NOT to do some step while inside Exception Block.

Is there a way to determine (from shell script) if the script is invoked inside Exception Block? I want to be able to have an IF statement in the shell script to do different things depending whether it is inside Exception Block or not. Is there a Datastage system variable that get set to tell whether it is inside Exception Block or not?


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

Post by chulett »

I'm sorry but by Exception 'Block' do you mean the Exception Handler stage used in a Sequence job?
-craig

"You can never have too many knives" -- Logan Nine Fingers
eli.nawas_AUS
Premium Member
Premium Member
Posts: 39
Joined: Tue Apr 15, 2014 9:14 am

Post by eli.nawas_AUS »

You are correct. That's what I mean: Exeception Handler stage


Thanks
Palermo
Participant
Posts: 24
Joined: Fri Dec 12, 2014 2:05 pm
Location: Belarus
Contact:

Re: Determine if a ExeCmd is invoked inside Exception Block

Post by Palermo »

There is no variable to detect an exception. You can define an environment variable (for example, status_variable=0) with DataStage Administrator client and change it before running your shell script inside 'Exception Block' with 'Execute Command' stage in 'Command' filed.

Code: Select all

status_variable=1; sh /tmp/shell_name.sh
or
status_variable=#Exception_Handler.$ErrNumber#; sh /tmp/shell_name.sh
eli.nawas_AUS
Premium Member
Premium Member
Posts: 39
Joined: Tue Apr 15, 2014 9:14 am

Re: Determine if a ExeCmd is invoked inside Exception Block

Post by eli.nawas_AUS »

Hi

That would work the way you explained. But I was thinking of not having to change existing code (ie, not adding the set variable command).

Shell script is common code called by many DS jobs. Each DS job calls the same shell script both inside and outside the Exception Handler to do some reporting. I was hoping that there's an API I can call to determine whether the code is executing inside the Exception Handler or not, so i can perform different processing depending where I am.


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

Post by chulett »

There's a way to check the "interimstatus" of a job to see if it is going to abort when it wraps up, that might be helpful but AFAIK it's only available from a routine, not from the command line.

Just a thought but don't you know if it is "executing inside the Exception Handler" or not at design time, i.e. if it is in the EH branch or not? Perhaps a simple change to the script so that, rather than trying to determine the state - you pass it in as a argument instead. True when using it after an exception event, false when used elsewhere with the default being false. Seems to me that would also minimize the amount of job "code changes" you would need to make.
-craig

"You can never have too many knives" -- Logan Nine Fingers
eli.nawas_AUS
Premium Member
Premium Member
Posts: 39
Joined: Tue Apr 15, 2014 9:14 am

Post by eli.nawas_AUS »

Hi,

Well, at this time I can only change the shell script, not the other commands inside ExeCmd. So I can't pass in a argument to the shell script to indicate whether it's in the EH as that would require change to all other DS jobs to pass in this flag. That's why i was wondering if there is an API that I can call inside the shell script.


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

Post by chulett »

As already noted, there's no such API. Hence the other suggestions.
-craig

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