Teradata BTEQ 条件未按预期工作

Teradata BTEQ conditional not working as expected

我休息了。我需要检查的地方 如果 teradata table 存在。如果是则删除记录 如果否,则根据 DDL

创建 table

问题是..两个语句都在执行,但我想要 运行 的条件没有成功 运行

select * from doc.tablesV
where database = DATABASE_NAME 
and table = TABLE_NAME ;   

.if activitycount = 1 then .GoTo del_tab ;   
.if activitycount = 0 then .GoTo create_tab ;
.LABEL del_tab ;   
delete  table DATABASE_NAME.TABLE_NAME;
.LABEL create_tab;
create multisite table ...;

在日志中我看到这条消息 对于第一个 运行(当不存在 table 时)

activity count =0
.label del_tab
skipped
.label create_tab
Go to create_tab

del_tab 命令被执行(虽然它说跳过) 它失败了(因为 table 不存在)

我的条件逻辑有没有错误?或者 BTEQ 中的条件逻辑是否有任何限制? 谢谢 帕里

而不是 activity count ,使用 count(1) 检查记录是否存在于 dbc.tables 中。然后继续你的逻辑。下面的代码应该可以工作。

INSERT INTO table_cnt
(
cnt_var
)
select count(1) from doc.tablesV
where database = DATABASE_NAME 
and table = TABLE_NAME ; 

.if cnt_var = 1 then .GoTo del_tab ;   
.if cnt_var = 0 then .GoTo create_tab ;
.LABEL del_tab ;   
delete  table DATABASE_NAME.TABLE_NAME;
.LABEL create_tab;
create multisite table ...;