UniMetadata - get table and View list

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
kneighbour
Posts: 77
Joined: Wed 08 Oct 2008 04:55

UniMetadata - get table and View list

Post by kneighbour » Mon 02 Feb 2015 02:37

I am trying to get a table and view list from either a Firebird or a MS SQL database.

Code: Select all

  MetaData.MetaDatakind := 'Tables';
      MetaData.open;
      MetaData.first;
      while not MetaData.eof do
         begin
            temp := MetaData.FieldByName('TABLE_NAME').AsString;
            if Pos('RDB$', temp) = 0 then
                  AddNode(TablesNode, temp, cTableImage) ;
            MetaData.next;
         end;
      MetaData.close;
That is basically the code. The CONNECTION is either to a Firebird 2.5 database, or to a MS SQL database.

Problem 1 -
In Firebird, I get the correct list of tables. I want to separate out the list of Views. Is there any way to do this??


Problem 2 -
In MS SQL, I get a list of everything - not limited to tables. All system tables, columns, contraints, views, everything.

How Can I just see the tables. Also - want to separate out the Views. Any way to do this?

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

Re: UniMetadata - get table and View list

Post by ViktorV » Mon 02 Feb 2015 08:32

When working with the TUniMetaData component, you can filter the retrieved result using the TUniMetaData.Restrictions property. See more details about this property in the UniDAC documentation: http://www.devart.com/unidac/docs/devar ... ctions.htm
For example: to return only user tables, before calling the TMetaData.Open method, insert the following code line:

Code: Select all

MetaData.Restrictions.Values['TABLE_TYPE'] := 'TABLE';
And to return only user views - insert

Code: Select all

MetaData.Restrictions.Values['TABLE_TYPE'] := 'VIEW';

kneighbour
Posts: 77
Joined: Wed 08 Oct 2008 04:55

Re: UniMetadata - get table and View list

Post by kneighbour » Thu 05 Feb 2015 06:32

thanks

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

Re: UniMetadata - get table and View list

Post by ViktorV » Thu 05 Feb 2015 09:20

Feel free to contact us if you have any further questions about UniDAC.

Post Reply