Subject Re: [firebird-support] Tracking changes to records / triggers
Author Thomas Steinmaurer
> We have some update triggers that we use to track if any change has
> occurred to a record in a table. These are sometimes used to transfer
> information to web sites (for example) only when data has changed.
> Sometimes however we recalculate values in records based on changes in
> other tables. When we do this the values do not often change but our
> trigger counts that as a change and 'marks' the record as updated. To
> avoid this we could change our trigger to compare the Old and New field
> values. This however has a large ongoing maintenance cost, if we change
> a record (adding or deleting) a field we would need to also remember to
> change the associated trigger (s).
> Is it possible to write a trigger like....
> Changed := False;
> Counter := 0;
> while (counter < Record.FieldCount) and (Changed = False) do begin
> if (old.Fields[Counter] <> new.Fields[Counter]) then begin
> Changed := True;
> end;
> end;
> If (Changed = True) then begin
> //Marke record as changed
> end
> A trigger such as the above would deal with any record structure
> changes. Is it possible? Would it be a major performance hit?

Such a generic approach isn't possible in a trigger.

> Do I have any other options?


The 50% discount is still available, so a VERY good deal. ;-)

Best Regards,
Thomas Steinmaurer
LogManager Series - Logging/Auditing Suites supporting
InterBase, Firebird, Advantage Database, MS SQL Server and
NexusDB V2
Upscene Productions
My blog: