Subject | Re: Recursive trigger |
---|---|
Author | colinriley666 |
Post date | 2004-01-16T16:01:21Z |
Hi,
by "behaving strangely" I mean :
select * from storedProc1. result (2 rows) = 1 , 9
select * from storedProc1. result (2 rows) = 1 , 9
select * from storedProc1. result (2 rows) = 1 , 9
select * from view1. result immaterial (but correct)
select * from storedProc1. result = 0 , 9
Just these statements are executed. StoredProc1 does no updating,
but does select from view1. View1 uses the table with the trigger.
regards, Colin
--- In firebird-support@yahoogroups.com, "Bill Meaney"
<wameaney@t...> wrote:
by "behaving strangely" I mean :
select * from storedProc1. result (2 rows) = 1 , 9
select * from storedProc1. result (2 rows) = 1 , 9
select * from storedProc1. result (2 rows) = 1 , 9
select * from view1. result immaterial (but correct)
select * from storedProc1. result = 0 , 9
Just these statements are executed. StoredProc1 does no updating,
but does select from view1. View1 uses the table with the trigger.
regards, Colin
--- In firebird-support@yahoogroups.com, "Bill Meaney"
<wameaney@t...> wrote:
>very
> >I have a requirement to insert a record into a table from that
> >table's "before insert" trigger.
> >
> >The mechanism works, but thereafter my database starts behaving
> >strangely. (tried with FB 1.5 RC7 and RC8)
>
>
> Could you give us more details on "behaving very strangely"
>
>
> >
> >I have read somewhere that it is not recommended to perform any
> >action in a trigger that may cause the trigger to be re-invoked.
> >Does anybody have any ideas?
> >
> >regards, Colin
> >
> >a simplified example follows:
> >(and I really do have a strong argument to want to do this!)
> >
> >CREATE TABLE TABLE1 (
> > ID INTEGER,
> > PRODUCTCODE INTEGER,
> > VAL1 INTEGER,
> > VAL2 INTEGER
> >);
> >
> >
> >CREATE TRIGGER TABLE1_BI0 FOR TABLE1
> >ACTIVE BEFORE INSERT POSITION 0
> >AS
> >begin
> > /* when val1 and val2 both non-zero, rather write 2 records:
> > one with only val1, one with only val2
> > */
> > if ((new.val1 <> 0) and (new.val2 <>0)) then begin
> > insert into table1(id, productcode, val1, val2)
> > values (gen_id(table1_gen, 0),
> > new.code,
> > new.val1,
> > 0);
> > new.val1 = 0;
> > end;
> >end
> >
> >
> >
>
> Bill Meaney
> wameaney@t...