strange (DOS Error 32) DBFCDX/1006 ¿bug?

Re: strange (DOS Error 32) DBFCDX/1006 ¿bug?

Postby Otto » Sun Feb 12, 2012 10:46 pm

Hello John,
I use xharbour and bcc582.
But the tests I made with your exe.
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: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: strange (DOS Error 32) DBFCDX/1006 ¿bug?

Postby codemaker » Mon Feb 13, 2012 12:15 am

John,
try to remove Commit() inside the loop
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: strange (DOS Error 32) DBFCDX/1006 ¿bug?

Postby StefanHaupt » Mon Feb 13, 2012 8:23 am

Hi John,

regarding your first sample:
- you cannot delete an open index
- if the index is deleted you must use index, not reindex, reindex needs an open index
- dbcommit() is not neccessary, it does not affekt the index, it will only write the database buffer to disk.

your second sample should work, but I would remove dbcommit(). Here it´s working fine
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: strange (DOS Error 32) DBFCDX/1006 ¿bug?

Postby ukservice » Mon Feb 13, 2012 3:15 pm

Hi,

Thanks for all help.

I modified the sample as follows:
http://demo.ovh.com/en/5f778b0a078d64d9 ... 153f675ff/

And now I get sometimes:
Error description: (DOS Error 5) DBFCDX/1006 Create error: C:\Users\John\Desktop\harbour\DATA\CUSTOMER.cdx

This is the code. I also compiled in pure DOS withour Fivewin and the error also arrises:

Code: Select all  Expand view

#define CRLF Chr(13)+Chr(10)

STATIC pPath

//--------------------------------------------------------------
FUNCTION MAIN()
//--------------------------------------------------------------


   LOCAL i := 0

   pPath := hb_dirbase()+"DATA"




   REQUEST DBFCDX, DBFFPT
   RDDSETDEFAULT( "DBFCDX")


   SET EPOCH TO 1990
   SET CENTURY ON
   SET DATE ITALIAN
   SET DELETED ON


   SET EXCLUSIVE ON
   SET AUTOPEN OFF




   for i:= 1 to 1000
      reindex()
   next

   alert(str(i)+CRLF+CRLF+"Path: "+PPATH+CRLF+CRLF+"Alias in use: "+Alias())
   dbcloseall()
   quit

RETURN NIL
//--------------------------------------------------------------



//--------------------------------------------------------------
FUNCTION REINDEX()
//--------------------------------------------------------------


        FERASE  (pPath+"\CUSTOMER.CDX")  // It´s not opened and it has a different name than dbf

        SELECT 1
        USE (pPath+"\CUST") EXCLUSIVE NEW  ALIAS "CUSTOMER"

        PACK

        INDEX ON FIELD->LAST TO (pPath+"\CUSTOMER")    // This line causes error
        dbcloseall()


return nil
//--------------------------------------------------------------
 


It´s quite strange.

Thank you very much for all help and support.
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: strange (DOS Error 32) DBFCDX/1006 ¿bug?

Postby Rick Lipkin » Mon Feb 13, 2012 8:23 pm

John

I put together a Sample program to open and index a FoxPro Database and compound index. I saw a couple of things I felt were wrong with your code ..

1) The .dbf and .cdx have to be the same name "Customer.dbf", "Customer.Cdx" but you can use any Alias you wish.
2) Opening your tables I would use this syntax use ( "table.dbf" ) via "DBFCDX" .. you left out the via clause
3) I supplied a function called NetUse() and you can easily adapt it to open your databases in either Shared or Exclusive mode. In a multi-user network environment you will also need a good Record Locking function .. Let me know if you need one.
4) Avoid field->pointers in your index statements

I also added a meter function so you can view the progress of the Indexing .. Consider this code:

Rick Lipkin

Code: Select all  Expand view

#Include "FIveWin.ch"


//-------------------
FUNCTION MAIN()

LOCAL i := 0
LOCAL pPath,cDefa,cFile,nStart

*pPath := hb_dirbase()+"DATA" // does not compile

cFILE := GetModuleFileName( GetInstance() )

// where .exe started from is default directory //

