Database - export data

Database - export data

Urvi_Sukharamwala
Not applicable
141 Views
5 Replies
Message 1 of 6

Database - export data

Urvi_Sukharamwala
Not applicable

[ FlexSim 24.0.1 ]

1706543226974.pngI have this example model can you please help me with exporting data on run stop trigger. What should be the flexscript?

0 Likes
Accepted solutions (1)
142 Views
5 Replies
Replies (5)
Message 2 of 6

jason_lightfootVL7B4
Autodesk
Autodesk
Accepted solution

You can either trigger the export of all defined exports like this:

Object dbConnector=Model.find("Tools/DatabaseConnectors/DatabaseConnector1");
function_s(dbConnector,"exportAll");

Or trigger a single export:

Object dbConnector=Model.find("Tools/DatabaseConnectors/DatabaseConnector1");
treenode dbexport=variables(dbConnector).subnodes["exporters"].first;   // the first in the list of exports.
function_s(dbConnector,"exportSingle",dbexport); 

Since it uses function_s calls, you may need to revise this code in the future, so if you need to invoke it in many places I'd place it in a user command and call that from multiple places instead.

Message 3 of 6

Urvi_Sukharamwala
Not applicable

Thank you for the answer. Can you please explain how we can create subnodes (like exporters) as you mentioned for the script?

0 Likes
Message 4 of 6

jason_lightfootVL7B4
Autodesk
Autodesk
They get created by the Database Connector GUI when you set up the export. Are you saying you need to programatically add export definitions?
0 Likes
Message 5 of 6

Urvi_Sukharamwala
Not applicable
Ok got it. Yes, if you can tell me how to do programmatically as well it would be great help
0 Likes
Message 6 of 6

jason_lightfootVL7B4
Autodesk
Autodesk

That's not going to be easy if you want to validate the table and column names against the target database. The basic function to add a global table to the export will start with

function_s(dbConnector,"createExporter",ownerobject(Table("GlobalTableName")); 

The added sdt node will then need its subnodes set for:

1) the export table name in the DB

2) whether to append records

3) the mapping of column names between the tables

0 Likes