Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Team,
Is it possible to Concatenate multiple tables into 1 table.
I have Table, Table1, Table2,...Table9 (can increase in future. i.e dynamic numbers of tables)
So instead of writing
FINAL:
LOAD * RESIDENT Table; DROP TABLE Table;
Concatenate
LOAD * RESIDENT [Table1]; DROP TABLE [Table1];
I want to automate this part..please help/suggest.
Thanks in advance
You can use For Loops
Also look here:
If you want to dynamically check your tables, you can use table functions like NoOfTables() and TableName().
You can use a Loop in the script to iterate over all tables, check if you want to concatenate the tables and do so:
Test:
LOAD 1 as Test
AutoGenerate 1;
Test2:
LOAD 1 as Test2
AutoGenerate 1;
AnotherTable:
LOAD 1 as Anotherfield
AutoGenerate 1;
Test3:
LOAD 1 as Test3
AutoGenerate 1;
Let vTableNo = NoOfTables();
Final:
LOAD 0 as Dummy AutoGenerate 0;
For vIter = 0 to vTableNo-1
Let vTable = TableName( vTableNo-1-vIter);
If vTable like 'Test*' Then
Concatenate (Final)
LOAD * Resident $(vTable);
DROP Table $(vTable);
endif
Next
DROP Field Dummy;