Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SCAN ENDSCAN with INSERT statment...
Message
De
01/12/2004 04:20:41
 
 
À
30/11/2004 14:17:15
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
OS:
Windows XP SP1
Divers
Thread ID:
00965286
Message ID:
00965993
Vues:
10
>>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform