duplicate key violates unique constraint - Mailing list pgsql-general

From vtaquette@globo.com
Subject duplicate key violates unique constraint
Date
Msg-id 450D86C300003E02@mail03.sc2.he.tucows.com
Whole thread Raw
Responses Re: duplicate key violates unique constraint  (Jeff Davis <pgsql@j-davis.com>)
List pgsql-general
Hi,

I'm trying to create a table with a PRIMARY KEY. The CREATE statement looks
like this:

CREATE TABLE  "projects" (
  "project_id" serial,
  "username" varchar(30) NOT NULL default '',
  "project_name" varchar(30) NOT NULL default '',
  PRIMARY KEY  ("project_id")
) ;

The problem is that sometimes, I would say 1 in 10 tries, when I use a INSERT
command I get the following error:

"duplicate key violates unique constraint"

The INSERT query is that:
"INSERT INTO projects (\"project_name\", \"username\") VALUES ('$project_name',
'$username')";

Can someone help me please?!!

Thanks,
Verônica



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: server resetting
Next
From: Jeff Davis
Date:
Subject: Re: duplicate key violates unique constraint