question

Anutt K avatar image
0 Likes"
Anutt K asked Julie Weller commented

Update cell data to Database Table

Hello. I want to export data from FlexSim GlobalTable to Database Table (SQL Server).

Now I can use this script to INSERT data to Database Table.

1688314242482.png

But INSERT It will be add new row in Database Table everytime when execute the script.

1688314365451.png

Then, I has change from INSERT to UPDATE for update new data only. (I won't to add new row). So that invalid.

1688314394040.png

1688314405987.png

How can I just update new data to old row and won't to add new row in Database Table. Thank You.

FlexSim 23.1.2
databasedatabase exportupdate database
1688314242482.png (101.7 KiB)
1688314365451.png (6.0 KiB)
1688314394040.png (50.1 KiB)
1688314405987.png (15.5 KiB)
· 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.

Julie Weller avatar image Julie Weller commented ·

Hi @Anutt K, was Jason Lightfoot's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.

0 Likes 0 ·

1 Answer

Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

Either DELETE * FROM test2 and then perform inserts for the whole table, or update based on a unique field combination (key ) using the WHERE clause.

· 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.

Anutt K avatar image Anutt K commented ·
Can you give some exam script ?
0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Anutt K commented ·
UPDATE Test2 SET C1 = :C1, C2 = :C2, C3 =  :C3 WHERE ID == :ID

Requires to bind the ID column value as a parameter as well to be able to find the matching row in the WHERE clause.

1 Like 1 ·