Subject | Re: [firebird-support] Re: Computed Column |
---|---|
Author | Martijn Tonies |
Post date | 2003-08-25T13:58:03Z |
Hi Werner,
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
> > > Have a table with column quantityonhand which is computed.Sorry to dissapoint you, but F3 computes just fine!
> > >
> > > 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!
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