From: | Ed Loehr <eloehr(at)austin(dot)rr(dot)com> |
---|---|
To: | jml(at)obs(dot)coe(dot)int |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: SERIAL type does not generate new ID ? |
Date: | 2000-07-10 18:08:58 |
Message-ID: | 396A113A.CEDC8733@austin.rr.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Shalini shikha | 2000-07-10 18:15:45 | problem with date |
Previous Message | Dorin Grunberg | 2000-07-10 17:21:10 | Subselects with IN and EXISTS |