Re: mysql replace in postgreSQL? - Mailing list pgsql-general

From
Subject Re: mysql replace in postgreSQL?
Date
Msg-id A7lGXMqe.1130656473.8695620.cristian@clickdiario.com
Whole thread Raw
In response to mysql replace in postgreSQL?  (blackwater dev <blackwaterdev@gmail.com>)
List pgsql-general
On 10/29/2005, "blackwater dev" <blackwaterdev@gmail.com> wrote:

>In MySQL, I can use the replace statement which either updates the
>data there or inserts it.  Is there a comporable syntax to use in
>postgreSQL?
>
>I need to do an insert and don't want to have to worry about if the
>data is already there or not...so don't want to see if it there, if so
>do update if not insert...etc.
>
>Thanks.
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: explain analyze is your friend

BEGIN;
-- other operations
SAVEPOINT sp1;
INSERT INTO wines VALUES('Chateau Lafite 2003', '24');
-- Assume the above fails because of a unique key violation,
-- so now we issue these commands:
ROLLBACK TO sp1;
UPDATE wines SET stock = stock + 24 WHERE winename = 'Chateau Lafite
2003';
-- continue with other operations, and eventually
COMMIT;

(extracted from the PostgreSQL Manual -
http://www.postgresql.org/docs/8.0/interactive/sql-update.html -)

pgsql-general by date:

Previous
From: Matthew Peter
Date:
Subject: function example?
Next
From: "A. Kretschmer"
Date:
Subject: Re: function example?