Here is my requirement,
I have a mysql table on which any change (insert/delete/update) should be handled in exactly same way. According to mysql documentation create trigger syntax is as follows:
CREATE
[DEFINER = { user | CURRENT_USER }]
TRIGGER trigger_name
trigger_time **trigger_event**
ON tbl_name FOR EACH ROW
trigger_body
When I'm trying to put more than one event, its throwing syntax error.
One solution is I can write one procedure and 3 triggers (one for each event) and call the same procedure from all the triggers.
Is there any sophisticated solution for this ??
解决方案
No. Only one "event" is supported. The trigger has to be either BEFORE or AFTER one of INSERT, UPDATE, DELETE.
If you have lots of logic that is "shared", you could write a procedure, and call the procedure from the body of the trigger.
The sophisticated solution to this is to use a different DBMS. Otherwise, you have to work within the confines of what MySQL supports.