Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SCAN ENDSCAN with INSERT statment...
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
OS:
Windows XP SP1
Miscellaneous
Thread ID:
00965286
Message ID:
00965299
Views:
8
Sorry Sergey,

I left out some important pieces of code. I replied to Elmer with the missing code.

Thanks for your input. I do appreciate it!

>Hi Will,
>
>The code you posted couldn't work properly at all. When new record is insered record poinre is moved to it. After that end of SCAN loop performs SKIP to move to the next record which lends record pointer on EOF. It means that not only new record wouldn't be processed by this code but any "old" records after INSERT INTO wouldn't be processed eother. You can save recor pointer before INSERT INTO and restore after if you want to process all recirds (old and new).
SELECT MyTable
>SCAN
>  lnRecno = RECNO()
>...
>    INSERT INTO MyTable FROM ARRAY laArray
>...
>  GOTO (lnRecno)
>ENDSCAN
>
If table has INDEX order set before processins than it became even more complicated.
>
>>While investigating some scary VFP code for a data production problem I came across the following :
>>
>>
>>SELECT MyTable
>>SCAN
>>  SCATTER TO laArray
>>  FOR x=1 TO 9
>>    DO CASE
>>      CASE x=1 AND ...
>>        laArray[22]=laArray[22]+"SA"
>>        INSERT INTO MyTable FROM ARRAY laArray
>>
>>      CASE X=2 AND ...
>>        laArray[22]=laArray[22]+"GA"
>>        INSERT INTO MyTable FROM ARRAY laArray
>>
>>      CASE x=3 AND ...
>>        laArray[22]=laArray[22]+"MF"
>>        INSERT INTO MyTable FROM ARRAY laArray
>>
>>    ENDCASE
>>  ENDFOR
>>
>>*** Process MyTable
>>
>>ENDSCAN
>>
>>
>>The cause of the problem is the records INSERTED during the scan are never processed. Walking through the code in the DEBUGGER shows the MyTable hits EOF when on the record that was the last record when the SCAN started. I could reproduce the problem VFP 8 and VFP 9 earlier this week at the office. Support is upgrading production code to VFP 8.0 so I thought it was a upgrade problem but they assured me the problem began BEFORE the upgrade was put in place. Well tonight I just ran the same code in VFP 6 SP5 thinking it would work but that is not the case. Walking through the DEBUGGER I get the same results as I do in VFP 8 and VFP 9.
>>
>>The troubling part is this code has been running and working in a high-volume, production environment since 2000. The problem started on November 8th and production support has not been able to solve the problem so I was asked me to investigate.
>>
>>Maybe VFP 6.0 worked before installing the VFP 8.0 runtimes? I don't know all the update details of when, what and who yet.
>>
Heavy Metal Pedal - click with care
Previous
Reply
Map
View

Click here to load this message in the networking platform