Subject Re: [firebird-support] Computed Column
Author Helen Borrie
At 09:23 AM 25/08/2003 +0000, you wrote:
>Have a table with column quantityonhand which is computed.
>COMPUTED BY (quantitypurchased-quantityconsumed)
>Now the problem I have is that the column does NOT compute when I
>update one of the two columns (purchased or consumed).
>Both columns are defined as Int and the computed column is BigInt, and
>all have no default.
>When I update from a Python program with kinterbasdb the computed
>column is not updated.
>When I try to update from e.g. IBExpert I get an error that I am
>trying to update a read-only column.
>I just figured out how to make the Python program work, have to ensure
>that neither of the two base columns contain Null.
>Shouldn't Firebird (1.5RC2) be able to deal with this? Or am I
>doing/or not doing something?

The value of a computed column is not stored. It is computed for output
only, i.e. when the column is selected or referred to (e.g. via an
expression) in a SELECT statement.

If you want a column that *stores* a computed value, then a computed column
is not what you want. Declare a real column of the required type and
perform the calculation in insert and update triggers.