Re: Trigger Problem
Posted in 1998
Peter Lancashire wrote:
> Ileana Soler wrote:
> >
> > A table named "tab1" have the following structure:
> > create table tab1 (
> > a integer primary key constraint num,
> > b integer,
> > c integer)> > The field named "c" will have the result of a+b.
> > I want to fill "c" in a trigger on insert on "tab1", but I can't because
> > there are the following rule in Informix: "You cannot reference the
> > triggering table in any triggered SQL statement with some exceptions".
> > I can fill "c" in a trigger on update, but not on insert (error 747).
> > My question is: How can I fullfill calculated fields in tables in Informix
> > using triggers or stored procedures calling by triggers?
> An alternative would be a view:
>
> CREATE VIEW view1 (a, b, c) AS
> SELECT a, b, a + b FROM tab1;>
> Having column c in your base table means that your database is not in
> third normal form. Is that what you want?
Or, migrate to 7.3 - it supposedly removes the restriction that
insert triggers cannot modify the triggering table.
Roger Tomas
AG Communication Systems