Unique Constraint Failed, Why?

Rob Mostyn mostyn at platformis.net
Mon Sep 20 06:52:23 UTC 2021


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 



More information about the omnisdev-en mailing list