Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insert while scan
Message
De
26/03/2001 23:40:31
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00488698
Message ID:
00488824
Vues:
10
>>You have a bit of a conflict here. You're expecting to use SCAN to process ALL records in the Employee table with an ID of 1234. SCAN positions the record pointer for you. However, the INSERT - SQL command positions the record pointer at the newly created record. The location of that new record will depend on any index order being set. For example, if your master tag is on EmpID ascending, and you use a lower number for NewEmpID, then the record pointer will be positioned ABOVE your original 1234 record. SCAN then will find the same record again and repeat the process ad infinitum. One way around this would be to temporarily set Employee to "natural" order for the duration of the SCAN:
select employee
>><b>SET ORDER TO 0 IN Employee</b>
>>scan for employee.empid=1234
>>  insert into employee(empid,task);
>>     values (NewEmpId,employee.task)
>>endscan
>
>
>Ahhh! Ok... What about this...
>(btw - NewEmpId would never match the original. 1234 in this case)
>
>
>NewEmpID=5678
>select employee
>scan for employee.empid=1234
>  currec=recno()
>  insert into employee(empid,task);
>     values (NewEmpId,employee.task)
>  goto currec
>endscan
>
That should be fine. Is there more than 1 instance of EmpID = 1234? If not, using SEEK, SEEK() or LOCATE might be more appropriate.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform