Re: mysql replace in postgreSQL?

From: <cristian(at)clickdiario(dot)com>
To: blackwaterdev(at)gmail(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: mysql replace in postgreSQL?
Date: 2005-10-30 07:14:33
Message-ID: A7lGXMqe.1130656473.8695620.cristian@clickdiario.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On 10/29/2005, "blackwater dev" <blackwaterdev(at)gmail(dot)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 -)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message A. Kretschmer 2005-10-30 07:45:53 Re: function example?
Previous Message Tom Lane 2005-10-30 05:33:57 Re: Installation trouble -- oops