Page 1 of 1

Filtering a table with an UNIQUEIDENTIFIER field

Posted: Fri 10 Jan 2014 09:13
by ads42
Hi,
I can't figure how to filer a table with an UNIQUEIDENTIFIER field.
Any expression sample for doing this stuff ? it seems that ising simply a string doesn't work.
Regards

Re: Filtering a table with an UNIQUEIDENTIFIER field

Posted: Fri 10 Jan 2014 12:35
by AlexP
Hello,

To filter data, you can use either local filtration

Code: Select all

  MSQuery1.KeyFields := 'f_uniqueidentifier';
  MSQuery1.Open;
  MSQuery1.Filter := 'f_uniqueidentifier like ''%d6658596%''';
  MSQuery1.FilterOptions := [foCaseInsensitive];
  MSQuery1.Filtered := True;
or use filtration on the server

Code: Select all

  MSQuery1.FilterSQL := 'f_uniqueidentifier like ''%d6658596%''';

Re: Filtering a table with an UNIQUEIDENTIFIER field

Posted: Wed 29 Jan 2014 09:11
by ads42
Hi Alex,
sory haven't received notifications about reply.
In your sample code you use an integer as a unique identifier, but in my case it's something like :
7fcaf9b3-7256-4953-a0e0-0c6122b47660

Any idea ?

Regards

Re: Filtering a table with an UNIQUEIDENTIFIER field

Posted: Wed 29 Jan 2014 09:33
by AlexP
In my example, I use a string field as KeyFields (the LIKE operator is used with strings). Please provide your query example.

Re: Filtering a table with an UNIQUEIDENTIFIER field

Posted: Wed 29 Jan 2014 09:49
by ads42
in my case 7fcaf9b3-7256-4953-a0e0-0c6122b47660 is a string field.
Should I use %d like in your sample ?
Can you change your code using my string ?

Re: Filtering a table with an UNIQUEIDENTIFIER field

Posted: Thu 30 Jan 2014 11:59
by AlexP
The '%' symbol in the LIKE operator means that any sequence of symbols can be in this place, i.e., if you specify in the filter:

Code: Select all

filed_name like '%a0e0%'
then all strings containing 'a0e0' will be found. If you need an accurate search, you should use the following filter:

Code: Select all

filed_name = '7fcaf9b3-7256-4953-a0e0-0c6122b47660'

Re: Filtering a table with an UNIQUEIDENTIFIER field

Posted: Thu 30 Jan 2014 12:48
by ads42
Thanks Alex.