Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Make field entry unique
Message
De
20/06/2021 19:46:18
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., Nouvelle Zélande
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01681459
Message ID:
01681460
Vues:
53
J'aime (1)
>>So some records have an ID that already exists. Other records have unique ID.
>>I want to run this table through a PRG and add a suffix '1', or '2', or '3' (depending on each duplicate record). So that the above table would look like this:

How about something along the lines of
select id_field,count(*) as cnt from mytable group by 1 order by 1 having cnt>1 into cursor c_fixme
SCAN
  licounter=0
  update mytable set id_field = rtrim(id_field)+mysuffix() where id_field=c_fixme.cid_field 
endscan

function mysuffix()
licounter=m.licounter+1
return transform(m.licounter)
"... They ne'er cared for us
yet: suffer us to famish, and their store-houses
crammed with grain; make edicts for usury, to
support usurers; repeal daily any wholesome act
established against the rich, and provide more
piercing statutes daily, to chain up and restrain
the poor. If the wars eat us not up, they will; and
there's all the love they bear us.
"
-- Shakespeare: Coriolanus, Act 1, scene 1
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform