Re: [SQL] insert or update within transaction

2011-09-17 Thread Josh Kupershmidt
On Sat, Sep 17, 2011 at 10:52 AM, Andreas wrote: > Instead of the update the query fails with an double key value error for the > primary key. > Shouldn't the insert fail, get rolled back and then exercute an update > instead successfully? Yes, and that is indeed what I see when I run your exampl

[SQL] insert or update within transaction

2011-09-17 Thread Andreas
Hi, http://www.postgresql.org/docs/current/static/sql-update.html has an example where an either an insert or update is done according if a key already exists. The example is about wines. I did it with numbers. drop table if exists tbl; create table tbl ( key int primary key, val int ); insert