Hi,
I'm using D5, MyDac 3.5.0.17, InnoDB.
In my application I need to retrieve the fields of the primary key.
I've try using IndexDefs[0].Fields, but it is slow (about 0.10~0.30 s).
Is there a way of obtaining these fields in a faster way?
Thanks
Luca
Retrieving Index Fields
Retrieve Primary Key Field
Hi,
I had wrote the function :
I had wrote the function :
Hope it can helpfunction GetKeyField(strTable:string;QGetKeyField:TMyQuery):string;
var
strIndex : string;
Begin
strIndex := '';
With QGetKeyField Do BEgin
Close;
SQL.Clear;
SQL.Add('SHOW INDEX FROM ' + strTable);
Open;
End;
If QGetKeyField.RecordCount = 0 Then
Result := ''
Else
Begin
While Not QGetKeyField.Eof Do Begin
If QGetKeyField.FieldByName('Key_Name').AsString='PRIMARY' Then
Begin
If strIndex='' Then
strIndex := TRIM(QGetKeyField.FieldByName('Column_Name').AsString) + ','
Else
strIndex := strIndex + TRIM(QGetKeyField.FieldByName('Column_Name').AsString) + ',';
End;
QGetKeyField.Next;
End;
Delete(strIndex,Length(strIndex),1);
Result := strIndex;
End;
End;