question

Thomas JR avatar image
0 Likes"
Thomas JR asked Thomas JR commented

Is it possible to append Table.query table to some global table?

Title. Currently I simply manually add rows to the global table and fill in each table entry but it is quite slow.

FlexSim 20.2.3
global tableflexsim 20.2.3sql query
5 |100000

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

Steven Hamoen avatar image
0 Likes"
Steven Hamoen answered Steven Hamoen commented

@Thomas JR It looks there is not a single method you can use, but it is not too complex to write a simple for loop that loops through the result of your query and copies the information to a table.

· 2
5 |100000

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

Thomas JR avatar image Thomas JR commented ·

@steven.hamoen

I already do so. Yes, it‘s very simple but I was looking for a built-in function because they are often faster, and my main concern for the moment is the execution speed of my model.

0 Likes 0 ·
Steven Hamoen avatar image Steven Hamoen Thomas JR commented ·

@Thomas JR This should not be slow. If you want to see where your model slows down, open the Flexscript Code Profiler under the Debug menu. There you can see if indeed this code is making your model slow or if there is something else.

0 Likes 0 ·
Roi Sánchez avatar image
1 Like"
Roi Sánchez answered Thomas JR commented

Hi @Thomas JR, take a look at the cloneTo() method. You can easily clone the result of a query to a Global Table.

· 7
5 |100000

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

Thomas JR avatar image Thomas JR commented ·

The problem is that I need to append several times to the same global table and cloneTo simply replaces the content with the result of the query.

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Thomas JR commented ·

Then you can include the first table:

Table results=Table.query("SELECT * FROM GlobalTable2 UNION ALL SELECT * FROM GlobalTable1");
results.cloneTo(Table("GlobalTable1"));
2 Likes 2 ·
Joerg Vogel avatar image Joerg Vogel Jason Lightfoot ♦ commented ·

@jason.lightfoot, do you know a flag or clause to copy identical rows of involved tables? If I do this query the result is reduced to unique values only.

SQL_Table_UNION_clause.fsm

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.