views:

33

answers:

1

Our product ecosystem: Web/Enterprise Application using EJB in Glassfish V3 and PostgreSQL 8.4.

How to detect which field was changed without using dirty flags or re-reading the same record(s) before updating it ? Why: For audit purpose/logging

Any recipes or ideas ?

Thanks Sven

+1  A: 

In PostgreSQL, write trigger on UPDATE that compares values in NEW and OLD, and reports somehow what has changed.

depesz
not sure how to return the result into the application layer where the logging is done.
devdude
If you're doing logging in application, make the comparison also in application. Or just do the audit logging in database - it's simpler.
depesz