Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Check duplicate in table buffered mode?
Message
 
 
À
18/10/1997 14:30:48
Juan Kh
Dataprop Technologies
Sungai Petani, Malaisie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00055264
Message ID:
00055344
Vues:
27
>>How do I check for duplicate in table buffered mode? Do I have to do a 'COPY TO' a temp table before I check? It seems troublesome.
>>
>>This table buffering is really killing my time. Can someone please comment?
>
>Hi,
>
>You have two situations:
>
>1) You are trying to search for a duplicate which is already in the table.
>2) You are trying to search for a duplicate which you have just entered into the bufferedd table (the one that has RECNO() less than 0)
>
>If you are dealing with case #1, try to USE YourTable IN 0 AGAIN ALIAS AnotherName. Issue a SEEK command (provided your search is on an indexed field)
>
>For case #2, try the following code (may be slow for big table)
>
>
>llRetVal = .T.
>SELECT YourTable
>SET ORDER TO YourIndexedField ASCENDING && Seek from TOP
>lnRecNo = RECNO() && Remember where you are
>cKey = YourValueToSeek
>IF SEEK(cKey)
> IF lnRecNo RECNO() && Found and is not where I was??
> && It is duplicate, Do something.
> llRetVal = .F.
> ENDIF
>ENDIF
>
>*-- If not found from the TOP, try to seek from the bottom
>IF llRetVal
> SELECT YourTable
> SET ORDER TO YourIndexedField DESCENDING && Seek from BOTTOM
> lnRecNo = RECNO()
> cKey = YourValueToSeek
> IF SEEK(cKey)
> IF lnRecNo RECNO()
> && It is duplicate, Do something.
> llRetVal = .F.
>
> ENDIF
> ENDIF
>ENDIF
>
>
>juan

Juan.
Your code looks pretty good but can you explain why you need to seek both from the top and from the bottom? In addition, can your routine be made more generic (use it as a function so you can call from other areas) by using the YourTable again in another area with different alias?

Just wondering.
John.
It's "my" world. You're just living in it.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform