Received: from Mail.austin.rr.com (sm2.texas.rr.com [24.93.35.55]) by hub.org (8.10.1/8.10.1) with ESMTP id e6AI4uW43525 for ; Mon, 10 Jul 2000 14:04:57 -0400 (EDT) Received: from austin.rr.com ([24.28.74.65]) by Mail.austin.rr.com with Microsoft SMTPSVC(5.5.1877.357.35); Mon, 10 Jul 2000 13:04:13 -0500 Message-ID: <396A113A.CEDC8733@austin.rr.com> Date: Mon, 10 Jul 2000 13:08:58 -0500 From: Ed Loehr X-Mailer: Mozilla 4.7 [en] (X11; U; Linux 2.2.12-20smp i686) X-Accept-Language: en MIME-Version: 1.0 To: jml@obs.coe.int CC: pgsql-sql@postgresql.org Subject: Re: SERIAL type does not generate new ID ? References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200007/103 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