Solving the mutating table problem in Oracle SQL produces a deadlock

后端 未结 1 1802
旧时难觅i
旧时难觅i 2021-01-14 00:49

Hey, I\'m trying to create a trigger in my Oracle database that changes all other records except the one that has just been changed and launched the trigger to 0. Because I

相关标签:
1条回答
  • 2021-01-14 01:06

    Using an autonomous transaction for this sort of thing is almost certainly a mistake. What happens if the transaction that inserted the new thumbnail needs to rollback? You've already committed the change to the other rows in the table.

    If you want the data to be transactionally consistent, you would need multiple triggers and some way of storing state. The simplest option would be to create a package with a collection of thumbnail.url%type then create three triggers on the table. A before statement trigger would clear out the collection. A row-level trigger would insert the :new.url value into the collection. An after statement trigger would then read the values from the collection and call the check_thumbnail_set_others procedure (which would not be an autonomous transaction).

    0 讨论(0)
提交回复
热议问题