All Forums Teradata Applications
sayaksitex 24 posts Joined 09/12
04 Sep 2012
Bteq script required to validate record count of Source and target table.

I have a source and a target. I want to make a post session failure command based on the record count of my source and target tables.

Thanks

ulrich 816 posts Joined 09/09
04 Sep 2012

Sounds like a good idea. What is your issue?

feel free to donate bitcoin:12kgAUHFUqvG2sQgaRBXFhCwyf9HXdkGud

sayaksitex 24 posts Joined 09/12
04 Sep 2012

I have 3 sources and a target with 3 instances of it. I want a post session failure, i.e. after the session succeds, if we find there is a mismatch in record count of source and target, then the workflow should fail.

 

I think it can be done through a bteq script. If we give a bteq script in 'Post Session Failure Command' in Session properties, it can be done.

I have prepared a sql query for it

sel( ( sel count (*) from src_tab_1) +  sel count (*) from src_tab_2) +  sel count (*) from src_tab_3) - sel count (*) from target_tab))

if result of the query is zero its fine, else there must be a post session failure.

Can you please provide me with the bteq script for the above sql query.

Thanks..

dnoeth 4628 posts Joined 11/04
05 Sep 2012

You just have to add a HAVING:

sel( ( sel count (*) from src_tab_1) +  sel count (*) from src_tab_2) +  sel count (*) as x
from src_tab_3) - sel count (*) from target_tab))
having x <> 0;

.if activitycount = 1 then quit 33;

Dieter

Dieter

05 Sep 2012

i think 'X' as an alias should come before 'having'

 

05 Sep 2012

And we may have to use WHERE instead HAVING

have a try Sayak.....

 

sayaksitex 24 posts Joined 09/12
05 Sep 2012

Thank u....dnoeth & Babbi......it worked...cheers...!

You must sign in to leave a comment.