When
when 前缀和后缀用于创建确定是否应执行语句或 exit 子句的条件子句。它可以被看作是完整的 if..end if 语句的简洁替代形式。
语法:
(when condition statement | exitstatement when condition )
如果评估条件为 True,则将仅执行 statement 或 exitstatement。
when 前缀可以在已有一个或多个其他语句的语句中使用,包括其他 when 或 unless 前缀。
参数 | 说明 |
---|---|
condition | 用于评估 True 或 False 的逻辑表达式。 |
statement | 任意 Qlik Sense 脚本语句,不包括控制语句。 |
exitstatement | exit for、exit do 或 exit sub 子句或 exit script 语句。 |
示例 1:
exit script when A=1;
示例 2:
when A=1 LOAD * from myfile.csv;
示例 3:
when A=1 unless B=2 drop table Tab1;