How to use UniMetadata

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
fgodecke
Posts: 2
Joined: Thu 29 Jul 2021 19:32

How to use UniMetadata

Post by fgodecke » Thu 29 Jul 2021 19:44

Hello,

I want a list of indexes from a certain table in MySQL.

What is wrong in this code?

IndexListBox.Clear;
UniMetaData1.Filter:=MyTablename;
UniMetaData1.MetaDataKind:='Indexes';
UniMetaData1.Open;
UniMetaData1.First;
While not UniMetaData1.Eof do
begin
IndexListBox.Items.add(UniMetaData1.FieldValues['COLUMN_NAME']);
UniMetaData1.Next;
end;

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: How to use UniMetadata

Post by ViktorV » Fri 30 Jul 2021 13:47

Hi there,
In order to get the list of index names, you may use the following code:

Code: Select all

  IndexListBox.Clear;
  UniMetaData1.Restrictions.Values['TABLE_NAME'] := MyTablename;
  UniMetaData1.MetaDataKind:='Indexes';
  UniMetaData1.Open;
  UniMetaData1.First;
  While not UniMetaData1.Eof do begin
    IndexListBox.Items.add(UniMetaData1.FieldValues['INDEX_NAME']);
    UniMetaData1.Next;
  end;
In order to get the list of index columns, you may use the following code:

Code: Select all

  IndexListBox.Clear;
  UniMetaData1.Restrictions.Values['TABLE_NAME'] := MyTablename;
  UniMetaData1.MetaDataKind:='IndexColumns';
  UniMetaData1.Open;
  UniMetaData1.First;
  While not UniMetaData1.Eof do begin
    IndexListBox.Items.add(UniMetaData1.FieldValues['COLUMN_NAME']);
    UniMetaData1.Next;
  end;
You may also find more information about TUniMetaData component on our site:
https://www.devart.com/unidac/docs/Deva ... aData.htm

Regards,
Viktor

fgodecke
Posts: 2
Joined: Thu 29 Jul 2021 19:32

Re: How to use UniMetadata

Post by fgodecke » Fri 30 Jul 2021 17:44

Thank you, Victor.
It's works now.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: How to use UniMetadata

Post by ViktorV » Tue 03 Aug 2021 16:18

Hi there!

I’m glad that your issue is fully resolved now and you can use all the features of our product.
In case you will get any additional questions simply submit a new request or reply in this topic.

Regards,
Viktor

Post Reply