Unix Technical Forum

Re: MERGE vs REPLACE

This is a discussion on Re: MERGE vs REPLACE within the pgsql Hackers forums, part of the PostgreSQL category; --> > Unless you have a table lock, INSERT has to be before UPDATE, think UPDATE, UPDATE (both fail), INSERT, ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-11-2008, 07:52 AM
Zeugswetter Andreas DCP SD
 
Posts: n/a
Default Re: MERGE vs REPLACE


> Unless you have a table lock, INSERT has to be before UPDATE, think

UPDATE, UPDATE (both fail), INSERT, INSERT.

> > update
> > if no rows updated
> > insert
> > if duplicate key
> > update
> > if no rows updated goto insert


That is why you have the loop. This is not a problem with above code,
because only one insert succeeds
while the others then do the update.

Andreas

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:12 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com