Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Not applicable

For Next issue

Hello

I am trying to check that a table has a certain value in it (-1) before it continues with the load process.  If the table does not have the required value then the process loops and tries 3 more times.  The issue I have is the any function  does not work after the 'then' statement.  There is a red squiggle line below the text after the 'then' statement and the load fails (Script line error).

for  i = 1 to 3
Load_temp:
load Active //field name that should contain at least one -1 value
;
SQL SELECT Active
FROM [PJB_ED].dbo.[tbl_PJB_ED_Data]
Where ArrivalDate > DATEADD(dd, DATEDIFF(dd, +2, getdate()), 0)
and Active = -1
and left(RoomBed,4) <> 'XRay'
;
if NoOfRows('Load_temp') <> 0 then exit for; // This line is where the problem is - after then 'then' statement anything gets red squiggle line

sleep 5000; // 5 seconds
next i ;

1 Solution

Accepted Solutions
Not applicable

Re: For Next issue

Hi Sunny

I have solved the problem. Adding an endif helped fix it. The exit for has to be on the next line (as you identified) but the endif is also required.

Thanks again for responding and helping me solve the issue.

Below is the corrected part of the code.

if NoOfRows(vRows) <> 0 then
exit for;
endif

3 Replies

Re: For Next issue

Moving the script to the next line seems to resolve the issue... Not sure why we need to move it to next lime, but you can see in the image that it works

Capture.PNG

Not applicable

Re: For Next issue

Hi Sunny

Yes I tried moving it to the next line but the script fails even though the red line disappears.

Cheers

Not applicable

Re: For Next issue

Hi Sunny

I have solved the problem. Adding an endif helped fix it. The exit for has to be on the next line (as you identified) but the endif is also required.

Thanks again for responding and helping me solve the issue.

Below is the corrected part of the code.

if NoOfRows(vRows) <> 0 then
exit for;
endif