Information générale
Catégorie:
Codage, syntaxe et commandes
>Beginner question -
>
>I'm trying to locate records in one table that have an exact match for certain fields in another table.
>
>LOCATE FOR fields and conditions works, but is extremely slow.
>
>What I am trying to code is based on the following:
>
>SCAN first table
>Get selected fields from first table into variables, including lcLname
>SEEK lcLname in second table
>if found, compare remaining fields
>if all fields matched, process
>if no match, re-SEEK lcLname and repeat until no more records match lcLname
>ENDSCAN
>
>I think want some variation of DO WHILE for FOUND() = .T., but I haven't been able to work out the syntax when the SEEK is inside the DO WHILE loop.
>
>Can you straighten me out?
>
>Thanks,
>Neil Preston
Neil,
Try something like this:
<\PRE>
SELECT FirstTable
SCAN
IF NOT SEEK(FirstTable.LName,"SecondTable")
LOOP
ENDIF
SELECT SecondTable
SCAN WHILE LName = FirstTable.LName
llAllFieldsMatch = .T.
FOR i 1 to lnNumberOfFieldsToCompare
IF FIELDS VALUES DO NOT MATCH
llAllFieldsMatch = .F.
EXIT
ENDIF
ENDFOR
IF llAllFieldsMatch
EXIT
ENDIF
ENDSCAN
IF llAllFieldsMatch
PROCESS
ENDIF
ENDSCAN
Précédent
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