Re: SQL sentence to insert where updated rows is zero...

From: Vincent Veyron <vv(dot)lists(at)wanadoo(dot)fr>
To: Glus Xof <gtglus(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SQL sentence to insert where updated rows is zero...
Date: 2013-01-31 19:30:04
Message-ID: 1359660604.2444.36.camel@asus-1001PX.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Le jeudi 31 janvier 2013 à 17:25 +0100, Glus Xof a écrit :

> It's just to ask you if there is a single SQL sentence to INSERT
> values in case of UPDATE WHERE returns 0 rows updated. I mean, If I
> write something like,
>
> # update my_table set column1='value' where column2='key_value';
>
> And system replies me with one "UPDATE 0" because there is no row at
> column2 with value 'key_value'... is it possible to say here: in this
> case, create one new row with 'value' - 'key_value'...? like
>
> # insert into my_table (column1, column2) values ('value', 'key_value');
>

You might want to have a look at this page :

http://www.depesz.com/2012/06/10/why-is-upsert-so-complicated/

--
Salutations, Vincent Veyron
http://marica.fr/site/demonstration
Logiciel de gestion des contentieux juridiques et des sinistres d'assurance

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2013-01-31 19:52:16 Re: "CREATE TEMPORARY TABLE" does not work in SQL language function?
Previous Message David Johnston 2013-01-31 19:17:20 "CREATE TEMPORARY TABLE" does not work in SQL language function?