Re: Logging database changes
- From: scott.ballinger@xxxxxxxxx
- Date: Thu, 19 Feb 2009 20:53:44 -0800 (PST)
Hi Dawn,
I use a "changes" file with a nask key and fields containing record-
id, user, date, time, port, field.name, old.value, & new.value, all
updated from a trigger on the master file. Field.name, old.value and
new.value are multi-valued, old.value and new.value are oconv'd before
being loaded in the changes record.
I have a generic trigger subroutine that I clone & modify for each new
file I want to track changes for, and use standard names: e.g. for the
customers file the trigger bp is save.changes.customers, and the
"changes" file is named customers.changes. All the xxx.changes files
have the same dictionary structure.
(Note that on most of the systems I support I try to name files as a
plural noun, and the key is the singular noun, i.e. list customers
customer name addr city st zip, etc.)
The bp save.changes.xxx process uses dim() arrays and equate lists of
field.names and oconvs to manage which fields to log changes for. This
is the only real drawback, as those equate lists must be managed
manually and the save.changes.xxx program re-compiled when new fields
are added to a file, or when I want to change which fields are being
tracked, e.g. I don't usually track changes to fields that change
frequently, like customer balance, etc.
An index on the record-id (e.g. the customer number) allows pulling up
all changes for a customer record quickly. You can list them by date
or by-exp field.name using a standard executed "sort" statement.
I have a generic purge routine that prompts for the changes file-name,
and then prompts for either a date and/or a field.name to purge. In
general though, I try to keep many years of changes on file (sometimes
100's of millions of records).
In general this scheme is easy to implement, easy to use, and seems to
have minimal overhead. And being able to track all changes ever made
to a customer's address, or the commission rate, etc, has saved my
bacon many many times.
/Scott Ballinger
Pareto Corporation
Edmonds WA USA
206 713 6006
.
- References:
- Logging database changes
- From: dawn
- Logging database changes
- Prev by Date: Re: DEVCON2009 - save $300 before March 1, 2009
- Next by Date: free stuff
- Previous by thread: Re: Logging database changes
- Next by thread: Re: Logging database changes
- Index(es):
Relevant Pages
|