Subject | Possible Bug w/ After Delete triggers |
---|---|
Author | Béru |
Post date | 2001-05-12T09:38:43Z |
Hi,
Christophe Cerbourg has reported the following behavior on the
nzn.fr.interbase newsgroup... I thought it could interest some people
here !
create table MaTable (Champ1 integer not null, Champ2 integer not
null)!
create trigger MaTable_AfterDelete for MaTable after delete position
1 as
begin
update MaTable set Champ2 = Champ2 - 1 where Champ1 = Old.Champ1 and
Champ2 > Old.Champ2;
end!
commit
insert into MaTable values (1, 1)!
insert into MaTable values (1, 2)!
insert into MaTable values (1, 3)!
insert into MaTable values (1, 4)!
insert into MaTable values (1, 5)!
Now try to do:
delete from MaTable where Champ1=1 and Champ2=1
The table is empty after this !
Now:
create index monindex on matable(champ1, champ2)
commit
insert into MaTable values (1, 1)
insert into MaTable values (1, 2)
insert into MaTable values (1, 3)
insert into MaTable values (1, 4)
insert into MaTable values (1, 5)
delete from MaTable where Champ1=1 and Champ2=1
after this the table contents will be
1 1
1 2
1 3
1 4
(which is what Christophe expected)
Tested on IB5.6 and IB6.01
Any comments ?
Berenger Enselme
Christophe Cerbourg has reported the following behavior on the
nzn.fr.interbase newsgroup... I thought it could interest some people
here !
create table MaTable (Champ1 integer not null, Champ2 integer not
null)!
create trigger MaTable_AfterDelete for MaTable after delete position
1 as
begin
update MaTable set Champ2 = Champ2 - 1 where Champ1 = Old.Champ1 and
Champ2 > Old.Champ2;
end!
commit
insert into MaTable values (1, 1)!
insert into MaTable values (1, 2)!
insert into MaTable values (1, 3)!
insert into MaTable values (1, 4)!
insert into MaTable values (1, 5)!
Now try to do:
delete from MaTable where Champ1=1 and Champ2=1
The table is empty after this !
Now:
create index monindex on matable(champ1, champ2)
commit
insert into MaTable values (1, 1)
insert into MaTable values (1, 2)
insert into MaTable values (1, 3)
insert into MaTable values (1, 4)
insert into MaTable values (1, 5)
delete from MaTable where Champ1=1 and Champ2=1
after this the table contents will be
1 1
1 2
1 3
1 4
(which is what Christophe expected)
Tested on IB5.6 and IB6.01
Any comments ?
Berenger Enselme