FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ADS Local and Index
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
ADS Local and Index
Posted: Sat Jan 11, 2014 07:11 PM
Hi All,

After a lot of trial and error, web searches and head banging I found that when using ADS Local, Indexes are not done the same as standard xHarbour indexes.

With xHarbour, an index can be done as follows:

Code (fw): Select all Collapse
INDEX ON Test->Field1 TO C:\Test FOR Test->Field2 = cSomeString


With ADS Local, you cannot use cSomeString. I found this on the ADS website:
Memory variables do not work in expressions sent to the Advantage Database Server. This is applicable with filter or index expressions. The expression that is used for filtering or indexing must have all macros expanded prior to sending the expression text to the server


They give an example of how to get around this:
Solution:
Use the & symbol to expand macro values.

Below is a simple console application that demonstrates how to macro expand date variables in CA Visual Objects when used in a filter expression:
----------------
FUNCTION MemFilter()

LOCAL dbs AS DbServer
FIELD empid, first, last, hiredate
STATIC dDate AS DATE // won't macro-expand
MEMVAR cDate AS STRING // will macro-expand

dbs := DBServer{"\\ufo\recreate\dirke\VO2\scopes\master",DBSHARED,,"AXDBFCDX"}

dDate := CToD('10/01/98')
cDate := DToC(dDate)

? "SetFilter: "
? dbs:SetFilter(StrEvaluate('HIREDATE = CTOD("&cDate")')) <<<<<Here is their work around

WAIT

dbs:GoTop()
? "Filtered view: "
DO WHILE !(dbs:EOF)
? dbs:first,dbs:last,dbs:empid, dbs:hiredate
dbs:Skip()
ENDDO
wait


If I try replacing cSomeText with "&cSomeText" it still does not work.

Dose anyone know how to make this work?

I need to use ADS Local as I am using their table encryption.
Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Re: ADS Local and Index
Posted: Sun Jan 12, 2014 01:33 PM

Maybe &("{ || " + HIREDATE = CTOD(cDate) + "}")

Cheers,
Antonio Ferreira

Regards

Antonio H Ferreira
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: ADS Local and Index
Posted: Sun Jan 12, 2014 02:42 PM

Hi Antonio ... Thanks for the try but still is does not work :cry:

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 3022
Joined: Fri Oct 07, 2005 01:45 PM
Re: ADS Local and Index
Posted: Mon Jan 13, 2014 04:26 PM

Using tData objects:

oDB := tdata():new(, &quot;euntli&quot;,, .f. )
IF oDB:use()
    oDB:createIndex( &quot;euntli&quot;, &quot;UPPER(year)+UPPER(make)+UPPER(model)+UPPER(submodel)&quot;,,, .t., 10 )
ENDIF
oDB:close()

tData is an extension of tDatabase, provided by James Bott. It will make your life a whole lot simpler if you use it.

This works perfectly with DBFCDX, and ADS ( local and remote )

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: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: ADS Local and Index
Posted: Tue Jan 14, 2014 01:58 PM
Jeff,

Jeff Barnes wrote:
Code (fw): Select all Collapse
INDEX ON Test->Field1 TO C:\Test FOR Test->Field2 = cSomeString


Try this:

Code (fw): Select all Collapse
INDEX ON Test->Field1 TO C:\Test FOR ( [Test->Field2 = '] + cSomeString + ['] )


EMG
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: ADS Local and Index
Posted: Tue Jan 14, 2014 02:30 PM

Hi Enrico,

Sadly, it did not work. I get an ADSNTX/3211 error :(

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: ADS Local and Index
Posted: Tue Jan 14, 2014 03:30 PM
Jeff,

Jeff Barnes wrote:Hi Enrico,

Sadly, it did not work. I get an ADSNTX/3211 error :-)


What is in cSomeString?

EMG
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: ADS Local and Index
Posted: Tue Jan 14, 2014 03:40 PM

Jeff,

Try leaving out the aliases. These are variables too.

As I mentioned in another thread using aliases creates problems, especially if you want to open multiple copies of a database (and there are very good reasons to do so).

Try:

INDEX ON Field1 TO C:\Test FOR Field2 = &(cSomeString)

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: ADS Local and Index
Posted: Tue Jan 14, 2014 03:53 PM

Hi James,

Even without the alias it still fails :(

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: ADS Local and Index
Posted: Tue Jan 14, 2014 05:45 PM

I use ADS but not in Local mode. I took one of my index on commands and looked at to .ppo to see how it is structured.

Here is the actual code:
index on ld_num+mv_no tag ( [statactive] ) additive to ( ::cCurDir+cData ) for mv_status < 'F'

Here is the ppo code:
The "For" condition is set first.
ordCondSet( 'mv_status < "F"', {|| mv_status < "F"},,,,, RECNO(),,,,,, .T.,,,,,,, )

then the actual indexing is started
ordCreate( ( ::cCurDir+cData ), ( "statactive" ), "ld_num+mv_no", {|| ld_num+mv_no},,, ,{} )

Posts: 670
Joined: Wed Oct 19, 2005 06:41 PM
Re: ADS Local and Index
Posted: Wed Jan 15, 2014 04:04 AM

hello try

cFor = 'test->field2 = "' alltrim( cSomeString ) + '"'

INDEX ON Test->Field1 TO C:\Test FOR &( cFor )

saludos

Wilson 'W' Gamboa A
Wilson.josenet@gmail.com
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Re: ADS Local and Index
Posted: Wed Jan 15, 2014 01:24 PM

Hi Wilson,

That works :)

Thank you.

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: ADS Local and Index
Posted: Wed Jan 15, 2014 01:27 PM
Jeff,

Jeff Barnes wrote:Hi Wilson,

That works :-)

Thank you.


So the problem was inside cSomeString, as I suspected. :-)

EMG

Continue the discussion