Subject Re: use a trigger to set a field to null
Author Adam
--- In firebird-support@yahoogroups.com, "martinknappe" <martin@...>
wrote:
>
> hi
>
> i have an (after-update) trigger which looks like the following:
>
> update dicentries
> set
> asdskrpt1 = new.asdskrpt1
> where
> asverwid = new.id;
>
> it works fine except under one condition:
>
> if
> asdskrpt1
> of
> new.id
> was just set to null,
> then
> asdskrpt1 where asverwid = new.id
> remains unchanged
>
> so i tried with the following modification of the trigger (which
> doesnt work either):
>
> update dicentries
> set
> asdskrpt1 = new.asdskrpt1
> where
> asverwid = new.id;


This is not valid. It looks like you forgot the 'update table' logic.

> if new.asdskrpt1 is null then
> set
> asdskrpt1 = null
> where
> asverwid = new.id;

I am not sure what would be wrong with the original statement. Perhaps
you could generate a simple SQL script to create the two tables and
the trigger, and then to populate it with a record and run an update
statement to show what you mean.

Adam