Page 1 of 1

problema abriendo dbf con alias

Posted: Mon Nov 08, 2021 9:01 pm
by rterraz
hola amigos
quiero abrir una dbf con un alias y me da un error de apertura, estoy casi seguro que es por los indices que usa
Hace tiempo Mr.Rao habia explicado cual era el error en la construcción del indice que ocasionaba este problema, creo que eso ocurre cuando se incluye en la construccion del indice el nombre de la base de datos...alguien se acuerda de esto ?
abrazo

Re: problema abriendo dbf con alias

Posted: Mon Nov 08, 2021 9:40 pm
by karinha
Funciona de 1000.

Code: Select all | Expand


#Include "Fivewin.Ch"

// LOCAL lPack      := .T.

FUNCTION Indexar()


   AEVAL(DIRECTORY( "CADGRUPO.cdx" ),{ |aFILE| FERASE(aFILE[F_NAME]) } )

   USE CADGRUPO NEW EXCLUSIVE ALIAS CADGRUPO

   IF lPack = .T.  // checkbox en dialogo
      PACK
   ENDIF

   oMeter1:nTotal = RecCount()

   INDEX ON VAL(Field->GRUPOCOD) TAG GRUPOCOD TO CADGRUPO                 ;
         FOR .NOT. DELETED()                                              ;
         EVAL ( oMeter1:Set( RecNo() ), CursorWait(), SysRefresh() )      ;
         EVERY 10

   INDEX ON Field->GRUPODESCR TAG GRUPODESCR TO CADGRUPO                  ;
         FOR .NOT. DELETED()                                              ;
         EVAL ( oMeter1:Set( RecNo() ), CursorWait(), SysRefresh() )      ;
         EVERY 10

   INDEX ON Field->GRUPONOME TAG GRUPONOME TO CADGRUPO                    ;
         FOR .NOT. DELETED()                                              ;
         EVAL ( oMeter1:Set( RecNo() ), CursorWait(), SysRefresh() )      ;
         EVERY 10

   CLOSE DATABASE

   AEVAL(DIRECTORY( "CADORSER.cdx" ),{ |aFILE| FERASE(aFILE[F_NAME]) } )

   USE CADORSER NEW EXCLUSIVE ALIAS CADORSER

   IF lPack = .T.
      PACK
   ENDIF

   oMeter1:nTotal = RecCount()

   INDEX ON VAL(Field->TPSERCOD) TAG TPSERCOD TO CADORSER                 ;
         FOR .NOT. DELETED()                                              ;
         EVAL ( oMeter1:Set( RecNo() ), CursorWait(), SysRefresh() )      ;
         EVERY 10

   INDEX ON Field->TPSERNOME TAG TPSERNOME TO CADORSER                    ;
         FOR .NOT. DELETED()                                              ;
         EVAL ( oMeter1:Set( RecNo() ), CursorWait(), SysRefresh() )      ;
         EVERY 10

   CLOSE DATABASE

   //... continua.

RETURN NIL

FUNCTION APERTURA_BANCOS()

   PUBLIC DBCADGRUPO // asi para todos.

   IF NETERR()

      MsgStop( "ERRO DE REDE. IMPOSSÍVEL ABRIR OS BANCOS DE DADOS", ;
               "Atençao, Erro de Rede. Verifique o Servidor...   " )

      RETURN NIL

   ENDIF

   HB_GCALL( .F. )

   USE CADGRUPO NEW SHARED ALIAS CADGRUPO
   GO TOP

   DBCADGRUPO := ALIAS()

   //... continua...

RETURN NIL
 


https://imgur.com/UQxRdAp

Image

Regards, saludos.

Re: problema abriendo dbf con alias

Posted: Mon Nov 08, 2021 9:42 pm
by karinha

Code: Select all | Expand


SELECT( DBCADGRUPO )
GO TOP
 


Regards, saludos.

Re: problema abriendo dbf con alias

Posted: Thu Nov 11, 2021 8:53 pm
by nageswaragunupudi
Never build an index like this:

Code: Select all | Expand


INDEX ON CUSTOMER->CITY ....
 


When you open the dbf CUSTOMER with another alias name, the RDD can not find the alias CUSTOMER and you get an error.
Unfortunately if there is another DBF open with the alias "CUSTOMER" in another areay, your index will run on another area

Best practice is not to use "->" while building indexes.

Recommended:

Code: Select all | Expand



field CITY,STATE, ....

INDEX ON CITY TAG CITY
INDEX ON STATE TAB STATE
...
 


Note:
field ...
is a declaration like local, static

Re: problema abriendo dbf con alias

Posted: Thu Nov 11, 2021 11:47 pm
by rterraz
Thanks you Mr.Rao !!!