'How does the triggers fires in sql?
If I have a trigger like the following one:
CREATE TRIGGER T
AFTER UPDATE ON SERVER
FOR EACH ROW
WHEN condition
BEGIN
INSERT INTO tab1 ... VALUES (...)
UPDATE SERVER SET freememory = freememory + 2
DELETE tab2 WHERE ID = 2
END;
How does the triggers are fired? I mean, once the second query (UPDATE SERVER ...) is executed I should re-call the execution of the same trigger. It isn't clear to me if before re-executing the trigger I execute the DELETE tab2 (and so I wait the end of my actual trigger), or if the trigger is re-executed right after the update query and so all the delete are postponed. I am considering a general SQL language, not related to a specific vendor.
Thank you
Solution 1:[1]
The triggers are activated when asked: some before and some after. If we create a trigger that activates after an update then the trigger will activate itself
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | x300 |
