Index Memo Fields ?

Index Memo Fields ?

Postby TimStone » Wed May 10, 2017 12:18 am

Is it possible to index the first part of a memo field ? I'd like to build an index based on the first 60 characters of the memo, regardless of how long it is actually.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2943
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Index Memo Fields ?

Postby nageswaragunupudi » Wed May 10, 2017 4:54 am

Yes
Please use PADR() instead of LEFT()
INDEX ON PADR( <field>, 60 ) TAG ...
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Index Memo Fields ?

Postby TimStone » Wed May 10, 2017 3:25 pm

Generates error:

Error description: Error ADSCDX/3009 Error 3009: Unsupported data type in function parameter in index key expression.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2943
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Index Memo Fields ?

Postby hmpaquito » Wed May 10, 2017 3:35 pm

try so:

Code: Select all  Expand view
INDEX ON Left( <field>+ Space(60), 60 ) TAG ...
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Index Memo Fields ?

Postby nageswaragunupudi » Wed May 10, 2017 3:44 pm

I tested with this code and it worked for me
Code: Select all  Expand view
 
function test()

   FIELD CODE

  USE C:\FWH\SAMPLES\PROCESS NEW EXCLUSIVE VIA "DBFCDX"
   INDEX ON PADR(CODE,20) TAG CODEX
   CLOSE DATA

   USE C:\FWH\SAMPLES\PROCESS
   SET ORDER TO TAG CODEX
   ? ORDKEY()  // --> "PADR(CODE,20)"
   XBROWSER DBSTRUCT()
   return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Index Memo Fields ?

Postby TimStone » Wed May 10, 2017 4:19 pm

I'm using Advantage Database Server ... won't work with it. The functions are not supported.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2943
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Index Memo Fields ?

Postby James Bott » Thu May 11, 2017 2:46 pm

Hi Tim,

Its a disk space waste, but you could post the first 60 characters of the memo field to another field every time you save the record, then index on that. Since you are using database objects, you can do this automatically in the save method.

Code: Select all  Expand view
Class TCustomer from TData
   Method Save()
Endclass

Method Save() Class TCustomer
   ::notes60= left( ::notes, 60 )
Return  super:save()
 

Now whenever you save a customer object, both fields are updated automatically. You just need to index on the notes60 field.


Regards,
James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Index Memo Fields ?

Postby nageswaragunupudi » Thu May 11, 2017 2:49 pm

TimStone wrote:I'm using Advantage Database Server ... won't work with it. The functions are not supported.

On ADS, this might work

INDEX ON Left( <field>+ Space(60), 60 ) TAG ...
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Index Memo Fields ?

Postby James Bott » Thu May 11, 2017 2:54 pm

Nages,

Well, if that works it would be a lot simpler than my suggestion.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Index Memo Fields ?

Postby TimStone » Thu May 11, 2017 2:59 pm

James, for this task it might be easier to simply add a field to a database ... which would accomplish what the client requested ... but I just don't want to a db update right now. The field would actually be the best solution ...

Nages, I had tried that method and though it doesn't error out, it also does not build an index. I can set this aside for now and deal with it another way later.

Thanks.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2943
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Index Memo Fields ?

Postby James Bott » Fri May 12, 2017 1:10 am

Tim,

James, for this task it might be easier to simply add a field to a database


I'm sorry, I didn't make that clear, you would need to add a field, then you modify the Save() method so it automatically saves the first 60 characters of the memo field to the new 60 character length string field. This way it the new field is always up to date.

I'm not sure what indexing will get you? I can see searching this though. Indexing and seeking would only get you the first word, right? Maybe I am missing something.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 53 guests