writing a generic row-level trigger function is not that easy