Re: Trigger for update of all columns of table
Posted in 1995
: > I have a field (in_lupdt) in a table(itemmain) that I've recently : > added to hold the date that the row was last updated. I made the : > following trigger to do this so that I wouldn't have to change all : > the programs that update this table. : > ... : Trigger language simply won't allow you to make any changes to the table : that caused the trigger to fire. Not precisely true (your assumption later in your mail is correct). Pete's approach was correct; an Update trigger that specfies columns can update other columns in the same row. I suspect the problem comes from the "*" syntax he wants to avoid changing in the 4GL code. Given the restriction that we don't want to modify the source code to take care of the new column, my approach would be to not put a new column into the existing table, but to create a new table with the PK of the existing table and the date column we want (a one-to-one relationship table). It would be a fairly simple task to create an update trigger that calls a SPL to either insert a new row into the new table for a row that doesn't yet exist or update the row in the 2nd table with the new date for the existing row. Taking it further, you could have an insert trigger with tracks when each row in the 1st table was created (another date column in the 2nd table), then the update trigger becomes trivial, since the row is always there. ======================================================================= Dennis J. Pimple dennisp@informix.com Opinions expressed Senior Consultant -------------------- are mine, and do not Informix Software Inc Voice: 303-850-0210 necessarily reflect Denver Colorado USA Fax: 303-779-4025 those of my employer.