Subject | RE: [firebird-support] trigger problem |
---|---|
Author | Alan McDonald |
Post date | 2004-02-12T08:32:38Z |
> Iam having a problem where it seems that the trigger didn't fire, but asbut if left is NULL you will always get NULL as the answer.
> Helen says trigger always fire, it just depend on how we program it. Can
> you guys please take a look at my trigger and tell me how could be the
> problem that makes it unable to work properly?
>
> In the invoicedetails table I have this after insert trigger.
>
> update items
> set left = left + (new.qty*new.conversion)
> where id = new.itemid;
>
> I always have value for the itemid, qty, and conversion field. I don't
> know where to look that cause my problem.
>
> Thanks
>
> James
You need to use the COALESCE function
UPDATE ITEMS SET LEFT=COALESCE(LEFT,0)+(NEW.QTY*NEW.CONVERSION) WHERE
ID=NEW.ITEMID;
As you say the other values are also required to be NOT NULL for this to
work.
Alan