4 Replies Latest reply: Jan 23, 2017 3:26 AM by Martin van der Bent RSS

    IF.. Then.. Else not working as intended with ScriptError

    Martin van der Bent

      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