0

I want to iterate the ResultSet of a TempTable. For eg:

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

This works fine. We tested with hard-coded emails

MyTmpTable:
Load emails from Employee;

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

next

But we want to iterate with dynamic emails. So tried the above code but its throwing QVD UNEXPECTED END OF DATA Error

Again tried with the below code

MyTmpTable:
Load emails from Employee;

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

next

This time loop works fine but getting the same error QVD UNEXPECTED END OF DATA Error on API call

Whats wrong with this implementation?

Gnik
  • 7,120
  • 20
  • 79
  • 129

1 Answers1

0

Try building the list in the variable first, then it sould behave like the hardcoded list. chr(39) is just a trick to insert ' without creating a text escape in the initial declaration

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
The Budac
  • 1,571
  • 1
  • 8
  • 10