is it possible to do multiple activitycount check in teradata?

729 views Asked by At

using bteq script, I want to delete the temporary error and log tables created during TPT load namely ErrorTable1, ErrorTable2, LogTable.

I have prepared following bteq script with if-else, which will drop tables if it exists

.LOGON ${HOST}/${USER},${PASS};

SELECT 1 FROM dbc.TablesV WHERE CONCAT(DataBaseName, '.', TableName) = 'Test.ErrorTable1';
.IF ACTIVITYCOUNT = 0 THEN GOTO CHECK_1;
DROP TABLE Test.ErrorTable1;


.LABEL CHECK_1;
SELECT 1 FROM dbc.TablesV WHERE CONCAT(DataBaseName, '.', TableName) = 'Test.ErrorTable2';
.IF ACTIVITYCOUNT = 0 THEN GOTO CHECK_2;
DROP TABLE Test.ErrorTable2;


.LABEL CHECK_2;
SELECT 1 FROM dbc.TablesV WHERE CONCAT(DataBaseName, '.', TableName) = 'Test.LogTable';
.IF ACTIVITYCOUNT = 0 THEN GOTO DONE;
DROP TABLE Test.LogTable;


.LABEL DONE;

.LOGOFF
.EXIT

My question is, in teradata bteq, can I use ACTIVITYCOUNT multiple times, like in above script, to check various table's existence?

0

There are 0 answers