Subject Re: [ib-support] calculated fields in master-detail
Author Svein Erling Tysvaer
At 14:47 08.11.2002 +0100, you wrote:
>if I have two tables in master-detail relation, is it possible to have
>calculated fields in master-table with values from the detail-table, or must
>I define a seperate view (with a join) for this purpose?

Hi Ulrich,

it certainly is possible to use subqueries like

SELECT Master.Something, (select sum(SomeColumn) From Detail where
Detail.Somefield = Master.Somefield) as CalculatedField
FROM Master
WHERE...

but we all do this in our applications - not in the table definition
itself. I doubt it is possible to have calculated columns computed by
fields from another table (you can have calculated fields based on
constants and other values of the current record) - the closest you could
get would be adding a field to your master table and write triggers for
your detail table that updated the master. But I doubt this could be
considered good design.

So - rather than implementing something like this, I suggest you rethink
your design.

Set