Subject Re: [Firebird-Architect] Re: NOT UPDATABLE fields
Author Ann W. Harrison
Roman Rokytskyy wrote:
>
>
> I think we can solve this problem easier if we extend our mechanism of
> trigger to accept <search condition> as part of the condition that
> fires the trigger (currently it contains only {BEFORE | AFTER} {INSERT
> | UPDATE | DELETE}, but if I'm not mistaken, SQL standard allows also
> WHEN <search condition> and REFERENCING old AS <local var name>
> clauses to trigger definition).

Unh, maybe I'm just having a really bad, day, but I don't see what we
get for extending the trigger syntax that we don't have already.
>
> So the trigger can look like this:
>
> CREATE TRIGGER bla ON myTable AFTER UPDATE
> WHEN
> old.protectedCol1 IS DISTINCT FROM new.protectedCol1
> OR
> old.protectedCol2 IS DISTINCT FROM new.protectedCol2
> AS BEGIN
> RAISE myException;
> END


CREATE TRIGGER blah ON mytable AFTER UPDATE
AS BEGIN
IF ((old.protectedCol1 IS DISTINCT FROM new.protectedCol1)
OR (old.protectedCol2 IS DISTINCT FROM new.protectedCol2))
THEN RAISE myException;
END


Regards,


Ann