I'm afraid you can't solve all that dynamically. If course, if you'd do it, it would probably perform not too good.
Do your tables definitions change that often? You could just generate the static trigger code from the information schema. In that case, you just have to make sure to generate the trigger anew once you create or alter the table, but that can usually be managed.
Bear in mind that you would already have to generate specific triggers even if you would use your dynamic solution (hence my tablename question), so why not do that properly, and put all the code there you need right away?
It's just a self plug, but it does show some things involved in generating triggers for such a purpose:
http://mysql.gilfster.com/page.php?parent_id=6&page_id=6.0.2
Edited 1 time(s). Last edit at 10/28/2005 04:35PM by Roland Bouman.