From: | Tomas Vondra <tv(at)fuzzy(dot)cz> |
---|---|
To: | Greg Peters <gregpeters79(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Problem with unique key |
Date: | 2006-11-28 09:29:45 |
Message-ID: | 456C0189.7080308@fuzzy.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> ERROR: duplicate key violates unique constraint "admin_field_list_pkey"
> CSG=#
>
> /I don't understand what is going on. It seems that it can't increment
> the primary key properly, or for some reason it's trying to assign an
> incorrect value to the key column. If i change the command to include a
> value for the key column (in this case the number 9), it seems to work.
> I've tried dumping/restoring the DB and also tried it on v8.1 and v8.2
> with no success. Any ideas?/
>
> Kind Regards,
>
> Greg Peters.
The problem is in the primary key constraint, not the unique one. I
guess you have inserted the previous rows with 'key' value specified
directly just like in:
=# insert into admin_field_list (key, field, added_by) values (1,
'Talinga', 'Greg Peters');
Thus the sequence is not set to the correct value and generates values
from 1 ... and these are already in the table. Try this
=# SELECT setval('admin_field_list_key_seq', (SELECT MAX(key) FROM
admin_field_list));
and then the insert again.
Tomas
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2006-11-28 09:34:32 | Re: Problem with unique key |
Previous Message | Greg Peters | 2006-11-28 09:13:03 | Problem with unique key |