Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SCAN ENDSCAN with INSERT statment...
Message
From
01/12/2004 04:20:41
 
 
To
30/11/2004 14:17:15
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
OS:
Windows XP SP1
Miscellaneous
Thread ID:
00965286
Message ID:
00965993
Views:
11
>>This code is kind of 'asking for trouble' :)
>>U can achieve much cleaner solution, by inserting new records into temporary cursor of the same structure while scaning original table and then simply dump them in after main scan is done.
>>
>>so code cld look something like this ;
>>
>>
>>SELECT MyTable
>>local aStru(1)
>>afields(aStru)
>>create cursor tmpTable from array aStru
>>SELECT MyTable
>>go top
>>scan
>>   .
>>   scatter to laArray
>>   .
>>   do case
>>
>>     case ...
>>     insert into tmpTable from array laArray
>>
>>     case ...
>>
>>   endcase
>>   .
>>endscan
>>.
><b>append from dbf("tMyTable")     && need dbf() here</b>
>>.
>>
>>
>>
>
>The bolded is the correction.
>
>But if I understand well, the original problem was that the appended >records weren't processed at all. That'd be better solved with what Sergey >proposed, to save the current record's recno() before inserting, and GoTo >it afterwards.

Yes, You are right I overlooked that part. The way I proposed they wld not be processed either, But nor wld the old records, as pointer wld jump to eof and mess up scan/endscan . (Sergey pointed it out I think).

My aim was to suggest keeping things clean, as scan/processing and adding into the same alias is not something i particularly like :)

As this is an old procedure I agree, Sergey's solution
wld be much easier way out, provided that index order is off.

As for my metacode 'bug', correct wld be ;
append from dbf("tmpTable")
as alias 'tMyTable' is nowhere to be found! :)

Cheers :)
Srdjan
*****************
Srdjan Djordjevic
Limassol, Cyprus

Free Reporting Framework for VFP9 ;
www.Report-Sculptor.Com
Previous
Reply
Map
View

Click here to load this message in the networking platform