Re: peer review: recipe for solving SELECT/INSERT/UPDATE race condition
- From: mark@xxxxxxxxxxxxxxx (Mark Stosberg)
- Date: Mon, 21 Aug 2006 21:12:43 -0500
Stuart Cooper wrote:
Sometimes it's desirable to first to a SELECT to see if a row exists,
and then INSERT if it doesn't already, or UPDATE if it does.
MySQL's got a really handy 'REPLACE INTO' for just this circumstance,
some have suggested that PostgreSQL should support this in future.
The SQL 2003 Standard has a really handy "MERGE INTO" for just this circumstance, too. You can search for "MERGE INTO" on this page to read about it:
http://www.varlena.com/GeneralBits/73.php
I hope both PostgreSQL and MySQL support this in the future.
Your solution looks good.
Thanks.
Mark
--
http://mark.stosberg.com/
.
- References:
- peer review: recipe for solving SELECT/INSERT/UPDATE race condition
- From: Mark Stosberg
- Re: peer review: recipe for solving SELECT/INSERT/UPDATE race condition
- From: Stuart Cooper
- peer review: recipe for solving SELECT/INSERT/UPDATE race condition
- Prev by Date: Re: queries not getting executed?
- Next by Date: Re: "max" datatypes support of SQL Server 2005 for DBD-ODBC
- Previous by thread: Re: peer review: recipe for solving SELECT/INSERT/UPDATE race condition
- Next by thread: possible leak in 1.52
- Index(es):
Relevant Pages
|