Subject Re: [ib-support] Re: BUG:"cannot update read-only view" with triggers!
Author Svein Erling Tysvaer
What if you simply change to

CREATE VIEW V_OBJECT_DOCUMENT(
OBJECT_ID,
DOCUMENT_ID)
AS
select Object_ID_Left+0, Object_ID_Right+0
from T_Object_Links
where T_object_links.Link_type_id = -5001
;

I don't quite understand what is the problem, so appologies in advance if
my suggestion is just wasting your time.

Set

- I support Firebird, I am a FirebirdSQL Foundation member.
- Join today at http://www.firebirdsql.org/ff/foundation

At 11:34 21.01.2003 +0000, you wrote:
> >the Firebird bug-tracker is NOT for your application bugs, it is for
> >bugs that have been identified in the database engine.
>
>Well, I should apologize again, now for posting my question around
>where it shouldn't be; I really believed this was engine bug, not
>application'.
>
> > Now, your problem becomes much clearer. The error is being raised because
> > your *view* contains a cross-join on rdb$database. By including
> > rdb$database in the *view specification*, you have made it so that, when
> > the engine goes to construct the output set, it looks at the view's delete
> > and insert triggers and the dependency of rdb$database upon the view,
> and
> > says "oh no, this view has the potential to add to or delete from
> > rdb$database. Not allowed."
>
>Join to rdb$database is really quite widespread trick that I met very
>often in various postings here and in "IB-Architect" too (discussion
>considering means of making view read-only, e.g. msg ID 3635); you
>can find it in FB Open Bug #523589 description and others, and,
>judging from that postings, it worked fine (at least, it did not
>throw "cannot update.." error).
>
> > Take the cross-join to rdb$database out of the view specification and,
> > instead, include it in your query specification. That should do the trick
> > to force the view to be read-only without affecting anything else.
> >
> > Also, I'm sure you need the means to parameterise the selection criterion
> > in this view. By forcing it to a constant in the view specification you
> > make this view fairly useless.
>
>I made this view to hide from application the means of storing many-
>to-many relationships and make it look like common separate "special"
>table, so that application doesn't need to know specific values
>of 'Link_type_id': that's why I didn't parametrize selection
>criterion.
>As for taking the cross-join to rdb$database out of the view
>specification and including it in my query specification - I just
>can't understand how it would work; how can _query_ specification
> make _view_ read-only? This may be my ignorance again, but I just
>can't comprehend it; read-only result set of a query (from
>application point of view) doesn't mean read-only view, so when I'll
>try to pass:
>
>insert into V_OBJECT_DOCUMENT
> (OBJECT_ID, DOCUMENT_ID)
>values
> (1111, 22222)
>
>it will throw error about Link_type_id NULL value, 'cause it still
>will be trying to perform default action along with the trigger (or,
>if I'll include Link_type_id in view specification, it will post the
>record twice).
>I really feel confused taking such a lot of your time, but I'm
>definitely not the first to encounter such problem, and I believe it
>to be serious enough, so it needs to be cleared out at last.
> lisov.