RE: Re: Unanswered questions about Postgre

From: Roger Wernersson <roger(dot)wernersson(at)mindark(dot)com>
To: PostgreSQL general mailing list <pgsql-general(at)postgresql(dot)org>
Subject: RE: Re: Unanswered questions about Postgre
Date: 2000-12-12 11:04:46
Message-ID: 5146853DD571D411AC54000102070D610125C4@MINGBGNTS02
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)acm(dot)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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mayers, Philip J 2000-12-12 11:45:53 LIKE with macaddr types
Previous Message martin.chantler 2000-12-12 11:01:53 Which character data type to use?