Re: most idiomatic way to "update or insert"?

From: Pierre-Frédéric Caillaud <lists(at)boutiquenumerique(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: most idiomatic way to "update or insert"?
Date: 2004-08-05 06:49:33
Message-ID: opsb8ykvcgcq72hf@musicbox
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


I use stored procedures :

create function insertorupdate(....)
UPDATE mytable WHERE ... SET ...
IF NOT FOUND THEN
INSERT INTO mytable ...
END IF;

You lose flecibility in your request though.

I wish Postgresql had an INSERT OR UPDATE like MySQL does. So far it's
the only thing that I regret from MySQL.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Prabu Subroto 2004-08-05 06:54:40 Re: Sequence Question
Previous Message Scott Marlowe 2004-08-05 06:32:51 Re: Test case for bug fix in 7.4.3