Subject | Re: [firebird-support] Maintain values syncronized between two tables. |
---|---|
Author | Werner F. Bruhin |
Post date | 2008-09-11T13:08:39Z |
Fabio,
Fabio Gomes wrote:
A subset of the detail rows add into mastertable.value1, another subset
to mastertable.value2 and the rest to mastertable.value3, correct?
So, why could you not have a trigger after insert/delete/update on the
detail table which updates the appropriate value field in the master table?
Werner
Fabio Gomes wrote:
> Yes, I know about subqueries, but I want to avoid using it, otherwise I'dI am not sure I get your problem.
> have to add the subquerie in every select from the master table, and I don't
> like views also.
> Is there some other way?
>
> On Thu, Sep 11, 2008 at 10:15 AM, Alan McDonald <alan@...> wrote:
>
>> > Hi,
>>> We have a master-detail table which has 3 value fields and a total
>>> which is
>>> calculated by the sum of these 3 fields. I'll just call them value1,
>>> value2
>>> and value3 and total.
>>>
>>> Then we have another value field in the detail table, so basically the
>>> structure is:
>>>
>>>
>>> Master Table:
>>> Value1
>>> Value2
>>> Value3
>>> Total (calculated by value1 + value2 + value3
>>>
>>> Detail Table:
>>> Value
>>>
>>> The problem is that the Total must always match the sum of the values
>>> in the
>>> Detail table.
A subset of the detail rows add into mastertable.value1, another subset
to mastertable.value2 and the rest to mastertable.value3, correct?
So, why could you not have a trigger after insert/delete/update on the
detail table which updates the appropriate value field in the master table?
Werner