most idiomatic way to "update or insert"? - Mailing list pgsql-general

So I have some data that I want to put into a table.  If the
row already exists (as defined by the primary key), I would
like to update the row.  Otherwise, I would like to insert
the row.

I've been doing something like

delete from foo where name = 'xx';
insert into foo values('xx',1,2,...);

but I've been wondering if there's a more idiomatic or canonical
way to do this.

Many TIA,
Mark

--
Mark Harrison
Pixar Animation Studios

pgsql-general by date:

Previous
From: Jerry LeVan
Date:
Subject: Re: Simplfied Bytea input/output?
Next
From: "Scott Marlowe"
Date:
Subject: Re: [HACKERS] enforcing a join type