Re: Merge condition in postgresql - Mailing list pgsql-hackers

From Stephen Frost
Subject Re: Merge condition in postgresql
Date
Msg-id 20080204142742.GE5031@tamriel.snowman.net
Whole thread Raw
In response to Merge condition in postgresql  ("Amit jain" <amitjain.bit@gmail.com>)
Responses Re: Merge condition in postgresql  ("Roberts, Jon" <Jon.Roberts@asurion.com>)
List pgsql-hackers
* Amit jain (amitjain.bit@gmail.com) wrote:
> I am currently migrating database from ORACLE to postgresql but i am stucked
> up at one point while creating procedures.
> There is a query which has used oracle MERGE condition so how can i change
> this query as per posgresql. kindly suggest me its very urgent.

If you're talking about what I think you're talking about, then
basically you need to break up the MERGE into seperate insert/update
steps.  You just have to write the queries such that if the record
doesn't exist, it gets inserted, and if it does exist, then it gets
updated.  MERGE just allows you to do this in a nicer, somewhat more
efficient, way.  If you've got alot of transactions happening around the
same time with the table in question then you may also have to write
your logic to be able to handle a rollback and to try again.
Enjoy,        Stephen

pgsql-hackers by date:

Previous
From: Ron Mayer
Date:
Subject: Re: configurability of OOM killer
Next
From: "Roberts, Jon"
Date:
Subject: Re: Merge condition in postgresql