FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour APPEND FROM not working when CDX file exist
Posts: 38
Joined: Tue Jan 09, 2007 02:31 AM

APPEND FROM not working when CDX file exist

Posted: Tue Aug 14, 2007 08:48 PM

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
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

Re: APPEND FROM not working when CDX file exist

Posted: Tue Aug 14, 2007 09:39 PM

Can you show a reduced sample of the problem?

EMG

Posts: 38
Joined: Tue Jan 09, 2007 02:31 AM

APPEND FROM not working when CDX file exist

Posted: Thu Aug 16, 2007 11:33 AM

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

Charles Pratt
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

APPEND FROM not working when CDX file exist

Posted: Thu Aug 16, 2007 02:02 PM

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

EMG

Posts: 38
Joined: Tue Jan 09, 2007 02:31 AM

APPEND FROM not working when CDX file exist

Posted: Thu Aug 16, 2007 02:45 PM

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

Charles

Charles Pratt
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

APPEND FROM not working when CDX file exist

Posted: Thu Aug 16, 2007 04:10 PM
The following sample works fine here:

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
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM

APPEND FROM not working when CDX file exist

Posted: Fri Aug 17, 2007 12:24 AM

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. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

APPEND FROM not working when CDX file exist

Posted: Fri Aug 17, 2007 06:46 AM

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

EMG

Posts: 38
Joined: Tue Jan 09, 2007 02:31 AM

APPEND FROM not working when CDX file exist

Posted: Fri Aug 17, 2007 02:25 PM

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
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM

APPEND FROM not working when CDX file exist

Posted: Fri Aug 17, 2007 03:15 PM
Same error with Clipper. The reason is that you can't use aliases inside the index key. Change as follows:

INDEX ON FIELD->LAST TAG LAST
INDEX ON FIELD->SALARY TAG SALARY


EMG
Posts: 38
Joined: Tue Jan 09, 2007 02:31 AM

APPEND FROM not working when CDX file exist

Posted: Fri Aug 17, 2007 05:37 PM

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

Charles

Charles Pratt

Continue the discussion