Re: Replace into...

From: Dani Oderbolz <oderbolz(at)ecologic(dot)de>
To: "Boget, Chris" <chris(at)wild(dot)net>
Cc: "''PGSQL-NOVICE(at)postgresql(dot)org' '" <PGSQL-NOVICE(at)postgresql(dot)org>
Subject: Re: Replace into...
Date: 2003-07-07 10:45:12
Message-ID: 3F094F38.6060708@ecologic.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Boget, Chris wrote:

> >> Somebody else probably has a more clever way to do it though......
> >I would do this unconditionally.
> >UPDATE ... FROM ... WHERE EXISTS (SELECT ...)
> >INSERT INTO ... WHERE NOT EXISTS (SELECT ...)
> >That are still 2 queries, but better than playing around with triggers.
>
Hmm, in Oracle, before we had MERGE INTO
we did it in the Procedureal language:
- You try to update
- if it doesnt work, insert.

this would lead to such a structure:

update;
if not found then
insert;
end if;

I hope this gives you a hint.
Cheers, Dani

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Guerin 2003-07-07 13:18:40 Multiple Resultsets
Previous Message wong siew hui 2003-07-07 10:32:14 Problems with Installation of Perl-DBD-PG