Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello everyone,
I have been searching the forums for a solution or explanation however until now i am not able to find either
The following is the situation:
I have a script in which a connection is made via ODBC to a SQL source.
However i would like QlikView to load existing data from QVD's if the ODBC connection cannot be established (via the ScriptError) but i do not seem to get this working.
I have tried the same idea with setting up a variable which should set the value to "Good" if the THEN bit is processed and "Bad" when the ELSE bit is processed but i only seem to getting the ELSE bit being processed.
SET Errormode=0;
ODBC CONNECT TO Test;
Let vScriptError = ScriptError;
Let vScriptErrorDetails = ScriptErrorDetails;
If ScriptError=1 THEN
SET vTest='Good';
ELSE
SET vTest='Bad';
END IF
I have tried multiple ScriptError codes and >0 but nothing seems to trigger the THEN bit.
With kind regards,
Martin van der Bent
SET Errormode=0;
ODBC CONNECT TO Test;
Let vScriptError = ScriptError;
Let vScriptErrorDetails = ScriptErrorDetails;
If vScriptError=0 THEN
SET vTest='Good';
ELSE
SET vTest='Bad';
END IF
TRACE $(vTest);
Hi Martin,
Maybe you are using a wrong statement for your if condition. The ScriptError statement gives you a string, not a numeric value. Try this:
SET Errormode=0;
ODBC CONNECT TO Test;
//Let vScriptError = ScriptError;
Let vScriptError = ScriptErrorCount;
Let vScriptErrorDetails = ScriptErrorDetails;
If '$(vScriptError)'=1 THEN
SET vTest='Good';
ELSE
SET vTest='Bad';
END IF
Regards,
Enrique.
SET Errormode=0;
ODBC CONNECT TO Test;
Let vScriptError = ScriptError;
Let vScriptErrorDetails = ScriptErrorDetails;
If vScriptError=0 THEN
SET vTest='Good';
ELSE
SET vTest='Bad';
END IF
TRACE $(vTest);
Hi Enrique,
I have validated this approach and it seems to do the trick!
Thanks for the help.
With kind regards,
Martin van der Bent
Hi Massimo,
I see the mistakes I have made in my script, thanks for pointing it out, works like a charm!
With kind regards,
Martin van der Bent