TOracleDataset composite look up key fields

Does this work with other datasets? It seems that the lookup field tries to determine the value of the KeyFields as if it just one field. I think this is all handled at the TDataSet and TField level (DB.pas), so I wonder how this works with other TDataSet descendants.

------------------
Marco Kalter
Allround Automations
 
Hi,

The Delphi Help topic "Defining Look Up Fields" has this step for the KeyFields property:

6. Choose from the Key Fields drop-down list a field in the current dataset for which to match values. To match more than one field, enter field names directly instead of choosing from the drop-down list. Separate multiple field names with semicolons.

So I do this but it does not work. In TTable it works, and this is a TDataSet descendant.

I wonder if any other developers ever tried to do a look up with a composite primary key. Did it work for you?

Please check this out? I can't imagine that lookup's cannot be done when the primary key is a composite one.

Originally posted by mkalter:
Does this work with other datasets? It seems that the lookup field tries to determine the value of the KeyFields as if it just one field. I think this is all handled at the TDataSet and TField level (DB.pas), so I wonder how this works with other TDataSet descendants.
 
Did I write KeyFields? I meant to write LookupKeyFields
wink.gif
. A composite primary key is no problem, a composite lookup value just might be.

------------------
Marco Kalter
Allround Automations
 
A composite primary key is no problem, a composite lookup value just might be.

But... how can you have a composite KeyFields without having the same LookUpKeyFields. If I have a table that has a foreign key to a lookup table with a composite primary key (ex. ID1 and ID2), then I need to set up the KeyFields as 'ID1;ID2' and the LookupKeyFields as 'ID1;ID2'... isn't this the case? If it is, this doesn't work with TOracleDataset. If you agree on this (i.e. that it doesn't work) then please tell me, so I can stop using composite keys and convert all the primary keys to single column ones.

Thank you

[This message has been edited by amiridis (edited 08 February 2001).]
 
I tried this, and the lookup feature seems to work okay. As soon as I use the lookup as a combobox in a dbgrid, the error you mentioned occurs. I traced this down to dbgrids.pas where it says:
Code:
if FieldKind = fkLookup then
begin
  MasterField := Dataset.FieldByName(KeyFields);
  ...
end
I wonder how this can ever work for compound keys, since this can never return a single MasterField...

------------------
Marco Kalter
Allround Automations
 
Back
Top