filtering TMyMetaData

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jkuiper
Posts: 138
Joined: Fri 04 Aug 2006 14:17

filtering TMyMetaData

Post by jkuiper » Mon 15 Sep 2008 09:53

I'm using TMyMetaData with options columns to show all my tables with columns and definitions. I'm using a filter to select one schema (database), because only one database I want to see. But the filter doesn't work. I even created IndexFieldNames, but it doesn't help.

So how do I filter my data?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 16 Sep 2008 11:49

If you want to use the Filter property you should set the TMyMetaData.Filtered property to True, like this:

Code: Select all

MyMetaData.Filter := 'TABLE_SCHEMA=''test''';
MyMetaData.Filtered := True;
Also you can use the Restrictions property to provide one or more conditions restricting the list of objects to be described. This is a better way, because filtering is executed on server.
For example:

Code: Select all

MyMetaData.Restrictions.Values['TABLE_SCHEMA'] := 'test';

jkuiper
Posts: 138
Joined: Fri 04 Aug 2006 14:17

Post by jkuiper » Wed 17 Sep 2008 10:49

I set my filter in the properties in TMyMetaData en set the Filtered to true with no results. But I didn't try the Restrictions, because the help didn't say how to use it.
But I'm going to try it.

jkuiper
Posts: 138
Joined: Fri 04 Aug 2006 14:17

Post by jkuiper » Wed 17 Sep 2008 10:55

It works, thanks.

Another question about restrictions. Is it also possible to excludes things like tables?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 19 Sep 2008 10:48

You can specify the table to show information for, like this:

Code: Select all

MyMetaData.Restrictions.Values['TABLE_NAME'] := 'table';
You can use the TMyMetaData.GetRestrictions method to find out which restrictions are applicable to a certain MetaDataKind.

Post Reply