question

Sung Kim avatar image
0 Likes"
Sung Kim asked Sung Kim commented

Trouble to use dbexporttable

I tried to export one of global table from FlexSim to my local database. I use SQL Express free version for DB. The script I use is as follows;

//Script Starts***********************************************************************************

dbclose(); //In case

dbopen("BOBSTR", "select count(*) from [dbo].[BSOrders]", 0);
double numLines = dbgettablenum(1, 1);

Table tblItemRecord = reftable("ItemRecord");

//dbexporttable("ItemRecord", 1, 1, tblItemRecord.numRows, tblItemRecord.numCols);
dbexporttable("ItemRecord", 1, 1, 3, 3);

dbclose();

//Script Ends***********************************************************************************

I believe the connection is successfully done since I have correct 'numLines' return value. However, after 'dbexporttable' is executed, no tables are exported to BOBSTR database. I tested both (1) ItemRecord exists in BOBSTR DB and (2) ItemRecord not exists.

Does anybody have same or similar issue? Anyone can help me to export the global table? I am not sure what I missed. Thank you for your help much in advance.

ps. I think it would not help much to upload the model, since it is tied to my local DB. I hope someone can duplicate the issue using its own local DB. Thanks.

FlexSim 19.0.0
databaseexport data
· 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.

1 Answer

Phil BoBo avatar image
0 Likes"
Phil BoBo answered Sung Kim commented

The End of Replication trigger fires twice for each replication: once on the background child thread that is running the replication and then again on the main FlexSim thread.

When it executes on the main FlexSim thread, it passes a treenode reference to the child's experimenter node. That way, you can pass data from the child to the parent via this trigger and that node.

See the "Write to a GlobalTable" pick option code for an example of storing data in the child's experimenter node and then reading it from the main FlexSim thread.

Depending on whether you want your code to fire on the child background process or on the main FlexSim process, you should add a condition to your code:

  1. if (objectexists(childexpfolder)) {
  2. // End of Replication on the main process
  3. } else {
  4. // End of Replication on the child process
  5. }
· 1
5 |100000

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