UNIQUE + CDX + set delete on

UNIQUE + CDX + set delete on

Postby Otto » Mon Oct 05, 2009 8:34 am

I have a question concerning: UNIQUE

Records:
natural order
------------------------------
101 DELETED
101
102
103
104


SET delete on
index on field->test TAG TEMPADR UNIQUE

then 101 is missing in the index file.

If the natural order is like this:
------------------------------
101
101 DELETED
102
103
104

101 is in the index scope.

Is this behavior correct?

Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: UNIQUE + CDX + set delete on

Postby Enrico Maria Giordano » Mon Oct 05, 2009 11:37 am

I see no problem using this sample (xHarbour + BCC55):

Code: Select all  Expand view
REQUEST DBFCDX


FUNCTION MAIN()

    RDDSETDEFAULT( "DBFCDX" )

    DBCREATE( "BUGTEST", { { "CODICE", "N", 3, 0 } } )

    USE BUGTEST

    APPEND BLANK

    REPLACE FIELD -> codice WITH 101

    DELETE

    APPEND BLANK

    REPLACE FIELD -> codice WITH 101

    APPEND BLANK

    REPLACE FIELD -> codice WITH 102

    INDEX ON FIELD -> codice TO BUGTEST UNIQUE

    GO TOP

    WHILE !EOF()
        ? FIELD -> codice
        SKIP
    ENDDO

    CLOSE

    RETURN NIL


It correctly prints

101
102


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

Re: UNIQUE + CDX + set delete on

Postby Otto » Mon Oct 05, 2009 12:24 pm

Hello Enrico,

thank you for your answer.
Please try with:

SET DELETE ON

I only get 102 back.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm


Re: UNIQUE + CDX + set delete on

Postby Otto » Mon Oct 05, 2009 6:09 pm

Enrico, thank you.
I never noticed this behavior. I have to look after where I use unique in my index expression.
I don’t use it much.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: UNIQUE + CDX + set delete on

Postby Enrico Maria Giordano » Tue Oct 06, 2009 7:27 am

I just report the problem to the Harbour and xHarbour mailing-lists. I will report back here the answers.

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

Re: UNIQUE + CDX + set delete on

Postby Otto » Tue Oct 06, 2009 7:45 am

Enrico, thank you very much.
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Re: UNIQUE + CDX + set delete on

Postby Enrico Maria Giordano » Tue Oct 06, 2009 8:22 am

This is the answer from Przemyslaw:

The behavior is correct. Index contain record 1 with value 101 but
is filter by your SET DELETE ON filter. If you want to filter such
records when index is created then use USEFILTER clause in INDEX ON
command, i.e.:
INDEX ON FIELD -> codice TO BUGTEST UNIQUE USEFILTER
In such case record 1 (101) will not be added to filter but
record 2 which has the same key.


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

Re: UNIQUE + CDX + set delete on

Postby James Bott » Thu Oct 08, 2009 10:26 pm

Otto,

Instead of this:

SET delete on
index on field->test TAG TEMPADR UNIQUE

Try this:

index on field->test TAG TEMPADR UNIQUE FOR ! DELETED

I don't know if this will work, but it may skip deleted records when building the UNIQUE index. If so, then this should work regardless of the natural order of the records.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: UNIQUE + CDX + set delete on

Postby Enrico Maria Giordano » Fri Oct 09, 2009 6:47 am

Yes, FOR !Deleted() works fine.

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 58 guests