Recent

Author Topic: Filter syntax  (Read 1706 times)

johnmc

  • New Member
  • *
  • Posts: 31
Filter syntax
« on: January 12, 2020, 03:24:40 pm »
I have been trying to find some documenation regarding the syntax of the filter string used to filter a dataset, hitting F1 brings up only a brief description. Where can I find a complete description?

The best that I can come up with is the wiki https://wiki.lazarus.freepascal.org/Lazarus_Tdbf_Tutorial#Index.2Ffilter_on_strings

Was there some sort of software specification writen for this if so where would I find it?

howardpc

  • Hero Member
  • *****
  • Posts: 3481
Re: Filter syntax
« Reply #1 on: January 12, 2020, 03:30:53 pm »
Are you asking specifically about the Lazarus/FPC implementation of TDbf, or some other dataset descendant?

johnmc

  • New Member
  • *
  • Posts: 31
Re: Filter syntax
« Reply #2 on: January 12, 2020, 03:48:45 pm »
I am using Sqlite3, so that would be my preference if it makes any difference.

GetMem

  • Hero Member
  • *****
  • Posts: 3744
Re: Filter syntax
« Reply #3 on: January 12, 2020, 06:35:06 pm »
If you're using TSQLQuery, which is a TCustomBufDataset descendent,  the solution is quite simple: create an OnFilterRecord for the Query, then:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.SQLQuery1FilterRecord(DataSet: TDataSet; var Accept: Boolean);
  2. begin
  3.   Accept := SQLQuery1.FieldByName('FIRSTNAME').AsString = 'John';
  4. end;
  5.  
The code is self explanatory I guess, if not please let us know.

johnmc

  • New Member
  • *
  • Posts: 31
Re: Filter syntax
« Reply #4 on: January 12, 2020, 09:47:19 pm »
GetMem I was using TDataSet.Filter and want more info on the format and syntax of the filter string.

Code: Pascal  [Select][+][-]
  1.       myFilter := 'Country = ' + QuotedStr(DBGrid1.SelectedField.AsString);
  2.       SQLQuery.filter := myFilter;
  3.       SQLQuery.Filtered := True;
  4.  


 

TinyPortal © 2005-2018