Re: Insert Or update - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: Insert Or update
Date
Msg-id 20040423150334.GA6904@wolff.to
Whole thread Raw
In response to Insert Or update  (Anton Nikiforov <anton@nikiforov.ru>)
Responses Re: Insert Or update
List pgsql-general
On Fri, Apr 23, 2004 at 17:48:21 +0400,
  Anton Nikiforov <anton@nikiforov.ru> wrote:
> I know that this will be helpful to write a function that will do this
> for me, but it will run the same time as my insertion tool that is
> written in c or even slower. So my question is: is it possible to have
> "UPDATE OR INSERT" statement in the PostgreSQL like it is possible in
> Oracle (as i heard but did not check it by myself yet)?

This was discussed on the list over the last couple of days.
There is no update or insert statement in postgres.
You can do an update and check the number of rows affected and if it
is 0 do the insert.
However unless you lock the table while doing this, you have to be prepared
to handle errors.

pgsql-general by date:

Previous
From: "Bas Scheffers"
Date:
Subject: Re: Insert Or update
Next
From: Pascal Polleunus
Date:
Subject: Synchronize unicode data using copy or pg_dump