Re: SERIAL type does not generate new ID ?
| От | Ed Loehr |
|---|---|
| Тема | Re: SERIAL type does not generate new ID ? |
| Дата | |
| Msg-id | 396A113A.CEDC8733@austin.rr.com обсуждение исходный текст |
| Ответ на | SERIAL type does not generate new ID ? ("Jean-Marc Libs" <jean-marc.libs@obs.coe.int>) |
| Список | pgsql-sql |
Jean-Marc Libs wrote:
>
> I have this table:
>
> CREATE TABLE film (
> film_id serial,
> ...
>
> SELECT setval ('film_film_id_seq', 6);
>
> I have this query in PHP:
> insert into film
>
(film_country_id,film_country_id2,film_country_id3,film_country_id4,film_prod_year,film_ec_certif,film_ce_certif,film_eur_support,film_media_support,film_provisoire)
values('FR','','','','2000','f','f','f','f','f')
>
> And it gives the following error:
> ERROR: Cannot insert a duplicate key into a unique index
You should not have to do anything special with the serial or the
sequence (including setting it to 6). Possible sources for for your
error: 1) you are resetting the sequence value to 6 when you already
have a row with that value for film_id in the table, or 2) could be the
message is coming from a triggered insert "downstream" from your initial
insert (see your server log). BTW, 7.0+ tells you *which* index caused
the problem.
Regards,
Ed Loher
В списке pgsql-sql по дате отправления: