Subject Re: [ib-support] Re: BUG:"cannot update read-only view" with triggers!
Author Steve Landrum
I don't see a before update trigger. Did you forget to include this or
could it be the problem. I think you must have all three triggers for
the view to be updatable.

lisovnew wrote:

>>When you create triggers on simple view and do not
>>want default action take place, you join base table
>>with rdb$database or something to make view read-only;
>>BUT - after some time DB is working I get the message:
>>"The object of the insert, update or delete statement
>>is a view for which requested operation is not
>>permitted. cannot update read-only view '...'"
>>I get this error when I try to SELECT, not only
>>insert/update/delete from v_object_document or any
>>other view dependent on it;
>>
>>
>/* Table: T_OBJECT_LINKS */
>CREATE TABLE T_OBJECT_LINKS (
> LINK_TYPE_ID integer NOT NULL,
> OBJECT_ID_LEFT integer NOT NULL,
> OBJECT_ID_RIGHT integer NOT NULL);
>/* Indices definition */
>CREATE UNIQUE INDEX AK_OBJECT_LINKS ON T_OBJECT_LINKS
>(LINK_TYPE_ID, OBJECT_ID_LEFT, OBJECT_ID_RIGHT);
>
>/* View: V_OBJECT_DOCUMENT */
>CREATE VIEW V_OBJECT_DOCUMENT(
> OBJECT_ID,
> DOCUMENT_ID)
>AS
>select Object_ID_Left, Object_ID_Right
>from T_Object_Links, rdb$database
>where T_object_links.Link_type_id = -5001
>;
>
>SET TERM ^ ;
>
>/* Triggers definition */
>/* Trigger: TBD_V_OBJECT_DOCUMENT */
>CREATE TRIGGER TBD_V_OBJECT_DOCUMENT FOR
>V_OBJECT_DOCUMENT
>ACTIVE BEFORE DELETE POSITION 0
>as
>begin
> /* delete from t object links */
> delete from T_Object_Links
> where T_object_links.Link_type_id = -5001
> and T_object_links.Object_id_left = old.Object_id
> and T_object_links.Object_id_right =
>old.Document_id;
>end
>^
>
>/* Trigger: TBI_V_OBJECT_DOCUMENT */
>CREATE TRIGGER TBI_V_OBJECT_DOCUMENT FOR
>V_OBJECT_DOCUMENT
>ACTIVE BEFORE INSERT POSITION 0
>as
>begin
>end
> /* insert into t object links */
> if (not (EXISTS (
> select * from T_object_links
> where T_object_links.Link_type_id = -5001
> and T_object_links.Object_id_left =
>new.Object_id
> and T_object_links.Object_id_right =
>new.Document_id
> ))) then
> begin
> insert into T_Object_Links
> (Link_Type_ID, Object_ID_left, Object_ID_Right)
> values
> (-5001, new.Object_id, new.Document_id);
> end
>end^
>-----
>error is caused even by a simple select:
> select * from V_object_document
>executed from IBconsole or any other 3rd party query tool.
>
>Hope this time I was not too short and expansive:)
> Regards, lisov.
>
>
>
>