Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Scan and Update with 2 cursors
Message
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:
01340442
Views:
11
Beth,

PMFJI -- and I'm not sure this will help, but it's worth a try (or maybe a TRY...CATCH ???? -bg- )

If you're at the end of a file, the REPLACE command doesn't work and doesn't TELL you it doesn't work. This could happen if the SET RELATION doesn't find a match to the current row in BL -- you'd be at the end of file in the related table.

Try adding a LOCATE statement right after your SET RELATION TO command, and then check for EOF() in both tables. That will reposition all the pointers and should remove any issues with the REPLACE. Do *not* use a GO TOP instead of LOCATE -- it's not optimizable and causes other issues if a filter is present.

HTH,
Evan


>>>Hi All,
>>>
>>>I have a program, where I collect info into 1 cursor (fstcursor), then use that cursor to update a different cursor (mncursor). At the moment, I have to do a scan of fstcursor, and update mncursor within that scan. With 100,000+ records, this takes a while. Is there a better way to do this?
>>>
>>>I have a lot of these updates in the program, plus some fors. At the moment, the program takes well over 16 minutes to run (still has not finished this run) with 100,000 to 110,000 records.
>>>
>>>I thought maybe getting rid of scans might help, but I wanted to ask you, UT members, first. :)
>>>
>>>Thanks,
>>>Beth
>>
>>I don't think there's an SQL option to update the cursors since UPDATE FROM is not in VFP 8.
>>
>>But 16 minutes seems excessive for that many records. When I have this sort of situation I would usually do something like
>>
>>SELECT mnCursor
>>INDEX ON expression TAG temp
>>SELECT fstCursor
>>SET RELATION TO expression INTO mnCursor
>>REPLACE ALL field WITH fstCusor.field...... FOR FOUND('fstCusror')
>>
>>Can something like that be adapted to your situation?
>Okay, I tried to adapt this to my situation, and this is what I came up with:
>
>SELECT srvcid, UBILLDESC, stdntid, SUM(wrkRealCost) AS wrkRealCost, ;
>  C1, C4 ;
>  FROM BL731 WHERE wrkStatus<>ACTIVE ;
>  GROUP BY srvcid, C1, C4, UBILLDESC , stdntid ;
>  INTO CURSOR BL
>
>SELECT BL731
>INDEX ON srvcid + UBILLDESC + BINTOC(stdntid) + STR(C1) + STR(C4) TAG mainmix
>SELECT BL
>SET RELATION TO srvcid + UBILLDESC + BINTOC(stdntid) + STR(C1) + STR(C4) INTO BL731 IN BL
>
>REPLACE wrkAdjust WITH BL.wrkRealCost  ;
>  , wrkRealCost WITH BL731.wrkRealCost + BL.wrkRealCost ;
>  ALL FOR FOUND('bl') IN BL731
>
>USE IN "BL"
>
>and I get no records updated correctly. :(
>did I miss something in the relation, or setting up the replace command?
>C1 and C4 numerical amounts that represent money.
>
>Thanks for you help,
>Beth
Evan Pauley, MCP
Positronic Technology Systems LLC
Knoxville, TN

If a vegetarian eats vegetables, what does a humanitarian eat?
Previous
Reply
Map
View

Click here to load this message in the networking platform