Equivalent of BDE TTable IndexName property?

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
stevel
Posts: 125
Joined: Tue 02 Nov 2010 19:01

Equivalent of BDE TTable IndexName property?

Post by stevel » Thu 25 Jul 2013 22:08

For TUniTable (Interbase provider), what is the equivalent property for BDE TTable IndexName?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Equivalent of BDE TTable IndexName property?

Post by AlexP » Fri 26 Jul 2013 08:05

Hello,

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

stevel
Posts: 125
Joined: Tue 02 Nov 2010 19:01

Re: Equivalent of BDE TTable IndexName property?

Post by stevel » Sat 27 Jul 2013 01:29

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;


AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Equivalent of BDE TTable IndexName property?

Post by AlexP » Mon 29 Jul 2013 08:25

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.

Post Reply