Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
etrotter
Creator II
Creator II

Incremental Load - Exit Script not working when Loop field after

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! 

Labels (2)
1 Solution

Accepted Solutions
etrotter
Creator II
Creator II
Author

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)

View solution in original post

2 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

You might try it like this:

Let vExit = if($(vRows)=0 , 'Exit Script;', '');
$(vExit)

-Rob

etrotter
Creator II
Creator II
Author

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)