Page 1 of 1

abort the Job

Posted: Fri Oct 21, 2011 4:17 pm
by prasad v
I want to make job aborted when there is no records to update in the target table, can anyone tell me how can we achieve this?

Posted: Fri Oct 21, 2011 5:05 pm
by ray.wurlod
Why abort? Why not prevent the job from running in the first place?

Either way is possible. Run a command that checks the existence of the files and sets its exit status how you wish. Then test that.

If you're using a before-job subroutine, set ErrorCode to a non-zero value to abort the job.

Posted: Fri Oct 21, 2011 7:15 pm
by chulett
Clarify what you mean by "no records to update in the target table". Ray went with "no records in the source" but I'm wondering if you mean you send an update to the target and it updates zero records? :?

Posted: Fri Oct 21, 2011 10:14 pm
by pandeesh
One more way i can think of is, get the Link count using DSGetJobInfo() and abort if it's 0.

Posted: Sat Oct 22, 2011 12:58 am
by prasad v
Thanks to everyone for all your replies.

Ray: I could not know whether there are records in the target table to update. because i get the rows from source table and update to target table. I know while updating only.

Craig: Yes craig, If there are no matching records in the target table. we get rows in the source.

Pandeesh: I believe we can use that function in Transformer only.

Posted: Sat Oct 22, 2011 4:13 am
by pandeesh
So,first of all find out whether there are any matching records are there or not using Lookup or join,After that based on the count decide needs to abort or to update.

Posted: Sat Oct 22, 2011 7:28 am
by chulett
prasad v wrote:Yes craig, If there are no matching records in the target table. we get rows in the source.
That's one of the things the lookup stage is for.

Posted: Sat Oct 22, 2011 8:20 am
by Nagac
that works !! but I want to make the job abort when it fails to update atleast one record.

Posted: Sat Oct 22, 2011 8:35 am
by chulett
I'm not going to have the exactly correct terminology but (from what I recall) you can set the Lookup to Fail if a match is not found...