7 Replies Latest reply: Jul 22, 2014 12:56 PM by Herbert Beck RSS

    automatic load concatenation with while

    Herbert Beck

      Dear all,

      automatic concatenation does not always work with WHILE:

      class:
      LOAD IterNo() AS class
      WHILE IterNo() <= 5
      ;
      LOAD 6 AS class
      AutoGenerate (1)
      ;
      LOAD 7 AS class
      AutoGenerate (1)
      ;

      The second Load-statement is not executed, class 6 is not loaded.

      Replace WHILE IterNo() <= 5 with  AutoGenerate(5) and replace IterNo() with RowNo() and the script will work fine.

      Kind regards,

      Herbert

        • Re: automatic load concatenation with while
          Henric Cronström

          It works fine.

           

          In your script you have two tables concatenated into one: the first Load is a preceding Load that loads from the second load. But the field "class" from the second load is not carried through since this field isn't listed in the first load. But the resulting table nevertheless has 6 rows - five from the first two loads, and 1 from the last.

           

          Image5.png

           

          Try this instead:

           

          class:
          LOAD class & '-' & IterNo() AS class
               WHILE IterNo() <= 5 ;
          LOAD 6 AS class
               AutoGenerate (1);
          LOAD 7 AS class
               AutoGenerate (1);

           

          HIC

          • Re: automatic load concatenation with while
            Tresesco B

            Returns an integer for the number of the currently read row of the source data table.

            In your first load, there is nothing (a record) to load at the very first read, hence iterno() returns nothing. So your first load :

            LOAD IterNo() AS class
            WHILE IterNo() <= 5
            ;
            is loading nothing.

             

             

            The rest behavior is not yet clear to me. I will get back if can comprehend something meaningful.

                 

            • Re: automatic load concatenation with while
              Srikanth P

              HI Herbert, You have only 2 Load statements and so you got 6 rows.

               

              Try like below:

              class:
              LOAD IterNo() AS class
              AutoGenerate (1) WHILE IterNo() <= 5
              ;
              LOAD 6 AS class
              AutoGenerate (1)
              ;
              LOAD 7 AS class
              AutoGenerate (1)
              ;

              The above example have the 3 load statement having 3 sources.

              • Re: automatic load concatenation with while
                Herbert Beck

                Thanks for your responses:)) But now I am more confused.

                1)

                class:
                LOAD IterNo() AS class
                WHILE IterNo() <= 5
                ;

                loads nothing :((

                 

                2)

                class:
                LOAD IterNo() AS class
                WHILE IterNo() <= 5
                ;
                LOAD 6 AS class
                AutoGenerate (1)
                ;

                loads 5 rows (:(

                 

                3)

                class:
                LOAD IterNo() AS class
                WHILE IterNo() <= 5
                ;
                LOAD 6 AS class
                AutoGenerate (1)
                ;
                LOAD 7 AS class
                AutoGenerate (1)
                ;

                is loading 6 rows: 1,2,3,4,5 and 7 ???

                 

                4)

                class:
                LOAD RowNo() AS class
                AutoGenerate(5)
                ;
                LOAD 6 AS class
                AutoGenerate (1)
                ;
                LOAD 7 AS class
                AutoGenerate (1)
                ;

                is loading all 7 rows. This is the only thing that looks fine. Therefore I will apply script no 4).

                Kind regards,

                Herbert

                 

                • Re: automatic load concatenation with while
                  Tresesco B

                  Let me explain my understanding:

                   

                  The bottommost load statement is generating one record '7' (field- class). The middle one is producing record '6' and being referenced in the uppermost load (prceding load) and it iterates over the same record ('6' - but note the value '6' itself is not referred in the preceding load, it is actually being used as a record for iteration) five times and generating 1,2,3,4,5 by the iterno(). Now the two tables (the bottommost one and uppermost one) are getting concatenated to get 1,2,3,4,5,7. Don't get surprised that '6' is not there, because the middle table is not existing separately to be concatenated it is just been used as the input for uppermost table.

                   

                  To answer the question -why the first load alone can't generate a table  - There is no record to be iterated on in that load, hence it can't generate a table. To be able to use the similar load you have to use Autogenerate() alongwith it or some table already existing.