TMyStoredProc / Filter property does not work with LIKE clause ?

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jackfirst72
Posts: 8
Joined: Wed 02 Aug 2006 15:48

TMyStoredProc / Filter property does not work with LIKE clause ?

Post by jackfirst72 » Wed 02 Aug 2006 15:57

Hi,
Here is the code I use to filter the content of my TMyStoredProc after having retrieved data from the database :
---------------------------------------------------------------------------------

Code: Select all

procedure MyOwnClass.ExecuteFilter(const pc_valueToSearch : String);
var
  FilterValue : String;
begin
  if (pc_valueToSearch = EmptyStr) then
  begin
    FilterValue := EmptyStr;
  end
  else
  begin
    FilterValue := 'aFieldName LIKE ' + QuotedStr('%' + pc_valueToSearch + '%');
  end;
  pxyMySPMaster.Filtered := false;
  pxyMySPMaster.Filter   := FilterValue;
  pxyMySPMaster.Filtered := true;
end;
---------------------------------------------------------------------------------
The result is just empty ??? But the exactly same code DOES work with a simple TClientDataSet with the same columns and data ?
Thanks for your help.

jackfirst72
Posts: 8
Joined: Wed 02 Aug 2006 15:48

Post by jackfirst72 » Wed 02 Aug 2006 17:34

I forgot to say that the comparison '=' works fine. So if I write the following

Code: Select all

...
FilterValue := 'aFieldName = ' + QuotedStr(pc_valueToSearch);
...
and that "valueToSearch" corresponds exactly, the result is OK.
Why does'nt it work with the LIKE clause ?
Thanks.

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Thu 03 Aug 2006 11:04

Try to use '*' wildcard instead of '%'.

jackfirst72
Posts: 8
Joined: Wed 02 Aug 2006 15:48

Post by jackfirst72 » Thu 03 Aug 2006 13:03

Hi EvgeniyM.
Thanks for the tip. It works fine.
Have a good development day. :D

Post Reply