|
Posted by Tim Roberts on 10/26/06 04:20
"Rik" <luiheidsgoeroe@hotmail.com> wrote:
>Chung Leong wrote:
>>
>> No, that still wouldn't remove the race condition. What you want to do
>> is put a unique constraint on the table, then have your script just
>> perform the INSERT. If it fails, then you know you have a duplicate.
>> MySQL also support the INSERT ... ON DUPLICATE KEY UPDATE syntax I
>> believe.
>
>Yup, or the shorter REPLACE INTO which does exactly the same.
.... as long as one understands that "REPLACE INTO" is a MySQL-only
extension. If one plans to upgrade to Postgres or a commercial database,
one will have to remember to change that back to INSERT/UPDATE.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
[Back to original message]
|