Subject Re: [IBO] Displaying COMPUTED fields as a previous field isentered for the first time.
Author Raymond Kennington
Helen Borrie wrote:
> At 10:39 PM 7/04/2003 +0930, you wrote:
> >Consider a table that has several fields followed by a COMPUTED field.
> >
> >1. With a new record all fields that don't have defaults are NULL.
> >(a) What do COMPUTED fields display in grids and IB_Edits?
> The computed value that is output by the query.
> >(b) Are COMPUTED fields automatically updated in the grid and IB_Edits?
> Only when you refresh the dataset - because they are *output* values.

Will this work when in Insert mode and the user leaves the field that the COMPUTED field uses and
before all fields are entered and before posting the record?

Will displaying a COMPUTED field that is defined like:

((SELECT Paddock
FROM Paddock JOIN Animal
ON (Paddock.ID = Animal."Paddock ID")
WHERE Animal.ID = "Animal ID"

will IBO (or Firebird) generate an exception because "Animal ID" is NULL when the dataset goes into
Insert mode?
> >2. Editing an existing record:
> >(a) Are COMPUTED fields automatically updated as the fields they depend on
> >are changed by the user?
> As above.
> Also, to avoid exceptions, you should set the COMPUTED attribute of the
> column in the dataset editor. This tells IBO not to try to update it.

Thanks for the extra info. Prevents me having to ask about it later, hopefully.

> Delphi will let the user enter things into a VCL control that contains a
> computed column, but it may cause an exception when the control updates the
> dataset. You should avoid confusing the users by making the control
> read-only. I always set a special colour (text, background or both) for
> read-only controls or grid columns.

Me too. I use a bright yellow background.

Raymond Kennington
Programming Solutions
TeamW2W (InfoPower)