Subject Re: [firebird-support] Trigger not firing when supposed too
Author Martijn Tonies
Hi Uwe,


> I have a problem when inserting records as my trigger that is supposed to
> insert a value for the primary from a generator. The Trigger looks as
> follows. :
>
> CREATE GENERATOR GenDescription ;
> SET GENERATOR GenDescription TO 1 ;
>
> SET TERM !! ;
>
> CREATE TRIGGER TrigGenDescription FOR Description
> ACTIVE BEFORE INSERT POSITION 0
> AS
> BEGIN
> IF (NEW.DescrIDSQ IS NULL) THEN
> NEW.DescrIDSQ = GEN_ID(GenDescription,1) ;
> END !!
>

I usually write these as:

IF ( (NEW.DescrIDSQ = 0) or (NEW.DescrIDSQ IS NULL) )

in order to avoid problems with component sets that push a 0 to
the server.

If the trigger is active, it should fire just fine.


With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird & MS SQL Server.
Upscene Productions
http://www.upscene.com