Subject Re: [IBO] Views
Author Luiz Alves
Sandeep,

There is a bug in interbase with before update triggers in views. See at
http://firebird.sourceforge.net/download/OpenBugsDetailed.PDF

Here is a extract:

<<Rows affected incorrect with trigger>>
Prority 5 - Medium (next major release)
I'm having troubles with updatable views that have before update triggers.
When i update just one record (using the PK),
it returns 3 rows affected.
When i update this view using IBO it gives the error: 'MULTIPLE ROWS
AFFECTED', because the number of rows affected is
giving 3 rows!
PS: I can't put the before update in the table, because i have several view
on one table and i expect that each view have
an specific behavior.
Try this:
/* CREATE A TABLE */
create table test (
test_id integer not null primary key,
name varchar(30),
address varchar(30) );
/* CREATE A VIEW */
create view v_test as
select test_id, name, address from test;
/* INSERT A RECORD */
insert into v_test values (1, 'name1', 'address1');
/* ROWS AFFECTED: 1 */
/* UPDATE THIS RECORD */
update v_test set name = 'name1' where test_id = 1;
/* ROWS AFFECTED: 1 */
/* CREATE A TRIGGER FOR THE VIEW */
set term !! ;
create trigger trg_v_test for v_test
before update
as
begin
new.name = 'name1';
end !!
set term ; !!
/* UPDATE THE RECORD AGAIN - SAME AS ABOVE*/
update v_test set name = 'name1' where test_id = 1;
/* ROWS AFFECTED: 3 !!!!!!!!!!!!!!!!!!!!!!! */


Luiz.

----- Original Message -----
From: "Sandeep" <sandeep@...>
To: <IBObjects@yahoogroups.com>
Sent: Monday, November 05, 2001 8:01 PM
Subject: Re: [IBO] Views


> On 5 Nov 2001, at 19:38, Luiz Alves wrote:
>
> > Does your view have triggers?
>
> Yes, One Before Insert and one Before Update.
>
> The one before insert generate a new number for underlying table
> (There is no trigger on the underlying table).
>
> The one Before update has one statement like
> new.fieldA = old.FieldA
> to ensure the value is not changed accidentally
>
> Sandeep
>
> Software Developer
> CFL
> sandeep@...
> http://www.cfl.co.nz
>