Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Deleting records using REPLACE
Message
De
24/01/2000 17:46:10
 
 
À
24/01/2000 04:50:24
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00321564
Message ID:
00321900
Vues:
20
>The title says it all ; can I use REPLACE (some systemname) to delete records.
>
>Why ?
>
>I have a candidate index on a table. Records are deleted and added to it (wow !). When a record is deleted and later I want to add a record with the same index, the insert is refused because of the uniqueness constraint (as far as the table hasn't been packed since). So to prevent this, before I delete the record, I change a value in the record (using the negative recno() which can never give duplicates) :
>
>REPLACE whatever_part_of_the_index WITH -recno()
>DELETE NEXT 1
>
>So twice access to the table : can I reduce the access to only once ?

Pascal, this is what I do. I use integer fields for keys. When I want to "delete" a record, I set the key value to the negative of itself.

REPLACE TABLE.iKey with -TABLE.iKey.

This will never cause a non-unique value.

I do this for the primary key and all of the foreign keys. I DON'T actually DELETE the record. I have SET DELETED OFF.

Works for me.

Peter
Peter Robinson ** Rodes Design ** Virginia
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform