RE: Re: Unanswered questions about Postgre - Mailing list pgsql-general

From Roger Wernersson
Subject RE: Re: Unanswered questions about Postgre
Date
Msg-id 5146853DD571D411AC54000102070D610125C4@MINGBGNTS02
Whole thread Raw
In response to Unanswered questions about Postgre  (Joe Kislo <pgsql@athenium.com>)
Responses RE: Re: Unanswered questions about Postgre  ("Edward Q. Bridges" <ed.bridges@buzznik.com>)
List pgsql-general
How do you mean "reliable"?

This raises an interesting question though. How do I _reliably_ INSERT or
UPDATE a row?

I can't INSERT - fail - UPDATE as someone might delete the record in between
my two statements.

I can't BEGIN - INSERT - fail - UPDATE - COMMIT as the failing INSERT will
invalidate my transaction (stupid).

I can't BEGIN - SELECT FOR UPDATE - INSERT or UPDATE - COMMIT as someone
might insert after my SELECT and before my INSERT.

Is there a right solution?

/Roger

-----Original Message-----
From: Tim Kientzle [mailto:kientzle@acm.org]
Sent: den 12 december 2000 02:10
To: PostgreSQL general mailing list
Subject: [GENERAL] Re: Unanswered questions about Postgre


> Of course, people really shouldn't be inserting
> objects which already exist, ...

On the contrary, the best way to test if
something already exists is to just try the
INSERT and let the database tell you if
it's already there.  Both faster and more
reliable than doing SELECT then INSERT.

            - Tim

pgsql-general by date:

Previous
From: martin.chantler@convergys.com
Date:
Subject: Which character data type to use?
Next
From: "Mayers, Philip J"
Date:
Subject: LIKE with macaddr types