Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insert while scan
Message
De
28/03/2001 12:26:27
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00488698
Message ID:
00489505
Vues:
8
>>>
>>>NewEmpID=5678
>>>select employee
>>>scan for employee.empid=1234
>>>  currec=recno()
>>>  insert into employee(empid,task);
>>>     values (NewEmpId,employee.task)
>>>  goto currec
>>>endscan
>>>
>>
>>Unless you are doing some other processing within the SCAN...
>>I think the following approach gives an equivalent result. How about
>>
>>
>>SELECT 5678 AS empid,task FROM employee;
>>  WHERE empid=1234;
>>  INTO CURSOR curTemp
>>
>>SELECT employee
>>APPEND FROM DBF('curTemp')
>>
>
>Is there a reason your method would be better?

Cause I thought of it???? <g>

FW(Little)IW

My impression is that taking things out of loops and processing the entire file in one command is usually faster and cleaner. For example
REPLACE ALL myField WITH somevalue FOR condition
rather than
SCAN FOR condition
     REPLACE myField WITH somevalue
ENDSCAN
By taking all the extra record changing out of the equation I think my method will be significantly faster. Of course, significantly faster is a relative term and a large percentage improvement may not be meaningful.

I used big (200000 records) tables with lots of replacements. My tests showed a drop in processing time (5.14 seconds vs 3.83 seconds).

My .02 cents...............Rich

Oh, something else. I don't have VFP 7 or SQL Server. Could one of the real gurus tell me if
INSERT INTO employee ;
       (SELECT 5678 AS empid,task FROM employee e2;
         WHERE e2.empid=1234)
be a legal statement in either???
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform