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

From: Glus Xof <gtglus(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: SQL sentence to insert where updated rows is zero...
Date: 2013-01-31 16:25:53
Message-ID: CAGFvGiOxZrkoCdkFNw6HVwr=rbg5sdUMA4TY_0q6HFc2N2BSAg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi guys,

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');

Glus

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2013-01-31 16:37:35 COPY table to file missing quotation marks
Previous Message Tom Lane 2013-01-31 16:12:34 Re: AT TIME ZONE and interval arguments