All Forums Database
Pawankumar 4 posts Joined 08/13
21 Sep 2013
I'm trying to automate a process in Teradata, if the count is greater than 5 then do not execute the below statement

--------------------------------------------------
i'm trying to automate a query that i have written , here i want to enable a QC check:
--------------------------------------------------
if count on tableX is > 5
then donot execute any statements below;
 
create volatile table T1 as
(
select * from TableA;
) with data
on commit preserve rows;
create volatile table t2 as
(
select * from TableB;
) with data
on commit preserve rows;

dnoeth 4628 posts Joined 11/04
21 Sep 2013

Which tool do you use to submit it?
In BTEQ and (SQL Assistant 13.10+) you can use basic conditional logic:

select count (*) from tableX
having count(*) > 5;
-- no row returned when count(*) <= 5

-- no need to any additional steps
.if activitycount = 1 then .exit;

or

-- just skip some statements and then go on
.if activitycount = 1 then .goto nextStep;
 
create volatile table T1 as
(
select * from TableA;
) with data
on commit preserve rows;
create volatile table t2 as
(
select * from TableB;
) with data
on commit preserve rows;

.label nextStep;

 
Dieter

Dieter

Pawankumar 4 posts Joined 08/13
21 Sep 2013

Thanks Dieter, i use Teradata my sql assistant 13.11.0.05
i will try this out! Thanks a lot

Also one other thing, can i mail the result that comes out from  the count * statement

Pawankumar 4 posts Joined 08/13
22 Sep 2013

Hi,
can somebody help me out,
i'm looking at a automated Qc process. i want to be able to export the Qc results via mail or directly into my local as a csv file every time my code runs. Is this feasible in Teradata. Can i write a script to achieve this in Teradata?
 

emilwu 72 posts Joined 12/07
24 Sep 2013

check Teradata BTEQ in the product manual. 

You must sign in to leave a comment.