APPEND FROM not working when CDX file exist
-
- Posts: 38
- Joined: Tue Jan 09, 2007 2:31 am
- Location: Winston-Salem, NC
APPEND FROM not working when CDX file exist
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
Charles Pratt
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: APPEND FROM not working when CDX file exist
Can you show a reduced sample of the problem?
EMG
EMG
-
- Posts: 38
- Joined: Tue Jan 09, 2007 2:31 am
- Location: Winston-Salem, NC
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
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
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
-
- Posts: 38
- Joined: Tue Jan 09, 2007 2:31 am
- Location: Winston-Salem, NC
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
The following sample works fine here:
Please add the minimal amount of code needed to replicate the problem.
EMG
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
EMG
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.
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
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
-
- Posts: 38
- Joined: Tue Jan 09, 2007 2:31 am
- Location: Winston-Salem, NC
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
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
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Same error with Clipper. The reason is that you can't use aliases inside the index key. Change as follows:
EMG
Code: Select all
INDEX ON FIELD->LAST TAG LAST
INDEX ON FIELD->SALARY TAG SALARY
-
- Posts: 38
- Joined: Tue Jan 09, 2007 2:31 am
- Location: Winston-Salem, NC