Re: After Insert Trigger
Posted in 1998
Jon Brown wrote:
>
> Can anyone offer advice?
>
> We are developing a large client server system with an Informix back end.
> Each of the tables in the database has a lastupdated and bywhom field which
> we had invisioned setting by use of an 'after Insert/Update' Trigger.
> (i.e.)
> CREATE TRIGGER post_insert> INSERT ON tablename
> REFERENCING NEW AS NEW_INS
> FOR EACH ROW ( NEW_INS.lastupdated = CURRENT;
> NEW_INS.bywhom = USER);
>
> It would appear that it is impossible to update an informix table with a
> trigger that is on the same table
> Is this the case or are we just being stupid?
You can instead alter to table to include DEFAULT clauses for each of
these columns:
alter table tablename modify (lastupdated datetime year to fraction(2)default CURRENT), modify (bywhom char(8) default USER);
That will take care of your requirement.
Art S. Kagel