Subject Re: [firebird-support] Is possible to have a computed column using a column of another table?
Author Markus Ostenried
On Mon, Aug 1, 2011 at 02:39, W O <sistemas2000profesional@...> wrote:
> Hello everybody
> - I have a table called CAB
> - CAB has a primary key on column ID_CAB
> - I have a table called DET
> - DET has a foreign key to the column ID_CAB of CAB
> - Now, I want to have a computed column in DET, using a column of DET and a
> column of CAB, something as: TOTALX is CAB.COUNT * DET.PRICE
> - But I cannot do that, the message "column unknown" is showed.
> There is some way to do that?

Hi, try something like

alter table det
add totalx computed by ((
select c.count * det.price
from cab c
where c.id_cab = det.id_cab