Re: unique constraint

From: Erik Jones <erik(at)myemma(dot)com>
To: Dominique Bessette - Halsema <dbhalsema(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: unique constraint
Date: 2008-01-24 22:17:59
Message-ID: 5C6E42D2-9080-4ADE-A40B-7E947E064842@myemma.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Jan 24, 2008, at 12:36 PM, Dominique Bessette - Halsema wrote:

> I'm getting the following error, and I think it's because when i
> insert into postgres from geoserver's WFS, i first delete then
> insert the track, and geoserver does this in succession but very
> fast. If I personally test inserting two tracks with the same guid
> in a row, then it works, but because geoserver is going so fast it
> blows up and gives this error. i'm looking into fixing it another
> way but does any one have an idea of anything i can do to avoid
> this error in postgres?
>
> STATEMENT: INSERT INTO
> "public"."tracks" ("guid","classification","creationtimestamp","lastup
> datetime","effectivetime","reportedtime","staletime","confidencevalue"
> ,"behavioridentity","nationality","classificationcategory","classconfi
> dencevalue","axislabels","uomlabels","aoumajaxis","aouminaxis","aouval
> id","the_geom") VALUES ('OOSTZEE','U','2008-01-22T21:05:
> 15.366Z','2008-01-22T21:05:15.366Z','2008-01-22T21:05:15.366Z','2008-0
> 1-22T21:05:15.366Z','2008-01-22T21:05:15.366Z',
> 1.0,'FRIEND','','SEA','1.0','Lat Long h','degree degree',
> 9999999,9999999,'true',setSRID
> ('00000000014029D8E757928E0D404B9C28CBD1244A'::geometry,4326))
>
> ERROR: duplicate key violates unique constraint "tracks_guid_key"
>

Perhaps you haven't wrapped these successive DELETE -> INSERT
statements in a transaction?

BEGIN;
DELETE ...;
INSERT ...;
COMMIT;

Erik Jones

DBA | Emma®
erik(at)myemma(dot)com
800.595.4401 or 615.292.5888
615.292.0777 (fax)

Emma helps organizations everywhere communicate & market in style.
Visit us online at http://www.myemma.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alan Hodgson 2008-01-24 23:07:52 Re: Disk configurations....
Previous Message Dominique Bessette - Halsema 2008-01-24 21:47:39 close connection