Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Appending problem
Message
De
18/07/2008 14:44:50
 
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
Divers
Thread ID:
01332359
Message ID:
01332378
Vues:
14
This message has been marked as a message which has helped to the initial question of the thread.
>I want delete records of my emails.dbf, and copy them to a backup table called emails_ex.dbf
>
>In method keypress of column of my grid with belongs to emails.dbf
>
>*************************************************
>LPARAMETERS nKeyCode, nShiftAltCtrl
>
> IF nKeyCode = 7
>SELECT emails
> STORE emails.cod TO esteCOD
>
>SELECT emails_ex
> APPEND FROM emails FOR emails.cod = esteCOD
>
I think this should be
APPEND FROM emails FOR cod = esteCOD
You can also try
INSERT INTO emails_ex SELECT * FROM emails WHERE cod = esteCOD
Note that this makes the explicit assumption that the two tables have identical structures. If they don't then you could try
SELECT * FROM emails WHERE cod = esteCOD INTO CURSOR curTemp
SELECT emails_ex
APPEND FROM DBF('curTemp')
>SELECT emails
> LOCATE FOR emails.cod = esteCOD
> DELETE FOR emails.cod = esteCOD

The LOCATE is unnecessary since the default scope for your DELETE command is ALL. However, if the table is order by COD you could
LOCATE FOR emails.cod = esteCOD
DELETE WHILE emails.cod = esteCOD
Even better you could simply
DELETE FROM emails WHERE cod = esteCOD
>
>
> thisform.refresh
> ENDIF
>******************************************************
>
>The problems
>
>It is appending all records from emails.dbf and not only the selected record
>in the grid line
>
>After deleting it does not go to the line I was in, but go to the end of the grid,
>even if I assign: LOCATE FOR emails.cod = esteCOD

Doing the LOCATE won't get you anything since you have deleted those records. You should probably just do a GO TOP.

If the table is ordered by COD then you could also try
LOCATE FOR cod > esteCOD
which should put you on the next record after the ones you deleted
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform