3 Replies Latest reply: May 6, 2016 5:03 AM by kushal chawda RSS

    Create Empty Table for a Looping Load

    Jonathan Dienst

      It is common to load from a set to files using a loop like a ForEach over a FileList. If the files are not identical, you need to explicitly concatenate them, but you cannot use concatenate in the first iteration of the loop as the table does not exist yet. One common solution is this:

       

      Set vTable = ‘MyTable:’;

      For ......

        $(vTable)

        LOAD ……

        ;

       

        Set vTable = ‘Concatenate(MyTable)’;

      Next

       

      and clean up the variable at the end of the load:

      Set vTable = ;

       

      There is another way that I prefer. Create an empty table before the loop. Like this:

       

      MyTable:

      LOAD 0 as ID AutoGenerate 0;

       

      For ......

        Concatenate(MyTable))

        LOAD ……

        ;

      Next


      (Use a field that is in the main load inside the loop - ID in this example).

      AutoGenerate 0 creates an empty table. The other columns are added as required by the loads in the loop. There is no clean up necessary and the syntax checker is not confused by the embedded variable.