Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Make field entry unique
Message
 
 
À
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:
01681464
Vues:
34
>>>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)
>
Your approach works. Thank you. Let's wait till Mike comes back and tells us if this is the fastest approach :)
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform