Subject Re: [firebird-support] Prevent direct update from view
Author Dmitry Yemanov
"Kevin Day Programming" <kev.kdp@...> wrote:
>
> > Lets say I have view V1(RowX) (select RowX from TableX);
> > If I am updating RowX in view V1, it updates that row in table as well.
> > How can I prevent it ? (I need to fire my own trigger on view, but it
> > updates table, then fires triger)
>
> Interesting question.
>
> I haven't ever put triggers on views although I know you can. The ibv6
> manuals suggest it as a method of making a non-updatable view updatable.

It has been changed during the Borland era, but kept undocumented. A
natively updatable view (i.e. the one without distinct / aggregates / joins)
with triggers became a subject of the automatic direct underlying table
update performed by the engine. The original behaviour has been reverted
back in FB 2.0.

> I guess you have to make your view non-updatable to begin with so that the
> updating can be done with your triggers. Maybe you can put a join to
> another table or something like that. Views based on multiple tables are
> not updatable.

Correct. Generally, people work around this "feature" using a join with
RDB$DATABASE.


Dmitry