Is a TField in primary key?
Posted: Tue 05 Jul 2011 12:54
Hi,
after loading a TDataSet I would like to know, if a field is used in the primary key index. I tried the following code, which seems to work (at least with Firebird)
m.MetaDataKind := 'IndexColumns';
m.Restrictions.Values['TABLE_SCHEMA'] := FUniConnection.SpecificOptions.Values['Schema'];
m.Restrictions.Values['TABLE_NAME'] := ATableName;
m.Restrictions.Values['UNIQUE'] := '1';
m.Open;
while not m.Eof do begin
Result.Include(m.FieldByName('COLUMN_NAME').AsString);
m.Next;
end;
But is there a way to read the information from the TField directly? E.g. like from ProviderFlags or FieldKind?
cu Christian
after loading a TDataSet I would like to know, if a field is used in the primary key index. I tried the following code, which seems to work (at least with Firebird)
m.MetaDataKind := 'IndexColumns';
m.Restrictions.Values['TABLE_SCHEMA'] := FUniConnection.SpecificOptions.Values['Schema'];
m.Restrictions.Values['TABLE_NAME'] := ATableName;
m.Restrictions.Values['UNIQUE'] := '1';
m.Open;
while not m.Eof do begin
Result.Include(m.FieldByName('COLUMN_NAME').AsString);
m.Next;
end;
But is there a way to read the information from the TField directly? E.g. like from ProviderFlags or FieldKind?
cu Christian