Page 1 of 1

Forcing a DataStage job to Abort based on a rule

Posted: Mon Aug 26, 2002 9:20 am
by catmans1
Does anyone know if there is a way to force a DataStage job to abort when a certain condition doesn't match?

I have the need to do balance and controls within DataStage 5.2 on HP-UXIX. I read a file that has the first record containing total count (of all records) and I'm to match it to the count of all records in the file. Once I have the total count of the records after processing then through a transformer I need to see if they match, if so continue processing otherwise abort the job and do not load the records to the Target table.

Has anyone done anything like this?

Any help would be great.

Thank you,

Clarence

Posted: Tue Aug 27, 2002 9:49 pm
by ray.wurlod
Row count reconciliation is a fairly common requirement. If you really want your job to abort, perform the check in an after-stage subroutine and set its ErrorCode argument to a non-zero value.
The number of rows to be processed can be obtained in a before-stage subroutine and loaded into a variable defined as being COMMON.
The number of rows processed can be obtained by requesting the LinkRowCount property of the stage's input link:
RowCount = DSGetLinkInfo(DSJ.ME,DSJ.ME,LinkName,DSJ.LINKROWCOUNT)
This value can be compared with the value in the variable defined as being COMMON that was initialized in the before-stage subroutine.
Ta da!

However, I counsel strongly against aborting jobs. I prefer to retain control in my own structures. So, instead of aborting the job (which is what setting ErrorCode to a non-zero value does), I would set a flag somewhere and have it detected in an after-job subroutine or in a controlling job.