[fpc-pascal] Lookup fields in databases

Michael Van Canneyt michael at freepascal.org
Sat Aug 29 09:11:41 CEST 2015

On Sat, 29 Aug 2015, Marc Santhoff wrote:

> Hi,
> peeking the database code I found that:
> - a TDataSet has FieldDefs
> - fields are described by TFieldDef(s)
> - TField has several special properties like "KeyFields" and
> "LookupDataset"
> How are these properties of TField (descendants) set and by whom?

In the IDE designer, by the programmer, or after opening the dataset in code.

> I can imagine the information to set the lookup dataset is stored inside
> the databases metadata using contraints (foreign key references ...).

No, it is not.

> Or are those props for wiring by the programmer manually at design time?

A relation (lookup) doesn't have to exist formally in the database to be used in the IDE.
Since a second dataset is needed, there is no way the code can know which dataset to use.

I do have a project where I have an IDE wizard that uses DB information to construct the 
necessary datasets and lookup fields.


More information about the fpc-pascal mailing list