Subject | RE: [firebird-support] Prevent direct update from view |
---|---|
Author | Kevin Day Programming |
Post date | 2005-06-07T01:58:25Z |
> Lets say I have view V1(RowX) (select RowX from TableX);Interesting question.
> 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)
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.
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.
If that becomes impractical or creates a performance problem or unless
someone else has a better solution, perhaps you could use a stored procedure
to do the updating, inserting and deleting instead of using an update
statement on the view. This can be done easily enough depending what
components and development system you are using. With my experience with
Delphi, IBO and FIB Plus you can change the SQL that used for update, insert
and delete.
regards,
Kevin.