7 Replies Latest reply: Feb 22, 2017 12:52 PM by Michael Solomovich RSS

    Help with If Statement

    Eduardo DImperio

      Hi everyone,

       

      Im trying to use some if's, i already did many times before and for that reason i dont know why this error happen. When  I run the code its expect "Then". For that reason i need some help to understand what im doing wrong.

       

      for a=1 to 2

      LET vCOD_CONTROLE = $(a);

      If ($(a)=1,vPath='MI_csv',vPath='Ultragaz QVD')

       

      RS_SYSTEM:

      load

       

        $(vCOD_CONTROLE) AS COD_CONTROLE,

          $(vCOD_CONTROLE)&'|'&OID_SYSTEM AS OID_SYSTEM,

          $(vCOD_CONTROLE)&'|'&OID_GROUP AS OID_GROUP,

          NAME_SYSTEM,

          SSN_REMOTE_SYSTEM,

          MIN_REMOTE_SYSTEM,

          NUM_CONCENTRATORS,

          NUM_PORTS_CONCENTRATORS,

          CUT_RELIG_FLAG,

          ADDRESS_SYSTEM,

          ADDRESS_NUMBER_SYSTEM,

          NEIGHB_SYSTEM,

          CITY_SYSTEM,

          UF_SYSTEM,

          CEP_SYSTEM,

          STATUS,

        $(vCOD_CONTROLE)&'|'&ID_SYSTEM_TYPE AS ID_SYSTEM_TYPE

          FROM [lib://$(vPath)/RS_SYSTEM.qvd] (QVD);

      If($(a)=2,store RS_SYSTEM into [lib://MI Ultragaz/RS_SYSTEM.qvd]);

        Next

         

          exit script

       

      Thank's

        • Re: Help with If Statement
          m w

          If  $(a)=1 then

               vPath='MI_csv';

          else

               vPath='Ultragaz QVD';

          endif

          • Re: Help with If Statement
            Nicole Smith

            IF statements used in script are written a bit differently than if on a chart.  If I'm understanding what you're trying to do here, I think this is what you need written differently (lines 3 and 26-28):

             

            FOR a=1 TO 2
              LET vCOD_CONTROLE = $(a);
              LET vPath = If($(a)=1,'MI_csv','Ultragaz QVD');
            
              RS_SYSTEM:
              load
              $(vCOD_CONTROLE) AS COD_CONTROLE,
              $(vCOD_CONTROLE)&'|'&OID_SYSTEM AS OID_SYSTEM,
              $(vCOD_CONTROLE)&'|'&OID_GROUP AS OID_GROUP,
              NAME_SYSTEM,
              SSN_REMOTE_SYSTEM,
              MIN_REMOTE_SYSTEM,
              NUM_CONCENTRATORS,
              NUM_PORTS_CONCENTRATORS,
              CUT_RELIG_FLAG,
              ADDRESS_SYSTEM,
              ADDRESS_NUMBER_SYSTEM,
              NEIGHB_SYSTEM,
              CITY_SYSTEM,
              UF_SYSTEM,
              CEP_SYSTEM,
              STATUS,
              $(vCOD_CONTROLE)&'|'&ID_SYSTEM_TYPE AS ID_SYSTEM_TYPE
              FROM [lib://$(vPath)/RS_SYSTEM.qvd] (QVD);
            
              IF $(a)=2 THEN
              store RS_SYSTEM into [lib://MI Ultragaz/RS_SYSTEM.qvd];
              ENDIF
            Next
              
            exit script