Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to make this code faster
Message
De
02/05/2013 14:19:20
Mk Sharma
Shrishti Solutions
Mumbai, Inde
 
 
À
02/05/2013 13:50:07
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01572484
Message ID:
01572531
Vues:
35
First i want to replace all the cuttct.cutt with space(1), cuttct.cuttno with 0 and cuttct.recuttno with 0 in cuttct.dbf

now i want to check if this 'cuttct. takano ' exist in other related dbf files, if exist then replace cuttct.cutt with 'Y', cuttct.cuttno with current Transation number and recuttno with current transaction number.

I am doing like below :
Select cuttct
Scan for not empty(takano)  && binary index on empty(takano) 
      lntakano = takano
       ** Remove Old  reference 
      Replace packed With ' ', packno With 0, recuttno With 0 In cuttct
      If Seek(m.lntakano, 'packtc', 'takano')
         lnpackno	= Iif(Seek(packtc.MASTERID, 'packtm', 'masterid'), packtm.packno, 0)
       ** Update Current reference 
         Replace packed With Iif(m.lnpackno <> 0, 'Y', ' '), packno With m.lnpackno, recuttno with 0  In cuttct
      Else
         lntrnno =	Iif(Seek(m.lntakano, 'cuttm', 'takano'), cuttm.trnno, 0)
       ** Update Current reference 
         Replace packed With Iif(m.lntrnno <> 0, 'Y', ' '), recuttno With m.lntrnno, packno with 0 In cuttct

         lntrnno =	Iif(Seek(m.lntakano, 'cuttm', 'takano1'), cuttm.trnno, 0)
       ** Update Current reference 
         Replace packed With Iif(m.lntrnno <> 0, 'Y', ' '), recuttno With m.lntrnno, packno with 0  In cuttct
      Endif
Endscan
Warm regards,
mk.




>Actually, this would be faster (provided takano is not updated inside the scan)
>
>
>SET ORDER TO Takano
>SEEK SPACE(1)
>SCAN WHILE EMPTY(takano)
>  * update code here
>ENDSCAN
>
>
>>>
>>*- updtakastk.prg
>>****
>>Local lcmasterid, lnavgrec1, lnavgrec2, lnavgrec3, lnpackno, lntakano, lntotrec, lntrnno
>>USEFILE('cuttm')
>>USEFILE('cuttct')
>>USEFILE('packtc')
>>lntakano = 0
>>Select cuttm
>>Set Order To takano
>>Select cuttct
>>Set Order To takano 
>>Select packtm
>>Set Order To MASTERID
>>Select packtc
>>Set Order To takano
>>Select cuttct
>>
>>Wait Window 'Working... Please Wait...' At Srows() / 2, Scols() / 2  Nowait
>>
>>Select cuttct
>>Scan for not empty(takano)  && might build a binary index on empty(takano) depending on data size and distribution
>>
>>   lntakano = takano
>>   &&If Not Empty(m.lntakano)
>>      **    Below code taking Maximum time in Coverage result
>>      && Replace packed With ' ', packno With 0, recuttno With 0 In cuttct
>>      If Seek(m.lntakano, 'packtc', 'takano')
>>         &&lcmasterid	= packtc.MASTERID
>>         lnpackno	= Iif(Seek(packtc.MASTERID, 'packtm', 'masterid'), packtm.packno, 0)
>>         **    Below code taking Maximum time in Coverage result
>>         Replace packed With Iif(m.lnpackno <> 0, 'Y', ' '), packno With m.lnpackno, recuttno with 0 && In cuttct
>>      Else
>>         && on first glance always overwritten ??? 
>>         && lntrnno =	Iif(Seek(m.lntakano, 'cuttm', 'takano'), cuttm.trnno, 0)
>>         && Replace packed With Iif(m.lntrnno <> 0, 'Y', ' '), recuttno With m.lntrnno In cuttct
>>
>>         lntrnno =	Iif(Seek(m.lntakano, 'cuttm', 'takano1'), cuttm.trnno, 0)
>>         Replace packed With Iif(m.lntrnno <> 0, 'Y', ' '), recuttno With m.lntrnno, packno with 0 && In cuttct
>>      Endif
>>   &&Endif
>>Endscan
>>Wait Clear
>>
>>
>>setting up relations in advance might not much/more help in this case, as only 1 seek is needed fo each record.
>>do NOT use brute force to clean a record first. unrolling the 2 iif into separate branches of replace might be still better
>>if you can be ****certain**** that cuttm/packno are always #0- test.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform