6 Replies Latest reply: Jul 18, 2011 2:19 PM by Siarhei Karpusenka RSS

    RENAME in a loop problem

      Hi,

       

      I have the following setup:

      Table A loads data from an excel file, Table B loads different data from the same excel file.

      Table A contains fields with default names (@1, @2, @3, etc), table B contains the actual names for the fields in table A.

      I have multiple excel files to go through, so I have the renaming process in the loop that goes through all of the my files.

      Mapping load didn't work for me, so I am working on this workaround.

      Within the file loop, I have the RENAME loop, which looks like this:

       

      FOR i=0 to NoOfRows('FieldNameMap')-1

          LET vNewFieldName = Peek('Field Name',$(i),'FieldNameMap');

          LET vOldFieldName = '@' & ($(i)+1);

          RENAME Field '$(vOldFieldName)' to '$(vNewFieldName)';

      NEXT

       

      This process works fine for the first excel file; however, the second time around, I can see in the debugger that the RENAME loop takes in the correct field names, but after the loop, my table still has @1, @2, @3, etc as the names of the fields!

       

      Another thing I should mention is that the tables are created at the beginning of the file loop, then one table is used as a resident table and then both the table and the map are dropped before the loop gets to NEXT, so I'm esentially starting with new tables every time I loop through with a new excel file.

       

      To sum up: why do the fields keep their names after the first file is processed?

       

      Thanks,

       

      Siarhei K.