Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
brunolelli87
Creator II
Creator II

On Error resume to next

Hello guys

I'm using a FOR loop in my Scrip, to load some files, as follow:

For each Ticker in 'AZUL4', 'CVCB3', 'BBDC4'

          LOAD... FROM

Next

 

But sometimes, due to some external conditions some Ticker may not be available at the time of the loading, so the script stops, show me the error, and asks for what to do...

I would like to insert some kind of code, saying that I don't care if you can't load it now, so, on error, just go to the next Ticker. How can I do ti?

Thanks

1 Solution

Accepted Solutions
cwolf
Creator III
Creator III

hy did I expect this question? 🙂

One solution is by using ErrorMode:

set failingTickers='';
set ErrorMode=0;

For each Ticker in $(NomeEmpresas), $(NomeBancos)

	Cotação:
	LOAD ... From ...;

	if ScriptError>0 then
		set failingTickers='$(failingTickers)$(Ticker),';
	end if

Next Ticker

set ErrorMode=1;

if len('$(failingTickers)')>0 then
	Trace Failing Tickers: $(failingTickers);
end if

View solution in original post

8 Replies
Brett_Bleess
Former Employee
Former Employee

Believe the following should likely put you on the right track:

https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/Error...

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
martinpohl
Partner - Master
Partner - Master

is your source a database or based on files?

If files, you can check with

if (isnull(filetime(Ticker_file.txt)) then

endif

load

...

next

 

brunolelli87
Creator II
Creator II
Author

Yes,

My source is based on files.
Actually I'm reading around 100 files.

Each file contains 5.000 rows approximately.

 

Would you mind to better explain how this If function works?

Thanks

cwolf
Creator III
Creator III

hy did I expect this question? 🙂

One solution is by using ErrorMode:

set failingTickers='';
set ErrorMode=0;

For each Ticker in $(NomeEmpresas), $(NomeBancos)

	Cotação:
	LOAD ... From ...;

	if ScriptError>0 then
		set failingTickers='$(failingTickers)$(Ticker),';
	end if

Next Ticker

set ErrorMode=1;

if len('$(failingTickers)')>0 then
	Trace Failing Tickers: $(failingTickers);
end if
Brett_Bleess
Former Employee
Former Employee

Just a quick caveat on setting ErrorMode=0, that will in fact ignore all errors, so you need to be sure things are working properly etc., as otherwise this may mask an issue, just wanted to be sure you were fully aware of this part of using that function.  

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
Vegar
MVP
MVP

As @Brett_Bleess  says all errors will be ignored with ErrorMode=0. So I would recommend you to restore the ErrorMode to 1 after you are finished loading your files in the script.

Do your initial stuff;

ErrorMode=0;

Do Your critical stuff;

ErrorMode=1;

Do the rest of your script;

Brett_Bleess
Former Employee
Former Employee

@Vegar CWolf did show that in their example, but not bad to point that out again for others that drop by...

Cheers,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
brunolelli87
Creator II
Creator II
Author

Yes, you met all my expectations!

Thank you so much...