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: 
Not applicable

Issue calling stored procedure in IF ELSE statement

Hello everyone,

I'm working on our load script and I'm running into a problem. We're implementing incremental load and I've got to call a stored procedure in SQL, but I'm having problems putting the call into an IF ELSE. Here's the code

if $(FirstReload) = true then

  LOAD *;

  SQL EXECUTE EV_TEST;

else

  LOAD *;

  SQL EXECUTE EV_TEST '$(vExecTime)';

end if

So what I'm seeing is when I run this:

The following error occurred:

Script line error:

The error occurred here:

else


So I'm not sure if I'm doing something incorrectly with my call to load the stored procedure, or if I have some syntax wrong with my IF ELSE. 

7 Replies
Gysbert_Wassenaar

Have you tried both sql statements separately without the if-then-else?


talk is cheap, supply exceeds demand
paul_scotchford
Specialist
Specialist

Syntax looks fine, your Stored Proc, is the input param mandatory or optional, as there is no param on the first call? Hence the SQL maybe throwing the error .

Not applicable
Author

I've ran both without the IF ELSE and they both successfully run and bring back data. When I run without the param I get a tabled called EXECUTE EV_TEST. When I run it with the param I get a table called EXECUTE EV_TEST '2016-03-10 12:36:50' and that name changes with the timestamp. Both bring back the data I'm expecting and the correct data that correlates to having or not having the parameter.

Not applicable
Author

The input param is optional. We pass nothing over if it's the first time we're loading data and we want to pass the whole set back to qlik. We pass the parameter if it's not the first load so we can get incremental data. I can run both in SQL and both return data to qlik.

Gysbert_Wassenaar

Since you're using variables... did you enable Legacy Mode? See: Qlik Sense Legacy mode and  Disabling standard mode ‒ Qlik Sense


talk is cheap, supply exceeds demand
Not applicable
Author

Yes legacy mode is enabled. We've got some loading from disk as well so we've had to enable legacy mode for the app.

Gysbert_Wassenaar

Curious. I'm afraid I don't know what's wrong. Can you try it in Qlikview too? Maybe you can generate a log file with more information that way.

Or try replacing one branch of the if statement with some code that can't fail: TRACE $(FirstReload)  $(vExecTime);


talk is cheap, supply exceeds demand