Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Scan and Update with 2 cursors
Message
From
20/08/2008 17:04:36
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01338981
Message ID:
01340569
Views:
7
>>>>>Hi Beth,
>>>>>
>>>>>Evan's message forced me to re-look at your problem. You need to set your relation the other way around from the table you're updating to the extra cursor. This way I hope it will work.
>>>>>
>>>>Naomi is right...(why am I not surprised)
>>>>You need to create the index in BL, SELECT bl731, SET RELATION INTO bl, and then do the REPLACE ALL.
>>>>
>>>
>>>I'm quite surprised, because it's such a rare occurrence :)
>>
>>Okay, That seems to be working correctly. I am running some more tests, but I found a different update problem to look at.
>>
>>If I need to start another thread, I will.
>>
>>I have 2 tables/cursors being updated by another cursor. 1 cursor needs to be updated matching the c1 and c4 info for one field, and another field needs to not match c1 and/or c4 but match the other 3 fields. Should I build the indexes for the matching fields first and run that replace, then build the index with the not matching (and how would I do that?) and run that replace?
>>
>>Here is the code:
>>
>>SELECT c5
>>SCAN
>>  UPDATE BL731 SET wrkNbrDate=c5.wrkNbrDate ;
>>    WHERE srvcid=c5.srvcid AND ;
>>    UBILLDIST=c5.UBILLDIST AND ;
>>    stdntid=c5.stdntid AND ;
>>    C1 = c5.C1 AND C4 = c5.C4
>>  UPDATE BL731 SET wrkNbrday2=c5.wrkNbrDate ;
>>    WHERE srvcid=c5.srvcid AND ;
>>    UBILLDIST=c5.UBILLDIST AND ;
>>    stdntid=c5.stdntid AND ;
>>    (C1 <> c5.C1 OR C4 <> c5.C4)
>>  UPDATE ctmpc1 SET wrkNbrday2=c5.wrkNbrDate ;
>>    WHERE srvcid=c5.srvcid AND ;
>>    UBILLDIST=c5.UBILLDIST AND ;
>>    C1 = c5.C1 AND C4 = c5.C4
>>ENDSCAN
>>USE IN c5
>>
>>
>>Again, Thanks for the help.
>>Beth
>
>Hi Beth,
>
>Quick answer, because I'm a bit tired. Create an index for matching fields only. Use the same approach Rich suggested but add a condition
>
>FOR FOUND('mySecondCursor') AND myFieldThatShouldNotMatch <> mySecondCursor.MyFieldThatShouldNotMatch

Great, Thanks. I will try this.
Now, go get some sleep! :)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform