Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
rheald
Contributor
Contributor

Problem adding File Name column when concatenating several files using for loop

Hello. 

I am loading several files using a for loop and want to concatenate them (all fields in the files are the same).

I would like to add a column which shows which file the data has come from.

I have managed to get a column which displays the file names, however now I am having a problem concatenating them.

Please help! Copy of my code so far below. Many thanks.

 

Let vTableCount = NoOfRows('OracleTableList');

For i = 0 To $(vTableCount) -1

              LET vMyTableName = Peek('OWNER', $(i), 'OracleTableList') & '.' & Peek('TABLE_NAME', $(i), 'OracleTableList');

             LET vFileName = Peek('TABLE_NAME', $(i), 'OracleTableList');

 

TEMP_KPI_CUSTOMER_COMBINED:

     SQL SELECT * FROM $(vMyTableName);

          NoConcatenate

 

Merged_Table:

Load *,

  '$(vFileName)' as FileName

  resident TEMP_KPI_CUSTOMER_COMBINED;

 

drop table TEMP_KPI_CUSTOMER_COMBINED;

Next i;

 

Labels (2)
0 Replies