Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Make field entry unique
Message
 
 
To
20/06/2021 19:46:18
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01681459
Message ID:
01681461
Views:
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
>   lcid_field=id_field
>   licounter=48 &&asc('0')
>  update mytable set id_field = rtrim(id_field)+mysuffix() where id_field=m.lcid_field 
>endscan
>
>function mysuffix()
>licounter=m.licounter+1
>return chr(m.licounter)
>
Thank you, John. I will try your approach; just so that I can learn. As I wrote in my message, I was able to find the solution by adding a dummy field, suffix, and setting a value to this field. Then adding the suffix to the ID_FIELD.
"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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform