Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SET RELATION TO to update a cursor
Message
 
 
À
15/08/2019 16:39:17
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01670104
Message ID:
01670109
Vues:
44
Yes, the change you made to my code works.
Thank you!

>>Hi,
>>
>>I found a problem when updating one cursor from another, using SET RELATION approach. The names are:
>>TARGET cursor is the one being updated
>>SOURCE cursor is the one from which the data is taken for update
>>
>>
>>CREATE CURSOR TARGET (pk_field i, task_no n(6,0), week_fr n(6,0), week_to n(6,0), week_no n(6,0), employee c(10) )
>>INSERT INTO TARGET (pk_field, task_no, week_fr, week_to, week_no, employee ) VALUES ;
>>	(1, 10, 1, 52, 4, '')
>>INSERT INTO TARGET (pk_field, task_no, week_fr, week_to, week_no, employee ) VALUES ;
>>	(2, 10, 1, 52, 4, '')
>>INSERT INTO TARGET (pk_field, task_no, week_fr, week_to, week_no, employee ) VALUES ;
>>	(3, 10, 1, 52, 4, '')
>>
>>SELECT TARGET
>>INDEX ON pk_field TAG pk_field
>>SET ORDER TO TAG pk_field
>>
>>*--  create SOURCE cursor
>>CREATE CURSOR SOURCE (pk_field i, task_no n(6,0), week_fr n(6,0), week_to n(6,0), week_no n(6,0), employee c(10) )
>>
>>INSERT INTO SOURCE (pk_field, task_no, week_fr, week_to, week_no, employee ) VALUES ;
>>	(5, 10, 1, 52, 4, '')
>>INSERT INTO SOURCE (pk_field, task_no, week_fr, week_to, week_no, employee ) VALUES ;
>>	(2, 10, 1, 52, 23, '')
>>
>>SELECT TARGET
>>SET RELATION TO PK_FIELD INTO SOURCE
>>GO TOP 
>>replace week_no WITH SOURCE.week_no, week_fr WITH SOURCE.week_fr, week_to WITH SOURCE.week_to  all
>
>
>
>REPLACE ALL week_no WITH SOURCE.week_no, week_fr WITH SOURCE.week_fr, week_to WITH SOURCE.week_to FOR NOT EOF('source')
>
>
>
>>BROWSE TITLE "TARGET after update" 
>>
>>
>>Note that above, because the SOURCE has fewer records than a TARGET (real case), the last record
>>of the TARGET is set to 0 (zero) all fields.
>>
>>Is this how the code is supposed to work or I am doing something wrong?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform