Subject Re: [firebird-support] Re: Computed Column
Author Werner F. Bruhin
Hi Martijn,

Please keep in mind that I am not a techie.

What is the correct (if there is such a thing) way to define my columns?

Or put another way, is there anything which might bite me later on if I
define default of Zero for the base columns (F1 and F2 in this case)?
Especially as I can't think of a case where I care to know that the
columns are not initialized/set (i.e. Null).

See you
Werner

Martijn Tonies wrote:

> Hi Werner,
>
>
>>>>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).
>>>
>>>What do you mean with "does not compute"? A COMPUTED BY
>>>expressesion is evaluated on every row retrieval, it ALWAYS computes.
>>
>>Do the following you will see:
>>
>>Create a table as:
>>CREATE TABLE "computedby" (
>> F1 INTEGER,
>> F2 INTEGER,
>> F3 COMPUTED BY (F1-F2)
>>);
>>
>>INSERT INTO "computedby" (F1, F2) VALUES (2, 1);
>>
>>F3 will compute with result of 2 - 1 = 1
>>
>>INSERT INTO "computedby" (F1) VALUES (1);
>>
>>F3 will NOT compute!
>
>
> Sorry to dissapoint you, but F3 computes just fine!
>
> Try this:
>
> select cast(NULL as integer)- 4
> from rdb$database
>
> As you can see, and "kind of" figured out, if one of the
> columns is NULL, the result will be NULL. However,
> it does compute - but you just don't like the result.
>
>
> With regards,
>
> Martijn Tonies
> Database Workbench - the developer tool for InterBase & Firebird
> Upscene Productions
> http://www.upscene.com
>
>
>
> To unsubscribe from this group, send an email to:
> firebird-support-unsubscribe@yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>