nSTART := RAT( "\", cFILE )
cDEFA  := SUBSTR(cFILE,1,nSTART-1)

SET DEFA to ( cDEFA )

pPath := cDefa+"
\Data"

REQUEST DBFCDX
rddsetdefault ( "
DBFCDX" )

*   REQUEST DBFCDX, DBFFPT
*   RDDSETDEFAULT( "
DBFCDX")


SET EPOCH TO 1990
SET CENTURY ON
SET DATE ITALIAN
SET DELETED ON


*   SET EXCLUSIVE ON
*   SET AUTOPEN OFF

*   for i:= 1 to 1000
*      reindex()
*   next

*   alert(str(i)+CRLF+CRLF+"
Path: "+PPATH+CRLF+CRLF+"Alias in use: "+Alias())
*   dbcloseall()
*   quit

ReIndex( pPath )


RETURN( NIL )


//--------------------------------------------------------------
Static FUNCTION ReIndex( pPath )

Local Saying

FERASE( pPath+"
\CUSTOMER.CDX" )
IF File( pPath+"
\CUSTOMER.CDX" )
   Saying := "
Can not Delete "+ pPath+"\CUSTOMER.CDX"+chr(10)
   Saying += "
Check to see if the File is being Shared"+chr(10)
   MsgInfo( Saying )
   Return(.f.)
Endif

*SELECT 1
*USE (pPath+"
\CUST") EXCLUSIVE NEW  ALIAS "CUSTOMER"   // missing via "DBFCDX" clause

// .DBF AND .CDX Must be named the same !

SELECT 1
Try
  Use (  pPath+"
\CUSTOMER.DBF" ) via "DBFCDX" alias "CUST" EXCL
Catch
  Saying := "
Error opening file "+pPath+"\CUSTOMER.DBF"
  MsgInfo( Saying )
  Return(.f.)
End Try

Pack

IndexMeter( { | oMeter, oText, oDlg, lEnd |            ;
        BuildCust( oMeter, oText, oDlg, @lEnd, 1 ) }     , ;
        ALIAS()+"
.dbf tag First " )

IndexMeter( { | oMeter, oText, oDlg, lEnd |            ;
        BuildCust( oMeter, oText, oDlg, @lEnd, 2 ) }     , ;
        ALIAS()+"
.dbf tag Last " )

IndexMeter( { | oMeter, oText, oDlg, lEnd |            ;
        BuildCust( oMeter, oText, oDlg, @lEnd, 3 ) }     , ;
        ALIAS()+"
.dbf tag Street " )

IndexMeter( { | oMeter, oText, oDlg, lEnd |            ;
        BuildCust( oMeter, oText, oDlg, @lEnd, 4 ) }     , ;
        ALIAS()+"
.dbf tag City " )

IndexMeter( { | oMeter, oText, oDlg, lEnd |            ;
        BuildCust( oMeter, oText, oDlg, @lEnd, 5 ) }     , ;
        ALIAS()+"
.dbf tag State " )

IndexMeter( { | oMeter, oText, oDlg, lEnd |            ;
        BuildCust( oMeter, oText, oDlg, @lEnd, 6 ) }     , ;
        ALIAS()+"
.dbf tag Zip " )

IndexMeter( { | oMeter, oText, oDlg, lEnd |            ;
        BuildCust( oMeter, oText, oDlg, @lEnd, 7 ) }     , ;
        ALIAS()+"
.dbf tag HireDate " )

IndexMeter( { | oMeter, oText, oDlg, lEnd |            ;
        BuildCust( oMeter, oText, oDlg, @lEnd, 8 ) }     , ;
        ALIAS()+"
.dbf tag Married " )

IndexMeter( { | oMeter, oText, oDlg, lEnd |            ;
        BuildCust( oMeter, oText, oDlg, @lEnd, 9) }     , ;
        ALIAS()+"
.dbf tag Age " )

IndexMeter( { | oMeter, oText, oDlg, lEnd |            ;
        BuildCust( oMeter, oText, oDlg, @lEnd, 10 ) }     , ;
        ALIAS()+"
.dbf tag Salary " )

IndexMeter( { | oMeter, oText, oDlg, lEnd |            ;
        BuildCust( oMeter, oText, oDlg, @lEnd, 11 ) }     , ;
        ALIAS()+"
.dbf tag Notes " )

CLOSE DATABASES


RETURN(NIL)

//-------------------------------------------------------------//
FUNCTION BuildCust( oMeter, oText, oDlg, lEnd, nTAG )

   oMeter:nTotal := lastrec()

   // do not use field-> pointers in index statement

   DO CASE
   CASE nTAG = 1
        INDEX on upper(First) TAG First                      ;
              EVAL ( oMeter:Set( recno() ), SysRefresh(), !lEnd )
   CASE nTAG = 2
        INDEX on upper(Last) TAG Last                        ;
              EVAL ( oMeter:Set( recno() ), SysRefresh(), !lEnd )
   CASE nTAG = 3
        INDEX on upper(Street) TAG street                    ;
              EVAL ( oMeter:Set( recno() ), SysRefresh(), !lEnd )
   CASE nTAG = 4
        INDEX on upper(City) TAG City                        ;
              EVAL ( oMeter:Set( recno() ), SysRefresh(), !lEnd )
   CASE nTAG = 5
        INDEX on upper(State) TAG State               ;
              EVAL ( oMeter:Set( recno() ), SysRefresh(), !lEnd )
   CASE nTAG = 6
        INDEX on upper(Zip) TAG Zip                          ;
              EVAL ( oMeter:Set( recno() ), SysRefresh(), !lEnd )
   CASE nTAG = 7
        INDEX on dtos(HireDate) TAG Hiredate                 ;
              EVAL ( oMeter:Set( recno() ), SysRefresh(), !lEnd )
   CASE nTAG = 8
        INDEX on Married TAG Married                         ;
              EVAL ( oMeter:Set( recno() ), SysRefresh(), !lEnd )
   CASE nTAG = 9
        INDEX on Age TAG Age                           ;
              EVAL ( oMeter:Set( recno() ), SysRefresh(), !lEnd )
   CASE nTAG = 10
        INDEX on Salary TAG Salary                           ;
              EVAL ( oMeter:Set( recno() ), SysRefresh(), !lEnd )
   CASE nTAG = 11
        INDEX on upper(Notes) TAG Notes                           ;
              EVAL ( oMeter:Set( recno() ), SysRefresh(), !lEnd )
   ENDCASE

RETURN( NIL )



*        FERASE  (pPath+"
\CUSTOMER.CDX")  // It´s not opened and it has a different name than dbf

*        SELECT 1
*        USE (pPath+"
\CUST") EXCLUSIVE NEW  ALIAS "CUSTOMER"

*        PACK

*        INDEX ON FIELD->LAST TO (pPath+"
\CUSTOMER")    // This line causes error
*        dbcloseall()


*        return nil

//-------------------------------
Function IndexMeter( bAction, cMsg, cTag )

local oDlg, oMeter, oText
local lEnd := .f.
local nVal := 0
local cTitle

IF EMPTY( cTAG )
   cTAG := "
Indexing Please wait"
ENDIF

DEFAULT bAction := { || nil },;
        cMsg := "
Processing...", cTitle := cTAG

DEFINE DIALOG oDlg FROM 5, 5 TO 11, 45 TITLE cTitle ;
       STYLE nOr( WS_POPUP,WS_CAPTION,WS_THICKFRAME )

   @ 0.2, 0.5  SAY oText VAR cMsg SIZE 130, 10 OF oDlg

   @ 1,   0.5  METER oMeter VAR nVal TOTAL 10 SIZE 150, 10 OF oDlg

*  @ 2.5, 9.5  BUTTON "
&Cancel" OF oDlg SIZE 32, 13 ACTION lEnd := .t.

   // This block gets evaluated only the first time the DialogBox is painted !!!
   oDlg:bStart := { || Eval( bAction, oMeter, oText, oDlg, @lEnd ),;
                      lEnd := .t., oDlg:End() }

ACTIVATE DIALOG oDlg CENTERED ;
      VALID lEnd

RETURN(NIL)



/* LOGICAL NETUSE( CDATABASE, LOPENMODE, NSECONDS )

  CHARACTER CDATABASE      - NAME OF DATABASE
  LOGICAL LOPENMODE        - OPEN MODE .T. exclusive  .F. shared
  NUMERIC NSECONDS         - NUMBER OF SECONDS TO WAIT  0 forever

  RETURN  .T. if successful,  .F. if not

  SAMPLE CALL  IF NETUSE( "
CALLS", .F., 5 )
*/

Func NETUSE( CDATABASE, LOPENMODE, NSECONDS, cAlias )

LOCAL FOREVER, RESTART, WAIT_TIME, YESNO

RESTART = .T.
FOREVER = ( NSECONDS := 0 )
YESNO := {"
Yes" , "No"}

DO WHILE RESTART
   WAIT_TIME := NSECONDS
   DO WHILE ( FOREVER .or. WAIT_TIME > 0 )

      IF LOPENMODE
            USE ( CDATABASE ) via "
DBFCDX" EXCLUSIVE

      ELSE
            USE ( CDATABASE ) via "
DBFCDX" SHARED


      ENDIF

      IF .NOT. NETERR()
         RETURN(.T.)
      ENDIF
      INKEY(1)
      WAIT_TIME--

   ENDDO

   * lock failed, ask to continue

   IF MsgYesNo( "
Cannot lock " + CDATABASE + ", retry ?" )
   ELSE
      EXIT
   ENDIF

ENDDO

RETURN(.F.)
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: strange (DOS Error 32) DBFCDX/1006 ¿bug?

Postby StefanHaupt » Tue Feb 14, 2012 7:49 am

John,

I ran your sample several times, I get no error :?: .

Very curious :(

Dos error 5 means "Access denied", maybe it´s a problem with directorty rights or the file is still in use by another process. Check the return value of FErase(), if its not 0 than you can get the error with FError ()

Code: Select all  Expand view
nOk := FERASE  (pPath+"\CUSTOMER.CDX")  // It´s not opened and it has a different name than dbf
IF nOk <> 0
  nError := FError()
ENDIF
 
Last edited by StefanHaupt on Tue Feb 14, 2012 8:11 am, edited 2 times in total.
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: strange (DOS Error 32) DBFCDX/1006 ¿bug?

Postby StefanHaupt » Tue Feb 14, 2012 7:54 am

Rick,

Rick Lipkin wrote:1) The .dbf and .cdx have to be the same name "Customer.dbf", "Customer.Cdx" but you can use any Alias you wish.


No, they can have different names, only this way you can create temporary indexes
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Otto and 92 guests