Strange seek behaviour

Strange seek behaviour

Postby Wanderson » Mon Nov 28, 2016 3:47 pm

Hi,

I have a file with many records with 3 fields
NOME C (45)
UF C (45)
CODIGO C (7)

A index TAG CIDADEUF with key NOME+UF

in this file i have 2 records in especific

NOME = SAO PAULO
UF = SP
CODIGO = 1111111

and another

NOME = EMBU
UF = SP
CODIGO = 2222222

If a seek the second record the result is false, but if a seek first and other many records returns true.
Seek dont found this registry in especific. I try to delete and insert again and nothing, try to reindex and nothing.
Any Idea?
Thanks.
Wanderson
 
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Re: Strange seek behaviour

Postby karinha » Mon Nov 28, 2016 5:01 pm

Wanderson:

cambie/troque,

UF C (45)

Por:

UF C(2)

SP, RJ, MG, PE, PI, etc.

Se der um SEEK por código, use o VAL para indexar, pois você disse que era C(7) no código.

Saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7813
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Strange seek behaviour

Postby Wanderson » Mon Nov 28, 2016 5:41 pm

karinha wrote:Wanderson:

cambie/troque,

UF C (45)

Por:

UF C(2)

SP, RJ, MG, PE, PI, etc.

Se der um SEEK por código, use o VAL para indexar, pois você disse que era C(7) no código.

Saludos.


Desculpe karinha, digitei errado é 2 mesmo. Estranho demais, todas as outras cidades encontra mas essa sempre dá falso no seek, já deletei inseri novamente, indexei e nada. Creio ser algum bug. Obrigado.
Wanderson
 
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Re: Strange seek behaviour

Postby karinha » Mon Nov 28, 2016 6:02 pm

Veja se ajuda:

Code: Select all  Expand view

#Include "FiveWin.ch"
#Include "Ord.Ch"

REQUEST HB_LANG_PT
REQUEST HB_CODEPAGE_PT850

ANNOUNCE RDDSYS
REQUEST OrdKeyNo, OrdKeyCount, OrdCreate, OrdKeyGoto
REQUEST DBFCDX, DBFFPT

FUNCTION Main()

   LOCAL cAlias, cSeek := "2222222"

   RDDSETDEFAULT("DBFCDX")

   HB_LANGSELECT( 'PT' )         // Default language is now Portuguese
   HB_SETCODEPAGE( "PT850" )

   IF .NOT. FILE( "WSEEK.DBF" )

      DbCreate( "WSEEK.DBF", { { "CODIGO",     "C", 07, 00 }, ;
                               { "NOME",       "C", 45, 00 }, ;
                               { "UF",         "C", 02, 00 } } )

      DbCloseAll()  

   ENDIF

   USE WSEEK NEW EXCLUSIVE
   GO TOP

   IF EOF()

      APPEND BLANK

      RLOCK()

      REPLACE CODIGO WITH "1111111"
      REPLACE NOME   WITH "SAO PAULO"
      REPLACE UF     WITH "SP"

      COMMIT
      UNLOCK

      APPEND BLANK

      REPLACE CODIGO WITH "2222222"
      REPLACE NOME   WITH ALLTRIM( "EMBU     " )
      REPLACE UF     WITH "SP"

      COMMIT
      UNLOCK

   ENDIF

   // DELE ALL FOR RECNO() >= 10

   //   IF .NOT. FILE( "WSEEK.CDX" )

      INDEX ON VAL(Field->CODIGO) TAG CODIGO TO WSEEK                   ;
            FOR !DELETED()                                              ;
            EVERY 10

      INDEX ON Field->NOME                 TAG NOME      TO WSEEK       ;
            FOR !DELETED()                                              ;
            EVERY 10

      INDEX ON Field->NOME + Field->UF     TAG NOMEUF    TO WSEEK       ;
            FOR !DELETED()                                              ;
            EVERY 10

      DBCLOSEALL()

   //   ENDIF

   USE WSEEK INDEX WSEEK NEW SHARED

   SET ORDER TO 01

   GO TOP

   cAlias := ALIAS()

   SEEK VAL( cSeek )

   IF FOUND()

      BROWSE()

   ELSE

      ? [NOT FOUND() ], cAlias

   ENDIF

RETURN NIL
 


João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7813
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 109 guests