Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Replacing one field with certain records in two tables
Message
De
21/03/2002 02:30:21
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00634995
Message ID:
00635350
Vues:
17
>Thanks Gregory, your solution is perfect!
>May I ask another quick question? I have a command button on a form that appends records from one table into another and the records being appended all have the same date. Can you help with an IF....EndIf statement that will prevent the records from being appended if the dates for the records are already there (because the user may have previously performed the append but is trying to do it again and I don't want the same names with the same dates appended twice).
>
>The sql I am using now is:
>SELECT table2
>Append From table1
>
>Thanks again!
>Max

Max,

you may give this a try

You need an index on table2 to check whether a record has already been appended
&& probably the fastest
select Table2
append from Table1 ;
    all for !IndexSeek(table1.field1+Table1.Field2, .F., 'Table2', 'TagInTable2')
or
&& bit slower, but you can add a progress bar in the loop
Select Table1
scan all
    pk = Table1.field1 + Table1.Field2 + ...
    if( !seek(pk, 'Table2', 'TagInTable2') )
       insert into Table2 (fld1, fld2, ..) values( table1.fld1, table1.fld2, ...)
              
    endif
endscan
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform