Page 1 of 1

Equivalent of BDE TTable IndexName property?

Posted: Thu 25 Jul 2013 22:08
by stevel
For TUniTable (Interbase provider), what is the equivalent property for BDE TTable IndexName?

Re: Equivalent of BDE TTable IndexName property?

Posted: Fri 26 Jul 2013 08:05
by AlexP
Hello,

An analogue of the BDE IndexName property in UniDAC is the IndexFieldNames property

Re: Equivalent of BDE TTable IndexName property?

Posted: Sat 27 Jul 2013 01:29
by stevel
Thank you for responding. Here is some code I wrote that helps with transition from IndexName to IndexFieldNames. Especially useful for those converting from BDE (Paradox) application to UniDAC (Firebird or Interbase).

Firebird index names are unique throughout the database, so this code just works.

Code: Select all

// Given an Index-name return the columns that make up that index.
//  Steve Faleiro; July 2013
function GetIndexFieldNamesByIndexName(const AUniConnection: TUniConnection;
  const AIndexName: String): String;
var
  um: TUniMetaData;
  S: String;
begin
  S := EmptyStr;

  um := TUniMetaData.Create(nil);
  try
    um.Connection := AUniConnection;
    um.Restrictions.Values['INDEX_NAME'] := AIndexName;
    um.MetaDataKind := 'IndexColumns';
    um.IndexFieldNames := 'COLUMN_POSITION';
    um.Open;

    while not um.Eof do
    begin
      S := S + um.FieldByName('COLUMN_NAME').AsString;

      if um.RecNo <> um.Recordcount then
        S := S + '; ';

      um.Next;
    end;

  finally
    um.Free;
  end;

  Result := S;
end;


Re: Equivalent of BDE TTable IndexName property?

Posted: Mon 29 Jul 2013 08:25
by AlexP
Hello,

Yes, you can use the TUniMetaData component for retrieving the information about indexes. In addition, you can also retrieve the information about indexes by the table name.