FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Index Memo Fields ?
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Index Memo Fields ?
Posted: 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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Index Memo Fields ?
Posted: Wed May 10, 2017 04:54 AM

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

Regards



G. N. Rao.

Hyderabad, India
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Index Memo Fields ?
Posted: Wed May 10, 2017 03: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
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Re: Index Memo Fields ?
Posted: Wed May 10, 2017 03:35 PM
try so:

Code (fw): Select all Collapse
INDEX ON Left( <field>+ Space(60), 60 ) TAG ...
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Index Memo Fields ?
Posted: Wed May 10, 2017 03:44 PM
I tested with this code and it worked for me
Code (fw): Select all Collapse
   
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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Index Memo Fields ?
Posted: Wed May 10, 2017 04: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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Index Memo Fields ?
Posted: Thu May 11, 2017 02: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 (fw): Select all Collapse
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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Index Memo Fields ?
Posted: Thu May 11, 2017 02: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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Index Memo Fields ?
Posted: Thu May 11, 2017 02: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
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: Index Memo Fields ?
Posted: Thu May 11, 2017 02: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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Index Memo Fields ?
Posted: Fri May 12, 2017 01: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

Continue the discussion