Update trigger object (datetime stamping records)
Posted in 2000
Topics: Triggers, Constraints & Referential Integrity
It seems to be impossible to update the trigger object using Version 7 SE. I understand the desire to avoid infinitely nested firings of the update trigger - but isn't there a way to work around this? We want to stamp the server time and user on each record posted. I can avoid the recurrence problem by using the WHEN condition and not doing the update if the time stamp is within a second of the CURRENT datetime. Has anybody done this? Thanks in advance, Ralph
Ralph Hardy wrote: > It seems to be impossible to update the trigger object using Version 7 SE. > > I understand the desire to avoid infinitely nested firings of the update > trigger - but isn't there a way to work around this? > > We want to stamp the server time and user on each record posted. I can avoid > the recurrence problem by using the WHEN condition and not doing the update > if the time stamp is within a second of the CURRENT datetime. > > Has anybody done this? I've not tested SE versus OnLine (IDS, whatever), but in OnLine, you can update the columns of a row if the user has not also done so. So, if the UPDATE statement does not set the update time and user, you can have your trigger set them. I've used this in the past with success; I've not formally verified that I can still do it several years and versions later. I'm also not sure whether any of the most recent servers have relaxed the constraint that the user must not have set the value. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v1.00.PC1 -- see http://www.perl.com/CPAN #include <disclaimer.h>