From: | "Shridhar Daithankar" <shridhar_daithankar(at)persistent(dot)co(dot)in> |
---|---|
To: | PgSQL General ML <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Replaceing records |
Date: | 2003-09-04 10:30:59 |
Message-ID: | 3F5761BB.23467.77CB3C@localhost |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 4 Sep 2003 at 12:17, Csaba Nagy wrote:
> This problem would be easily solved if the current transaction would not
> be automatically rolled back on the failed insert. Given this, it would
> be as easy as trying the insert, and if fails, do the update.
That violates definition of a transaction. You need nested transaction which
aren't there..
You can use a sequence to insert. If next value of sequence is more than value
you have, probably somebody has inserted the value. Then modify it.
Or do a select for update. If it returns the error, there is no record. So
insert, otherwise update.
It might still fail though but chances will be much less.
HTH
Bye
Shridhar
--
Air Force Inertia Axiom: Consistency is always easier to defend than
correctness.
From | Date | Subject | |
---|---|---|---|
Next Message | Bernd Helmle | 2003-09-04 11:05:35 | Re: syntax error in eRServer.pm line 69 |
Previous Message | Bjorn T Johansen | 2003-09-04 10:30:56 | Re: Tomcat Connection Pool? |