Page 1 of 1

Count Validatation and updation of Job even if it fails

Posted: Thu Jan 04, 2018 9:06 pm
by nibumathewbabu
Hi All,
This is my requriement

I need to compare file source count with target table count and write the both counts in to an audit table with status Success(If count are equal) or Fail on the other case and I also need to fail the job if count mismatch is there.

The issue I face is,If we try to achieve above with a lookup stage and fail the job if count mismatches, the counts wont be written in target table as the job is aborting.

Kindly suggest a way out

Posted: Fri Jan 05, 2018 7:35 am
by chulett
Can you not perform the check, write the results to the audit table and only then abort the job if required?

And there was no reason to post this twice, I removed the duplicate post.

Posted: Fri Jan 05, 2018 8:09 am
by PaulVL
External source stage with a filter: wc -l /path/filename.txt output to column source_count
Connector stage SQL statement: select count(*) from table output to column table_count

now just use a transformer on that stuff and redirect output to success or failure if condition branch.

Posted: Mon Jan 08, 2018 1:35 pm
by nibumathewbabu
Thank you for the response.But I need to write the table count to audit table and if count mismatches i need to fail the job also that is the req

Posted: Mon Jan 08, 2018 5:00 pm
by chulett
Okay then, how about chiming in on my response?

Posted: Tue Jan 09, 2018 12:09 pm
by nibumathewbabu
Thank you for the response. I am fine with first part you suggested.

"and only then abort the job if required"

Could you please specify how to implement above step?

Posted: Tue Jan 09, 2018 12:59 pm
by chulett
Well, here's what I was thinking.

First step would be to record the results in your audit table, so make sure when that happens that your transaction size is set to 1 for the record is not only inserted but also committed so it doesn't rollback when you fail the job. I'm thinking it could be as simple as two output links from a transformer, first one to the audit table insert and then a second one (enforced by link ordering) that is a "reject" link set to "Abort after rows=1". You shouldn't need a constraint on the audit link as it should always trigger the insert but your reject constrain should only trigger when your counts don't match.

Posted: Tue Jan 09, 2018 7:53 pm
by nibumathewbabu
Thanks Craig.
As you suggested I have two links from transformer


Link1: Constraint source count=target count then to target table with update audit table with target count and status in table is success

Target DB stage Read committed,Record Count and Array size=1


Link 2

Constraint source count <> target count then to target table with update audit table with target count and abort after 1 row and status in table is failed


Target DB stage Read committed,Record Count and Array size=1

Please guide whether the above idea is what you had meant

Posted: Tue Jan 09, 2018 11:30 pm
by chulett
Not quite.

The suggestion was to use the first link to update the audit table regardless of success or failure. Meaning always do it, record the result and commit the transaction, match or mismatch.

Then all the second link does is abort the job when the counts don't match. It doesn't even need to have a 'real' target at the end, perhaps use a flat file writing to /dev/null or something of that nature.

Posted: Thu Jan 11, 2018 12:37 pm
by nibumathewbabu
Thanks, I will try and let you know