Subject Re: BUG:"cannot update read-only view" with triggers!
Author lisovnew <lisovnew@yahoo.com>
>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;

>>So give us some information and let's try to get it sorted. As a
>>minimum:
>>:: The exact DDL for the tables upon which the view is based, and
>>any indexes
>>and table triggers
>>:: The DDL for the view specification and any view triggers
>>:: The SQL for the query specification, exactly as it is when it
>>crosses
>>the API
>>:: The parameter values that cause the error message
>>:: The client environment in which the error occurs

Sorry for not giving enough detail from the very start - it was
ignorant of me not to follow usual style of such reports.
I've encountered this problem in IB 6.0.1.6 (mers build), 6.5
(Borland eval), FB 1.0.2.908 - all with the same results. DB itself
was created with IB 5.6, then migrated to IB 6.0.1.6 half-year ago,
and it worked fine until last month, when I started to get this error
more and more frequently and decided to move to FB (after trying out
IB 6.5).
I use Windows 2000 Pro.
so here's script:

/* 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.