question

Luis Fernando avatar image
0 Likes"
Luis Fernando asked Luis Fernando commented

How to combine data of two or more Global Tables in one Global Table

Hi FlexSim team,


How can I combine two or more tables in just one table?

I have done a small example of that question.


1702578625693.png


I want to place the output data of the table "Processor1" and "Processor2" in the table called "All lines".

1. How to combine two or more tables.fsm


Thanks,

FlexSim 23.2.2
tablescombine tables
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Luis Fernando commented

Use a query with the UNION ALL clause.


Table.query("SELECT * FROM Processor1 UNION ALL SELECT * FROM Processor2").cloneTo("All Lines")
· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Luis Fernando avatar image Luis Fernando commented ·

Hi Jason,

Please, could you attach the model with this code suggested?

I am trying to paste the code, but appears an error in my model,


Thank you,

0 Likes 0 ·
Luis Fernando avatar image Luis Fernando Luis Fernando commented ·

This is the result obtained after the code:


1702581682542.png

0 Likes 0 ·
1702581682542.png (12.0 KiB)
Jason Lightfoot avatar image Jason Lightfoot ♦ Luis Fernando commented ·

You can either add the processor field to table with something like:

Table.query("SELECT 'Processor1',* FROM Processor1 UNION ALL SELECT 'Processor2', * FROM Processor2").cloneTo("All Lines")

or if you want it like your picture you can use:

treenode t=reftable("All Lines");
t.subnodes.clear();
Array tables=["Processor1","Processor2"];
while (tables.length){
    string tabname=tables.pop();
    treenode row=reftable(tabname).first;
    while (row) {
        row.copy(t);
        row=next(row);
    }
}


0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.