Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Update field
Message
De
04/08/2006 17:21:44
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Versions des environnements
Visual FoxPro:
VFP 8
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01143071
Message ID:
01143097
Vues:
8
>>>>Seems I am too silly today ;(
>>>>The question is:
>>>>May I update one table from another without SCAN ? (like localview does it)
>>>>
>>>>code example
>>>>
>>>>select * from table1 into cursor _tmp READWRITE
>>>>
>>>>Then I modify one field in _tmp cursor .. and then I want to update Table1 with new modifications..
>>>>
>>>>SELECT _tmp
>>>>SCAN ALL
>>>>       SELECT table1
>>>>       LOCATE FOR table1.id = _tmp.id
>>>>       IF FOUND()
>>>>            replace table1.field1 with _tmp.field1
>>>>       ENDIF
>>>>SELECT _tmp
>>>>ENDSCAN
>>>>
>>>>
>>>>Maybe it possible to make for one command line? (I do not mean tableupdate and view)
>>>>
>>>>Sorry for this stupid question
>>>>Denis
>>>
>>>
UPDATE Table1 SET table1.field1 = _tmp.field1 FROM _tmp WHERE table1.id = _tmp.id
>>
>>
>>Hi Vladimir,
>>Right.. I thought same ;) but seems I realy silly today... or.... in my case - its update only 1 record in Table1 for current _tmp.id value. Whats wrong?
>
>Denis,
>table1 and cursor _tmp has equal number of records.
>Is Id field unique? Is so it's normal.
>or I misunderstood your question.
>Your code
>
LOCATE FOR table1.id = _tmp.id
>IF FOUND()
>   replace table1.field1 with _tmp.field1
>ENDIF
Hi,
Yes. id is unique. but UPDATE... WHERE table1.id = _tmp.id update only one record

example
table1 _tmp (>> current rec)
=========== =========
1 Denis >> 1 Denis1
2 Vladimir 2 Vladimir
3 Michael 3 Ex Michael

After update but I want
table1
1 Denis1 1 Denis1
2 Vladimir 2 Vladimir
3 Michael 3 Ex Michael

?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform