Information générale
Catégorie:
Codage, syntaxe et commandes
>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
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement