Re: Atomic operations? - Mailing list pgsql-jdbc

From Dave Cramer
Subject Re: Atomic operations?
Date
Msg-id 845D8D6D-E1F8-4D8C-82B1-2EC3D3C4E6D0@fastcrypt.com
Whole thread Raw
In response to Re: Atomic operations?  ("Paul Tomblin" <ptomblin@gmail.com>)
Responses Re: Atomic operations?
List pgsql-jdbc
On 18-Mar-08, at 10:12 AM, Paul Tomblin wrote:

> On Tue, Mar 18, 2008 at 10:06 AM, Dave Cramer <pg@fastcrypt.com>
> wrote:
>> On 18-Mar-08, at 9:40 AM, Paul Tomblin wrote:
>>> I'm doing a simple delete/insert on a table, rather than trying to
>>> figure out whether the row exists or not and then doing an update or
>>> an insert.  But what I'm discovering is that every now and then I
>>> get
>>> a duplicate primary key exception, so I figure that two processes
>>> are
>>> doing the deletes and inserts and stomping on each other.  So my
>>
>> Can't you just check the return value from the delete to see if
>> anything was deleted ?
>
> I'm not sure how that would help.  If I do the delete and it didn't
> delete anything, that doesn't tell me if some other process inserted
> it in the meantime.
>
which ever process succeeds in deleting should do the insert.

Dave
>
>
>
> --
> For my assured failures and derelictions I ask pardon beforehand of my
> betters and my equals in my Calling here assembled, praying that in
> the hour of my temptations, weakness and weariness, the memory of this
> my Obligation and of the company before whom it was entered into, may
> return to me to aid, comfort and restrain.


pgsql-jdbc by date:

Previous
From: "Paul Tomblin"
Date:
Subject: Re: Atomic operations?
Next
From: Dave Cramer
Date:
Subject: Re: setQueryTimeout problem !?!?!