Subject Re: [IBO] Calculated fields vs Computed By fields
Author Helen Borrie
At 06:27 AM 02-02-01 +0000, you wrote:
>I am used to using Calculated fields with TTables. This worked fine
>with Paradox but obviously isn't the best way to use IB. I am now
>converting any Calculated fields to Computed By fields. However the
>problem is that computed by fields are only computed when the table
>is refreshed.
>
>Is there a more efficient way of forcing Computed By fields to
>display other than issuing a Refresh? Or is there a better solution?

Well, you have to understand that in a client/server database, the Computed
By column is computed from the value stored in its definition. What is
wrong with a refresh? It's the way to do it with C/s.

If you're using TIBOQuery, you can still create a calculated field...



>In addition, what is the best way to create a 'lookup' field. ie a
>computed by field that gets its value from another table?

Use a subselect in your query, viz.

select OrderID, CustomerID,
(select FirstName||' '||LastName from Customer where
Order.CustomerID=Customer.CustomerID) AS CustomerName,
Field3,
Field4
from Order

Note that you will get an error if your subselect is capable (through
inter-table dependencies) of returning more than one row. And, once again,
you won't get the subselect field populated until you do a refresh.

btw, this is only part of the story with native IBO lookups. If you have
the Getting Started Guide, read up the sections on Keysource-Lookup
relationships and TIB_LookupCombo.

Helen



Helen

All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________