APPEND FROM not working when CDX file exist

Post Reply
CharlesPratt
Posts: 38
Joined: Tue Jan 09, 2007 2:31 am
Location: Winston-Salem, NC

APPEND FROM not working when CDX file exist

Post by CharlesPratt »

I am not able to append from a dbf file when it has a .CDX file associated with it. The only way I can do it is to delete the cdx file first, then do an "INDEX ON..." to rebuild it after I append from it. Is this a limitation of xHarbour or is it a bug?

Charles
Charles Pratt
CharlesPratt
Posts: 38
Joined: Tue Jan 09, 2007 2:31 am
Location: Winston-Salem, NC

Post by CharlesPratt »

Enrico -
You can download a sample that shows the problem from http://www.softraksystems.com/download/append.zip Run the exe file and look at the prg file. I also included the error.log which appears in the app directory after it overwrites the first one that you see when the error occurs. The one you see says "alias not found", but is overwritten by the one that says "hb_cdxIndexFree: Index file still locked."

The problem appears to be that dbCloseArea() does not release the lock on the CDX file that has been previously opened with the dbf file as EXCLUSIVE.

Thanks for your help.

Charles
Last edited by CharlesPratt on Thu Aug 16, 2007 2:43 pm, edited 1 time in total.
Charles Pratt
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Page not found. Please paste here the PRG showing the problem.

EMG
CharlesPratt
Posts: 38
Joined: Tue Jan 09, 2007 2:31 am
Location: Winston-Salem, NC

Post by CharlesPratt »

Enrico -
Now the download link works. Sorry I didn't test it before.

Charles
Charles Pratt
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

The following sample works fine here:

Code: Select all

REQUEST DBFCDX


FUNCTION MAIN()

    RDDSETDEFAULT( "DBFCDX" )

    DBCREATE( "ERRTEST", { { "TEST", "C", 35, 0 } } )

    USE ERRTEST

    INDEX ON FIELD -> test TO ERRTEST

    APPEND BLANK

    REPLACE FIELD -> test WITH "Test"

    DBCREATE( "ERRTEST2", { { "TEST", "C", 35, 0 } } )

    USE ERRTEST2

    APPEND FROM ERRTEST

    RETURN NIL
Please add the minimal amount of code needed to replicate the problem.

EMG
User avatar
driessen
Posts: 1239
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Post by driessen »

Enrico,

It has been some time since I used "Append".

But if I remember well, the file from which you append, must be closed.

Could that solve your problem ?

Good luck.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Yes, you are right, as COPY TO opens the destination file in exclusive mode.

EMG
CharlesPratt
Posts: 38
Joined: Tue Jan 09, 2007 2:31 am
Location: Winston-Salem, NC

Post by CharlesPratt »

Enrico -
The following code is very simple, and causses the error to occur. Rather than using dbcreate as you did, I am using the customer.dbf from the FWH samples folder. The first time you run this, un-comment the COPY TO CUST line to produce the tcust.dbf.

REQUEST DBFCDX

RDDSETDEFAULT("DBFCDX")

USE CUSTOMER NEW EXCLUSIVE
INDEX ON CUSTOMER->LAST TAG LAST
INDEX ON CUSTOMER->SALARY TAG SALARY
DBGOTOP()

*COPY TO TCUST

CUSTOMER->(DBCLOSEAREA())

USE TCUST
ZAP
APPEND FROM CUSTOMER

RETURN NIL

Regards,
Charles
Charles Pratt
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Same error with Clipper. The reason is that you can't use aliases inside the index key. Change as follows:

Code: Select all

INDEX ON FIELD->LAST TAG LAST
INDEX ON FIELD->SALARY TAG SALARY
EMG
CharlesPratt
Posts: 38
Joined: Tue Jan 09, 2007 2:31 am
Location: Winston-Salem, NC

Post by CharlesPratt »

That fixes it. Many thanks, Enrico. I have some code to change in some of my apps.

Charles
Charles Pratt
Post Reply