Subject Re: [firebird-support] Re: altering triggers from sp
Author Lucas Franzen
Kaczy,

>
> I have a table of objects that is linked to itself via
> ID - primary key
> ID_parent - foreign key
> value - let say that it is integer
>
> the parent object contain the sum of all integers below (the tree is
> multilevel with varying depth from 1 to 10 levels)
>
> I built the trigger that make an update everytime (the update fire
> the same trigger at level higher). It has to be done that way
> because recalculation 'on fly' is not an option.
>
> The exact agregate operation may vary and could be quite complex,
> therefore I need it to execute the trigger once after a group of
> insert will be done instead of the current recalculation of all
> levels after every change.
>
> The whole thing should be multiuser safe - I believe commiting all
> changes in a single transaction should ensure that.

Deactivating a trigger is anything BUT multiuser safe.

If you use FB < 1.5 then you can just do this 127 times (deactivate and
re-activate) and then you've got to backup and restore the database.
(With FB 1.5 this action doesn't increment the metadata-change count for
the table anymore)

It's better if the trigger is deciding by a value from the table (or by
selecting a value from another table) if it has got to execute its code
or not.

And, maybe, it's a better option to do the calculation in a stroed proc,
not in a trigger.

My 2c.

Luc.