Hi Max,
I need to write data (multiple entries) to a database. The data is originating from a read so in {var:read_db1}, which is being extended with new properties derived from the original data combined with user input.
The {var:read_db1} shows me in the debug that it has the correct values (array with typed array values). But how can I write multiple entires? And can it handle existing keys that instead of an insert the data will be written as an update. Like in sql :
insert into mytable (col1, col2, col3, col4) values (.....), (....), ... ON DUPLICATE KEY UPDATE col2=values(col2), col3=values(col3), col4= values(col4);
If not possible, can there be a custom update function in the write database that still has the events for failure? I did find that via read database I can do such a query, but that seems a bit awkward using a read for writing.
Kind regards,Pim
Hi Pim
How many entries you are saving ? at the moment the Save Data action does not support multi row insert in 1 statement, and you have to do your inserts using a Loop:

There is support for on duplicate update but also for single statements
Thanks max,
Will implement it this way. I was thinking of one update doing all to make sure that if an error occurs at the database during the update, all are invalidated (roll-back). This to overcome states were parts are updated and parts not.
Is there a solution to make sure that in between the loop an error writing leads to a roll-back? If not, no worries it is not that important to have, so not requiring any updates.
Kind regards,Pim
Hi Pim
I have added a Database Transaction and Raise Error action to next update:

