Unique Constraint Failed, Why?
Das Goravani
goravanis at gmail.com
Mon Sep 20 14:51:30 UTC 2021
I found a workaround and that solves my problem. It’s strange. I was loading the values to be updated from a list. All values for all columns were being loaded, then I tried to update and would get the error. It should not happen. Then I tried to Select (Find) the record first, before updating it.. and that worked.. surprisingly.. shouldn’t have to be done as I was loading all values for all columns from the list.. the additional find did nothing but load them from disk instead of list.. but it made it work, so I’m happy.
> On Sep 20, 2021, at 2:52 AM, Rob Mostyn <mostyn at platformis.net> wrote:
>
> I think this is called an aggregate function in sql Das.
> It would return one or more rows with something like this:
> 23412 2
> 41232 4
>
> The first column is the primary key that has a duplicate and the second column is the count of occurrences.
> The above suggesting you have two records with 23412 as a primary key and 4 rows with 41232 as primary key.
> This explains why you cannot implement a unique key constraint. You could then manually adjust the primary keys and solve the problem. The first question though, is how did the problem occur in the first place? If the data was generated ages ago don’t bother to figure it out… just fix it.
>
> Rob
>
>> On 18 Sep 2021, at 21:08, Das Goravani <goravanis at gmail.com> wrote:
>>
>>
>>
>>> On Sep 18, 2021, at 2:19 PM, Rob Mostyn <mostyn at platformis.net> wrote:
>>>
>>> select primarykeycolumn, count(*)
>>> from table
>>> group by primarykeycolumn
>>> having count(*) > 1
>>
>> I’m not familiar with doing SQL like that. I get that you want me to put in that SQL statement.. little details I don’t get exist..
>>
>> Like do you include that comma in the first line?
>>
>> And what would this do?
>>
>> And is “having” a SQL command word, usually capitalized?
>>
>> Do I fetch into a list?
>>
>> What should I expect to see?
>>
>> Sorry
>>
>> Das
>> _____________________________________________________________
>> Manage your list subscriptions at http://lists.omnis-dev.com
>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
>
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
More information about the omnisdev-en
mailing list