4 Replies Latest reply: Jun 11, 2013 4:27 AM by sarah_mader RSS

    for each loop and array in load statement - How to handle text with space?

      Hi,

       

      i try to load data with a for each - loop and an array.

      When i use numbers the syntax works.

      But i have to use text with space, for example "cooking procedure".

      A little example table:)

       

       

      DataTable:

       

      Action_idsystemphase
      11clean procedure
      23clean procedure
      31clean procedure
      44clean procedure
      52clean procedure
      62clean procedure
      73clean procedure
      83clean procedure
      94cooking procedure
      102clean procedure
      113eat procedure
      121clean procedure
      131clean procedure
      142cooking procedure
      152clean procedure
      164clean procedure
      171cooking procedure

       

       

      This is the Syntax i use in load statement:

       

      SET sysArray = '1','2','3','4';

      SET phaseArray='cooking procedure','clean procedure','eat procedure';

       

      SET id=0;

       

      for each i in $(phaseArray)

           for each j in $(sysArray)

       

                ActionDone:

                Load $(id) as ID,count(Action_id) as AmountActions

                 resident DataTable where system=$(j) and phase =$(i);

       

                SET id=$(id)+1;

           next

      next

       

       

      But QV is not able to get the first field of phaseArray.

      I get following error:

       

       

      ERROR:   Field not found - <cooking>

                     ActionDone:

                                         Load 0 as ID,count(Action_id) as AmountActions resident +

                                         DataTable where system=cooking procedure and phase =1;

       

       

       

      I also tried:

       

      SET sysArray = '1','2','3','4';

      SET phaseArray=''cooking procedure'',''clean procedure'',''eat procedure'';                           

                  // i add to the first  '  another  ', dont read it as "

       

      SET id=0;

       

      for each i in $(phaseArray)

           for each j in $(sysArray)

       

                ActionDone:

                Load $(id) as ID,count(Action_id) as AmountActions resident DataTable

                where system=$(j) and phase =$(i);

       

                SET id=$(id)+1;

           next

      next

       

       

      ERROR:          Script line errror:

                             for each i in ''cooking procedure'',''clean procedure'',''eat procedure''

       

       

      It seems like that the space is the Problem.

      I cant change these identifiers.

      Anybody any idea?:)

      Thx for help!