FUNNY Indexing

FUNNY Indexing

Postby avista » Sun Jan 22, 2012 11:35 am

Hi to all
This is example program:

#include "FiveWin.ch"
//----------------------------------------------------------------------------//
function Main()
local i := 0
local aData := {"11","9","9999999999","99999999999","11111111111" }
DbCreate( "MyDbf.dbf", { { "Field1", "C", 13, 0 } } )
USE MyDbf
FOR i = 1 TO LEN( aData)
DbAppend()
REPLACE Field1 WITH aData[ i ]
NEXT
INDEX ON VAL(MyDbf->Field1) TO MyIndex
XBROWSE()
return nil

DATA ARE ORDERED LIKE THIS:
99999999999
11111111111
9
11
9999999999

:)
Best Regards
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: FUNNY Indexing

Postby Enrico Maria Giordano » Sun Jan 22, 2012 2:13 pm

Code: Select all  Expand view
INDEX ON STR(VAL(MyDbf->Field1),LEN(MyDbf->Field1)) TO MyIndex


Please note:

1. This is standard Clipper behavior (I just tested with Clipper 5.3b).

2. This is not a problem with FWH.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8419
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FUNNY Indexing

Postby Rick Lipkin » Sun Jan 22, 2012 6:00 pm

Avista

Code: Select all  Expand view

INDEX ON VAL(MyDbf->Field1) TO MyIndex
 


Try eliminating the database name in the index ..

Code: Select all  Expand view

Select MyDbf
INDEX ON VAL(Field1) TO MyIndex
 


Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2642
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: FUNNY Indexing

Postby Gale FORd » Sun Jan 22, 2012 6:11 pm

The problem is the val() function does not return a fixed length and the index needs to be fixed length.
Like Enrico's example, you should convert it to a fixed length string.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: FUNNY Indexing

Postby avista » Mon Jan 23, 2012 9:55 am

Hi,

INDEX ON STR(VAL(MyDbf->Field1),LEN(MyDbf->Field1)) TO MyIndex

Yes this is going well ....

Enrico ...this is problem in FWH too if you use NTX index ...with CDX there is no problem.

Thanks to all,
Best regards,
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: FUNNY Indexing

Postby MarcoBoschi » Mon Jan 23, 2012 1:10 pm

avista
> this is problem in FWH too if you use NTX index ...with CDX there is no problem.
enrico
>1. This is standard Clipper behavior (I just tested with Clipper 5.3b).
It's standard but it's wrong and very dangerous!

bye

marco
User avatar
MarcoBoschi
 
Posts: 1028
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: FUNNY Indexing

Postby Enrico Maria Giordano » Mon Jan 23, 2012 2:35 pm

I repeat: it's not a problem with FWH. Please report it to comp.lang.xharbour.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8419
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FUNNY Indexing

Postby hmpaquito » Mon Jan 23, 2012 3:56 pm

Hi,

I never use numeric keys.
1st) In dates do not obtain good order; it's necessary dtos()
2st) Numerics do not permit add subkeys field1+ field2

I allways use character key expressions, are more controllables (length key) y expansives (subkeys)

Regards
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: FUNNY Indexing

Postby Enrico Maria Giordano » Mon Jan 23, 2012 4:03 pm

I used dates as index key sometimes and never find any problems.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8419
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FUNNY Indexing

Postby hmpaquito » Mon Jan 23, 2012 4:34 pm

emg,

dates aren't good keys

INDEX ON Date1 TO FileOrder // obtain wrong order:
...
23/01/2011
23/01/2012
23/01/2013
24/01/2011
24/01/2012
24/01/2013
...


INDEX on DToS(Date1) TO FileOrder // obtain right order:
...
2011/23/01
2011/24/01
2012/23/01
2012/24/01
2013/23/01
2013/24/01
...

Regards
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: FUNNY Indexing

Postby Enrico Maria Giordano » Mon Jan 23, 2012 4:51 pm

Please post a complete sample showing the problem.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8419
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FUNNY Indexing

Postby hmpaquito » Mon Jan 23, 2012 5:27 pm

I dont understand; there is no problem; i haven´t problem. I only say: date expression do not keep year+month+day natural order and consequently they are very bad order key.That's all.
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: FUNNY Indexing

Postby Enrico Maria Giordano » Mon Jan 23, 2012 6:41 pm

But since I already used (as I said) dates as index key without any problems then I can't confirm the behavior you reported. So I need a sample showing that behavior. The following sample works fine for me:

Code: Select all  Expand view
#include "FiveWin.ch"
//----------------------------------------------------------------------------//
function Main()
local i := 0
local aData
SET DATE BRITISH
aData = {CTOD( "23/01/2011" ), CTOD( "24/01/2011" ), CTOD( "23/01/2012" ), CTOD( "24/01/2012" ), CTOD( "23/01/2013" ), CTOD( "24/01/2013" ) }
DbCreate( "MyDbf.dbf", { { "Field1", "D", 8, 0 } } )
USE MyDbf
FOR i = 1 TO LEN( aData)
DbAppend()
REPLACE Field1 WITH aData[ i ]
NEXT
INDEX ON MyDbf->Field1 TO MyIndex
XBROWSE()
return nil


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8419
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FUNNY Indexing

Postby hmpaquito » Mon Jan 23, 2012 6:55 pm

Enrico,

You are right. I was thinking in

INDEX ON DToC(Date1) TO TmpFile

DToC() function return bad order expression key

INDEX ON Date1 TO TmpFile is ok; my fault; I´m sorry :(


Regards
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: FUNNY Indexing

Postby Enrico Maria Giordano » Mon Jan 23, 2012 6:58 pm

No problem at all, my friend.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8419
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

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