Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
prees959
Creator II
Creator II

Renaming Columns of a Dynamic Table

Hi.

Im looping through a sql connection that dynamically names certain columns of a table with each pass so each time the 4th, 5th and 6th columns have a different name depending on the contents....

Is there a way I can rename, for example, the 4th, 5th, 6th columns of this table dynamically?

Many thanks

Phil

1 Reply
marcus_sommer

Within the load itself it's not possible but you could change them afterwards maybe with something like this:

for i = 4 to 6

     let FieldName = fieldname($(i), tablename(nooftables()));

     rename field $(FieldName) to FieldXYZ;

next

Of course you need also some logic to define the right name to the right field - and you couldn't change it to an already existing fieldname (if this is needed you need some more logic).

Also a reverse approach is possible by creating a load-statement on the fly by loading the first record from the table, looping through all fieldnames and creating with them a load-string including some logic to replace the wrong fieldnames with the right ones - an then applying this load-string to the real load.

- Marcus