Abort job if the Before/After Subroutine fails

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
clmhwyfe
Premium Member
Premium Member
Posts: 42
Joined: Mon Jun 18, 2012 1:39 pm

Abort job if the Before/After Subroutine fails

Post by clmhwyfe »

Hi All,

Am using a before and after routine to execute a PL/SQL block that updates the job log information to a oracle table.

Is there a way to abort the job incase the before or after sub routine fails , as my job runs even when the before routine fails.

Am using the ExecSH routine to call the PL/SQL block via sqlplus command, and also the sqlplus command outputs the password in the director log even when it is defined as a encrypted value.

Thanks
chanaka
Premium Member
Premium Member
Posts: 96
Joined: Tue Sep 15, 2009 4:06 am
Location: United States

Post by chanaka »

Is it giving you a warning if execSH fails?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That's the thing, the "ExecSH" part typically doesn't fail. It successfully executes and successfully runs sqlplus, it's just the procedure itself inside the sqlplus session that fails. You'll need to do two things - make sure the the script detects the errors in the sqlplus session and then ensure the script passes back a non-zero return code to DataStage when that happens. Then the job will know it should abort.
-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 »

If your script returns a non-zero exit status, then ExecSH will pick that up and cause the job to abort. Source code for ExecSH can be found in the Routines branch of the repository. You can clone it and adapt the copy for your own specific purposes if desired.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
clmhwyfe
Premium Member
Premium Member
Posts: 42
Joined: Mon Jun 18, 2012 1:39 pm

Post by clmhwyfe »

Thanks all,

I changed the return code to a 1 and It resolved the issue.
abc123
Premium Member
Premium Member
Posts: 605
Joined: Fri Aug 25, 2006 8:24 am

Post by abc123 »

I am assuming that in the "Input Value" of the "Before-job subroutine", you put in something like this:

sqlplus userid/pwd@server MySql.sql;

Can you tell me how you returned a 1 from the sqlplus call?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

sqlplus...
exit $?
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