Hi,
|
| BTW, from my estimates you'd need at least 4 - 6 sql queries to simulate the
| REPLACE syntax for Postgres, so why on earth would you use it?
|
I think Chris would be right. In my approach the true emulation of REPLACE
syntax is the following:
1. BEGIN;
2. SELECT ... FOR UPDATE;
3a. UPDATE ...;
3b. INSERT ...;
4. COMMIT;
I think each step is required to do a foolproof code.
Transaction (BEGIN and COMMIT) guarantees the atomicity for so called "REPLACE",
and the "FOR UPDATE" clause locks the corresponding row, if it exists.
(AFAIR, it works only in transaction, obvoiusly.)
So, it takes 4 SQL statements.
Papp Gyozo
- pgerzson@freestart.hu