MySQL How to SELECT…FOR UPDATE within a tigger

I’m creating a trigger after update on table 1. This trigger should update a second table but I need to "SELECT...FOR UPDATE" in order to avoid problem in concurrency. When you use "SELECT...FOR UPDATE" you should START TRANSACTION; and then COMMIT; but this is not allowed in triggers. Same story if you do that in a stored function that you call from the trigger, you receive error:”Error Code: 1422. Explicit or implicit commit is not allowed in stored function or trigger“.

Are there any know solution for this type of issue?

Source: mysql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.