Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SET RELATION TO to update a cursor
Message
From
15/08/2019 16:39:17
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01670104
Message ID:
01670106
Views:
53
>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?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform