Subject Re: [ib-support] Possible Bug w/ After Delete triggers
Author Helen Borrie
Bug?

Why would one create an AFTER trigger on a table, that performs an update on itself? I guess the "bug" is that the engine actually PERMITS you to compile a such a trigger!

Or we could start collecting examples of triggers you can write that destroy data for a joke...

Helen

At 09:38 AM 12-05-01 +0000, you wrote:
>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
>
>
>To unsubscribe from this group, send an email to:
>ib-support-unsubscribe@egroups.com
>
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________