Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Qlik Community,
I'm working on building an incremental loader, but I'm having trouble with the logic needed when there is no data.
To pull in the data I built a loop that pulls in each new id and cycles them through the REST connection statement using a loop. The issue I'm having is when there is no new data, I want the script to exit, but because there is a loop statement in the script, it errors with the " Semantic error The control statement is not correctly matched with its corresponding start statement Loop" despite the exit script. See an excerpt of my script below.
Is there a workaround for this? I can't put an If around the whole thing because I'm using If/end if in the loop. Additionally, I've tested the exit script logic and it will exit successfully if the loop statement is not present.
Source:
load
id,
RowNo() as RowNo
FROM
SourceTable
(qvd)
Where
not Exists(key,id) and not isnull(id);
let vRows=if(isnull(Peek('RowNo',-1,'Source')),0,Peek('RowNo',-1,'Source'));
Exit script when $(vRows)=0 //Exit script here if there are no new records
Set i=0;
Do while i<$(vRows)
Rest connection logic to pull in all tables..................................
let i=i+1;
Loop;
Thanks in advance for your help! Please let me know if I can provide any additional info!
Thanks Rob!
Unfortunately, that solution didn't work, but I used that logic for the "loop" function, and it worked:
Let vLoop = if($(vRows)=0 , '', 'Loop');
$(vLoop)
You might try it like this:
Let vExit = if($(vRows)=0 , 'Exit Script;', '');
$(vExit)
-Rob
Thanks Rob!
Unfortunately, that solution didn't work, but I used that logic for the "loop" function, and it worked:
Let vLoop = if($(vRows)=0 , '', 'Loop');
$(vLoop)