Subject | RE: [firebird-support] how to delayed update in trigger |
---|---|
Author | Alan McDonald |
Post date | 2009-12-23T11:39:10Z |
> hello,Many ways to do this 2 are:
>
> we have 2 tables
>
> invoice
> items
>
> in invoice we have a field Amount. we update this field by the help of
> a triger, everytime an items is add, delete or updated.
>
> the problem is that, if i create an invoice with 10 items, i will 10
> times update the field amount in the invoice ! this what i don't want,
> i want to update the invoice amount only at the end when all the items
> are inserted.
>
> so is it possible to "delayed the update of the amount" to not update
> it for every insert ?
>
> for exemple a trigger "before commit" will be a perfect solution for me
> (with the help of temp table)
>
> or any other suggestion ?
>
> thanks you by advance
> stephane
>
1. I never put the invoice total in. I always retotal the items.
2. You are in control of the COMMIT command. Why don't you call an SP to
total just before the commit. (instead of triggers)
Alan