Subject Re: [Firebird-Architect] old is distinct from new
Author Alex Peshkov
On Friday 09 January 2009 21:59, Adriano dos Santos Fernandes wrote:
> Milan Babuskov wrote:
> > Hi,
> >
> > I'm not sure if ideas for potential new features should do to -devel or
> > -architect, so I hope you don't mind me posting here.
> >
> > Few times in past recent days I had a need to check in some UPDATE
> > trigger whether any of the columns was changed and then do some action.
> > I ended up creating a trigger which looks like:
> >
> > if (old.field1 is distinct from new.field1 or
> > old.field2 is distinct from new.field2 or
> > old.field3 is distinct from new.field3 or
> > ...etc...
> > then
> > do_something;
> >
> >
> > It looks pretty ugly for this particular table because it has 30+ fields.
> >
> > Now, I wonder if there is anything in SQL that would enable such
> > triggers to be written like this:
> >
> > if (old is distinct from new) then do_something;

Addition of non-required clause except

if (old is distinct from new except field5, field8, field123)
then do_something;

can be even more useful (i.e. compare all fields except listed). Though this
looks like really new feature, not depending from ROW datatype.

> >
> >
> > If there is and it's easy to implement, I'd add it to the tracker. If
> > not, forget it.
>
> I think this is implicit on ROW types (already on the tracker). Once ROW
> types exists, OLD and NEW are of this type and IS DISTINCT should
> compare the elements.
>
>
> Adriano