Re: Column manipulation with triggers
Posted in 1998
Sean Garagan wrote:
>
> Good day,
>
> 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 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.
Create a stored procedure to perform the calculation and insert and call
it from the trigger passing the old and new values that it needs along
with the other column values needed for the insert.
Art S. Kagel