Subject | Re: Recursive trigger |
---|---|
Author | colinriley666 |
Post date | 2004-01-16T15:54Z |
Sorry, that was a typo. I'm using an increment of 1.
regards, Colin
--- In firebird-support@yahoogroups.com, "Muthu Annamalai"
<pearlamerica@h...> wrote:
regards, Colin
--- In firebird-support@yahoogroups.com, "Muthu Annamalai"
<pearlamerica@h...> wrote:
> Hi,value of 'table1_gen'
>
> In your table you are using generator with a increment value zero.
>
> So the value will be same for all inserts, that is whatever the
>very
> It should be 1 or any number that is not zero.
>
> try this, gen_id(table1_gen, 1)
>
> Muthu Annamalai
>
>
> ----- Original Message -----
> From: colinriley666
> To: firebird-support@yahoogroups.com
> Sent: Friday, January 16, 2004 7:16 AM
> Subject: [firebird-support] Recursive trigger
>
>
> 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)
>
> 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
>
>
>
> [Non-text portions of this message have been removed]