Subject Re: [firebird-support] Match two fields in same table using a trigger
Author PenWin
Dne 11.3.2011 8:51, thedevguy napsal(a):
> Is there a way to sync two columns in the same table using a trigger. For example I have field1 and field2. On an insert or an update I would like field2 = field1 if they are different.
> I tried something like the following but it doesn't work.
> if (new.field1<> old.field2) then
> new.field2 = new.field1;
> Any help would be greatly appreciated.

This kind of triggers works fine for me. I am pretty sure your
particular implementation has some bugs, e.g. one of the fields contains
a NULL value and the usual "comparison of anything to null is almost
always false" GOTCHA kicks in.