duplicate key violates unique constraint

From: vtaquette(at)globo(dot)com
To: pgsql-general(at)postgresql(dot)org
Subject: duplicate key violates unique constraint
Date: 2006-09-18 22:47:25
Message-ID: 450D86C300003E02@mail03.sc2.he.tucows.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Junkone 2006-09-18 22:54:05 unique key issue
Previous Message Geoffrey 2006-09-18 20:46:15 Re: server resetting