Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Update Master Table With Temp Table...
Message
De
26/04/2006 16:21:09
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
26/04/2006 13:08:04
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01116712
Message ID:
01116847
Vues:
19
This message has been marked as a message which has helped to the initial question of the thread.
Hi Marc

Untested code!

>What about this to update master table... is this a good technique (fast and efficient)?
>

If you have an index on cKeyField in cCursorName
m.lcReplace = ""
FOR m.lnCount = 1 TO FCOUNT(m.cCursorName)
  m.lcFieldName = FIELD(m.lnCount,m.cCursorName)
  m.lcReplace = m.lcReplace + m.lcFieldName + " WITH " + ;
    + m.cCursorName + "." + m.lcFieldName + ","
ENDFOR m.lnCount
*Drop the last comma.
m.lcReplace = LEFT(m.lcReplace,LEN(m.lcReplace)-1)

SET ORDER TO (m.cKeyField) IN (m.cCursorName)
SELECT (m.cTableName)
SET RELATION TO (m.cKeyField) INTO (m.cCursorName)
REPLACE ALL &lcReplace. IN (cTableName)
The code you have is replacing one field at a time per locate inside a scan. SET RELATION keeps the two tables in synch. REPLACE ALL does the scan. &lcReplace specifies the source and target fields.

>SELECT (cCursorName)
>SCAN
> SELECT (cTableName)
> LOCATE FOR EVALUATE(cTableName + "." + cKeyField) = EVALUATE(cCursorName + "." + cKeyField)
> IF FOUND(cTableName)
> BEGIN TRANSACTION
> FOR nCount = 1 TO FCOUNT(cCursorName)
> cFieldName = FIELD(nCount, cCursorName) REPLACE (cFieldName) WITH EVALUATE(cCursorName + "." + cFieldName)
> NEXT
> END TRANSACTION
> ENDIF
> SELECT (cCursorName)
>ENDSCAN
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform