Log In    |    Knowledge Base    |    4D Home
Tech Note: Transparent Audit Trails
PRODUCT: 4D | VERSION: 6.0.x | PLATFORM: Mac & Win
Published On: July 1, 1998

This Technical Note describes a transparent way of tracking changes in a 4D V6 database. The code to implement this tracking is provided in the accompanying structure file.

‘Transparent’ means that you can add this change-tracking capability to an existing database with trivial changes to existing code. Once you have incorporated the table and methods from the enclosed structure, and added the two lines to the triggers for tables, you can use the simple methods provided to extract earlier versions of any field or record that has been changed in the

V6’s triggers and BLOBs make this archiving simple and flexible. Whenever a new or existing record is saved, a copy of the record is saved in a BLOB in an [Archive] table. By employing BLOBs to keep the contents of whatever fields are in the source table, and by employing the 4D V6
commands that allow a method to learn details of the fields in a table, we can attach information to the records containing the BLOBbed version of a record. This information allows us to locate that record again. The methods time- and date-stamp changes, and will transparently decompress the BLOBs if they are ever compressed.

The only type of field that can’t be backed up by the methods in this Technical Note is a subtable.
It would be possible to do this also, but it would substantially increase the complexity of the
methods used. Much of the value of this Technical Note is its simplicity, which means that its behavior can be modified very easily.

This Technical Note presents the central techniques involved, and then discusses some simple variants, construct to do such things as compress the BLOBs and to track who made changes to the database.

Tech Note