APPEND FROM not working when CDX file exist

APPEND FROM not working when CDX file exist

Postby CharlesPratt » Tue Aug 14, 2007 8: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
CharlesPratt
 
Posts: 38
Joined: Tue Jan 09, 2007 2:31 am
Location: Winston-Salem, NC

Re: APPEND FROM not working when CDX file exist

Postby Enrico Maria Giordano » Tue Aug 14, 2007 9:39 pm

Can you show a reduced sample of the problem?

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

Postby CharlesPratt » 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
Last edited by CharlesPratt on Thu Aug 16, 2007 2:43 pm, edited 1 time in total.
Charles Pratt
CharlesPratt
 
Posts: 38
Joined: Tue Jan 09, 2007 2:31 am
Location: Winston-Salem, NC

Postby Enrico Maria Giordano » Thu Aug 16, 2007 2:02 pm

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

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

Postby CharlesPratt » Thu Aug 16, 2007 2:45 pm

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

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

Postby Enrico Maria Giordano » Thu Aug 16, 2007 4:10 pm

The following sample works fine here:

Code: Select all  Expand view
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
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby driessen » 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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Enrico Maria Giordano » Fri Aug 17, 2007 6:46 am

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

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

Postby CharlesPratt » Fri Aug 17, 2007 2: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
CharlesPratt
 
Posts: 38
Joined: Tue Jan 09, 2007 2:31 am
Location: Winston-Salem, NC

Postby Enrico Maria Giordano » Fri Aug 17, 2007 3:15 pm

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

Code: Select all  Expand view
INDEX ON FIELD->LAST TAG LAST
INDEX ON FIELD->SALARY TAG SALARY


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

Postby CharlesPratt » Fri Aug 17, 2007 5:37 pm

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

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 45 guests