FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Strange seek behaviour
Posts: 332
Joined: Thu Nov 17, 2005 09:11 PM
Strange seek behaviour
Posted: Mon Nov 28, 2016 03: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.

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Strange seek behaviour
Posted: Mon Nov 28, 2016 05: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
Posts: 332
Joined: Thu Nov 17, 2005 09:11 PM
Re: Strange seek behaviour
Posted: Mon Nov 28, 2016 05: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.
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Strange seek behaviour
Posted: Mon Nov 28, 2016 06:02 PM
Veja se ajuda:

Code (fw): Select all Collapse
#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

Continue the discussion