【问题标题】:Qlikview iterate result set of temp table using forloopQlikview 使用 for 循环迭代临时表的结果集
【发布时间】:2019-08-06 08:54:49
【问题描述】:

我想迭代 TempTable 的 ResultSet。 例如:

MyTmpTable:
set emails = 'abc@xyz.com','qwe@xyz.com','asd@xyz.com';

for each mail in $(emails)
  //Api call with Id    https://myapiurl/$(mail)

next

这很好用。我们使用硬编码的电子邮件进行了测试

MyTmpTable:
Load emails from Employee;

for each mail in $(emails)
   //Api call with Id    https://myapiurl/$(mail)

next

但我们想使用动态电子邮件进行迭代。所以尝试了上面的代码,但它抛出 QVD UNEXPECTED END OF DATA 错误

再次尝试使用以下代码

MyTmpTable:
Load emails from Employee;

for each mail in FieldValueList('emails')
   //Api call with Id    https://myapiurl/$(mail)

next

此时间循环运行良好,但在 API 调用时出现相同的错误 QVD UNEXPECTED END OF DATA 错误

这个实现有什么问题?

【问题讨论】:

    标签: qlikview qliksense qlik-expression


    【解决方案1】:

    尝试先在变量中构建列表,然后它的行为就类似于硬编码列表。 chr(39) 只是插入 ' 而不在初始声明中创建文本转义的技巧

    EMAIL_LIST:
    load 
        concat(emails,chr(39)&','&chr(39)) as Email_List
    Resident employees
    ;
    
    let zEmailList = chr(39)&fieldvalue('Email_List',1)&chr(39)
    ;
    
    drop table EMAIL_LIST
    ;
    
    for each mail in $(zEmailList)
    
    trace $(mail);
    
    //Api call with Id    https://myapiurl/$(mail)
    
    next mail
    

    【讨论】:

      猜你喜欢
      • 2019-09-16
      • 1970-01-01
      • 1970-01-01
      • 2013-10-25
      • 2016-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多