Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Copy fields
Message
 
À
26/11/2004 14:15:44
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00965005
Message ID:
00965027
Vues:
13
[ADDITIVE] && See HELP for SET RELATION command. it just in case You have additional relations between theese two tables, If You don't do not put ADDIDVE in command i.e.
YUou have old relations between tables
SET RELATION TO Key INTO Table2 ADDITIVE
If You Don't
SET RELATION TO Key INTO Table2 && noting else
about the Key, no That is no Primary Key, That is field on what theese two tables correspond each other and YES You must have an index (not necessary to be PRIMARY)
i.e. You have field in table A named Code, Id, or something else, let say it is ID, In Table2 (nan) You must have a field that contains exatly the same data (not necessary that all Ids in Table2 are in Table A)
i.e.
CREATE CURSOR Table1 (Id  C(10), Field1 C(20), Field2 C(20))
CREATE CURSOR Table2 (Id1 C(10), Field1 C(20), Field2 C(20), Field3 N(15,2))
tosmall = 0
FOR nCikle = 1 TO 300
    IF nCikle < 151
       INSERT INTO Table1 VALUES (TRANSFORM(nCikle), "Record"+TRANSFORM(nCikle), "Other"+TRANSFORM(nCikle+5))
    ENDIF
    IF nCikle < 160
       to_replace = nCikle
    ELSE
       to_replace = nCikle  - tosmall
       tosmall    = tosmall + 1
    ENDIF
    INSERT INTO Table2 VALUES (TRANSFORM(to_replace), SYS(2015), SYS(2015), nCikle)
ENDFOR
SELECT Table1
INDEX ON Id TAG Table1
SELECT Table2
GO TOP
BROWSE NORMAL
SET RELATION TO Id1 INTO Table1
REPLACE ALL Field1 WITH Table1.Field1,;
            Field2 WITH Table1.Field2,;
            Field3 WITH Table1.Field3;
FOR .NOT. EMPTY(Table1.Id) && Just in case You have no matching records
SET RELATION OFF
GO TOP
BROWSE NORMAL
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform