Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Concatenate of multile tables

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

2 Replies
swuehl
MVP
MVP

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;