Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2015-08

Lookup fields in databases

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marc Santhoff

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?

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

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

TIA,
Marc

Marc Santhoff
Michael Van Canneyt
to Marc Santhoff
Marc Santhoff wrote 10 lines
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?

Yes.
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.

Michael.