I am developing an auditing scenario and what I envisioned was creating an audit trail table that would track any changes that were made to specific fields in a table that is in our production database by use of triggers. I thought it would be cool to assign an audit id to this audit so that I could add more audits later should other users want to track changes in other tables. In the actual table that tracks the changes I want to have the old_value, new_value, etc. My problem is that since I want to make this generic the old_value and new value could either be int, float, varchar, etc fields.
I guess what I could do is create multiple fields, one called old_value_int, new_value_int, old_value_float, new_value_float, old_value_varchar, new_value_varchar. Then I could also create a field (let's call it fieldtype) that would identify the data type so that when I report off of this table if the fieldtype is integer I would write out the old_value_int and new_value_int.
Then I started thinking that it would be great if there was say a generic data type that I could write all of the old and new value fields to and just convert everything to character strings in the report. Any suggestions?
I guess what I could do is create multiple fields, one called old_value_int, new_value_int, old_value_float, new_value_float, old_value_varchar, new_value_varchar. Then I could also create a field (let's call it fieldtype) that would identify the data type so that when I report off of this table if the fieldtype is integer I would write out the old_value_int and new_value_int.
Then I started thinking that it would be great if there was say a generic data type that I could write all of the old and new value fields to and just convert everything to character strings in the report. Any suggestions?