我使用声明
在qlikview中填充数据/ /Importing data from flat file
dataimport:
LOAD @1 AS CoCd,
@2 AS Period,
@3 AS [Doc. Date],
@4 AS [Pstng Date],
@5 AS TranslDate,
@6 AS Reference,
@7 AS DocumentNo,
@8 AS Crcy,
@9 AS Year,
@10 AS [Doc. Type],
\\cagesre005\*GLDetl*
(txt, codepage is 1252, no labels, delimiter is ';', msq)
where @10 = 'KA' or @10 = 'KG' or @10 = 'KR' or @10 = 'KH' or @10 = 'KN' or @10 ='AB' or @10 ='IK' or @10 ='IM' or @10 ='MM' or @10 ='RE' or @10 ='RN';
这个语句完美地加载数据,但它不是动态的,因为如果我想将@10
更改为某个不同的值,我必须直接更改脚本,我正在寻找一种循环数组的方法包含这些值并将数据加载到表
类似于创建变量
$(vDocTypes) = 'KA','KG','KR','KH','KN','AB','IK','IM','MM','RE' ,'RN';
我可以在where子句中使用它来遍历数组中的值并加载数据
答案 0 :(得分:1)
您始终可以使用匹配功能:
set vDocTypes= 'KA','KG','KR','KH','KN','AB','IK','IM','MM','RE' ,'RN';
//Importing data from flat file
dataimport:
LOAD
@1 AS CoCd,
@2 AS Period,
@3 AS [Doc. Date],
@4 AS [Pstng Date],
@5 AS TranslDate,
@6 AS Reference,
@7 AS DocumentNo,
@8 AS Crcy,
@9 AS Year,
@10 AS [Doc. Type]
From
\\cagesre005\*GLDetl* (txt, codepage is 1252, no labels, delimiter is ';', msq)
Where
Match( @10, $(vDocTypes) ) > 0
;