Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 11 total
Thread Indexed field
Wed, Jul 27 2016 12:26 PMPermanent Link

Jose Eduardo Helminsky

HPro Informatica

If I have an indexed field, how can I use this feature to find a record using delphi table methods instead of using SQL code ?

Field
Name = 'JOSE EDUARDO';

SQL:
select * from table where textsearch('EDUARDO in name)
Wed, Jul 27 2016 12:34 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Eduardo,

I believe that you mean a Full Text Index, right?
If so, you can do it filtering the records, just like this:

With Table1 do
begin
  Filter := 'TEXTSEARCH( ''EDUARDO'' IN Name)';
  Filtered:=True;
end;

--
Fernando Dias
[Team Elevate]
Thu, Jul 28 2016 5:16 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Jose


Apart from the use of the dreaded "with" I agree with Fernando.

Its worth pointing out that, in as far as its practicable, Tim has made it so that filters for tables and SQL (ie the WHERE clause) work the same. The most significant difference is JOINs. They don't work in filters Frown

Its always worth trying the same syntax and most of the time you'll be pleasantly surprised.


Roy Lambert
Thu, Jul 28 2016 6:09 AMPermanent Link

Jose Eduardo Helminsky

HPro Informatica

Raul and Roy

Thanks for the explanation.

I will think how I can use this feature because users want to search text inside a field and I "hate" this because I have never use "like" in SQL statements but I have already used textsearch in a full text index (sorry Fernando to say indexed field) and it works very well.

Eduardo
Thu, Jul 28 2016 7:15 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Jose


Because of the power and flexibility of LIKE in ElevateDB it can be slow on big CLOB fields so I switched from field LIKE '%xxx%' to POS('xxx',field) yoou need to uppercase (or lowercase) it first but its fast and effective.

Roy Lambert
Thu, Jul 28 2016 9:41 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

José,

My name is not Raul, but as it's not a bad name, it's ok Smiley

--
Fernando Dias
[Team Elevate]
Thu, Jul 28 2016 10:10 AMPermanent Link

Jose Eduardo Helminsky

HPro Informatica

Fernando

I am so sorry about it, I was reading another thread with a user called "Raul".

The basic rule: read carefully BEFORE post

Eduardo
Thu, Jul 28 2016 3:47 PMPermanent Link

Walter Matte

Tactical Business Corporation

This is basic Table functions since Delphi 1.


tbTable.IndexName := '';  // IF primary key

//or

tbTable.IndexName := ;idxName';   // what ever name you called the index


//then

tbTable.SetKey;
tbTable.FieldByName('Name').AsString := 'JOSE EDUARDO';
if tbTable.GotoKey then
 ShowMessage('Found record')
else
 ShowMessage('Not Found');


// or

tbTable.SetKey;
tbTable.FieldByName('Name').AsString := 'JOSE EDUARDO';
if tbTable.GotoNearest;Key;

ShowMessage('We are at nearest record')


Walter
Thu, Jul 28 2016 3:48 PMPermanent Link

Walter Matte

Tactical Business Corporation

Small fix - cut and paste got me.


tbTable.SetKey;
tbTable.FieldByName('Name').AsString := 'JOSE EDUARDO';
if tbTable.GotoNearest;

ShowMessage('We are at nearest record')
Fri, Jul 29 2016 6:29 AMPermanent Link

Jose Eduardo Helminsky

HPro Informatica

Walter Matte

Thanks for your contribution but I think you misunderstand the question.

This is not so basic. The idea here is to find records with some word "inside" the field and not "beginning" with when we can use FindKey or FindNearest.

And when I write "word" I mean an entire word and not part of a word, because in this case we have to use LIKE or POS.
Page 1 of 2Next Page »
Jump to Page:  1 2
Image