News for hackers. Stuff that matters.
Re:PostgreSQL 9.3 Beta 1 Released by ef4 on Monday May 13, 2013 @07:29PM (#5702094)
Upsert is already possible in a single statement, though a bit unwieldy.

    create table people (uuid varchar, name varchar);
    with new_rows as (select (unnest(ARRAY[('xxx','John Smith'), ('yyy', 'Ben Bitdiddle')]::people[])).*), updated as (UPDATE people SET name=new_rows.name FROM new_rows WHERE people.uuid=new_rows.uuid RETURNING people.uuid) insert into people select new_rows.* from new_rows left join updated using (uuid) where updated.uuid is null;

There are no comments on this comment yet.