I need to be able to audit changes made on a form. Changes to each field must be reflected in the audit trail. Rather than writing a seperate SP for each of the 30+ fields, I would like to know if the Update statement could be written dynamically by passing parameters to a stored procedure.
Through ASP, I can use the request.form to identify a field name and the new value, as well as the record ID and UserID.
I would like to write a SP that will take these four pieces of information and use them as parameters as follows:
1. Begin a transaction
2. Write an entry to the audit table with the UserID, FieldName, CurrentValue(from DB), New Value (from form)
3. Write an Update to the record (as identified by the record id) on the selected field with the new value.
4. Commit the transaction
Through ASP, I can use the request.form to identify a field name and the new value, as well as the record ID and UserID.
I would like to write a SP that will take these four pieces of information and use them as parameters as follows:
1. Begin a transaction
2. Write an entry to the audit table with the UserID, FieldName, CurrentValue(from DB), New Value (from form)
3. Write an Update to the record (as identified by the record id) on the selected field with the new value.
4. Commit the transaction