Re: Column manipulation with triggers
Posted in 1998
In article <6vas1b$drk$1@News.Dal.Ca>,
garagan@cs.dal.ca (Sean Garagan) wrote:
> Good day,
Hello,
>
> I am trying to write a trigger that updates a column by subtracting the
> values of the old and new tables. I cannot find a way to get the subtract
> operator to act on the column values unfortunately. It looks something like
> the following:
>
> create trigger audit_table_trig> update of B on table
> referencing old as pre
> new as post
> for each row(
> insert into audit_table
> values ( post.B,
> post.B - pre.B ));>
I think the problem is an expression in values ( ) part of insert.
Of course you can save just post.B and pre.B and calculate differense
later.
Or if trigger-based calculation is just necessary, I will suggest
to create audit_table with one more column to save post.B, pre.B
and column for difference and create trigger 'insert on audit_table'
to update difference column of inserted row.
It will work if you will use in your trigger
insert into audit_table (col1, col2)
values ( post.B,
pre.B ));
to resolve trigger reentrancy problem.
> I have done something along these lines in Oracle, which allows you to use
> PL/SQL in a trigger statement, but it doesn't seem to work this way with
> Informix.
>
> Any help will be appreciated,
> Sean
>
HTH
--
Vardan Aroustamian
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own