> Auditing values as JSON
For PostgreSQL 9.2, or 9.1 with the fantastic json_91 addon, you can log the old and new values in the table as structured json instead of flat text, giving you much more power to query your audit history. Just change the types of v_old_data, v_new_data, original_data and new_data from TEXT to json, then replace ROW(OLD.*) and ROW(NEW.*) with row_to_json(OLD) and row_to_json(NEW) respectively.