You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know it is possible to combine multiple SELECT statements, but I have a use case where I could use some sort of combine Query for delete + insert.
In this specific use case, I need to delete all rows (1 + n) that match a certain ID, and then insert new rows again in one transaction.
There are alternatives like delete only what should not be there and insert only what is missing. But in a event-sourced system this can get out of hand quickly.
operations[0]: "delete from ... where foreign_id = ..."
operations[1]: "insert into ... values (...)"
operations[2]: "insert into ... values (...)"
operations[3]: "insert into ... values (...)"
But the system underneath which executes the individual statements cannot guarantee the order of queued individual statements.
So my idea is to queue one operation which contains the combined individual statements statements.
operations[0]: "delete from ... where foreign_id = ...; insert into ... values (...); insert into ... values (...); insert into ... values (...); insert into ... values (...);"
Is there any support or recommended way to do this?
The text was updated successfully, but these errors were encountered:
Hello
I know it is possible to combine multiple
SELECT
statements, but I have a use case where I could use some sort of combineQuery
for delete + insert.In this specific use case, I need to delete all rows (1 + n) that match a certain ID, and then insert new rows again in one transaction.
There are alternatives like delete only what should not be there and insert only what is missing. But in a event-sourced system this can get out of hand quickly.
Right now we do this using
and then loop over what we have to insert and do
Which results in something like
But the system underneath which executes the individual statements cannot guarantee the order of queued individual statements.
So my idea is to queue one operation which contains the combined individual statements statements.
Is there any support or recommended way to do this?
The text was updated successfully, but these errors were encountered: