Re: UPSERT

Поиск
Список
Период
Сортировка
От Florian G. Pflug
Тема Re: UPSERT
Дата
Msg-id 45E8395C.30501@phlo.org
обсуждение исходный текст
Ответ на Re: UPSERT  (Andrew Dunstan <andrew@dunslane.net>)
Ответы Re: UPSERT  (Gregory Stark <stark@enterprisedb.com>)
Список pgsql-hackers
Andrew Dunstan wrote:
> Jonathan Scher wrote:
>> Hello,
>>
>> I'd like to work on TODO item:
>> > Add REPLACE or UPSERT command that does UPDATE, or on failure, INSERT
>>
>> could you please tell me if I'm going in the right way?
>>
>> There are some different syntaxes possible, but MySQL has an 
>> interesting one here:
>> http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html
>>
>> INSERT INTO table (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1;
>> This allow to make an insert, and if the key is already there to 
>> modify the value depending on the current one.

May this could be generalized to a generic "<stmt> on <error> do <stmt>"?
You could then write
"update table set c=c+1 on not_found do insert into table (a,b,c) values (1,2,3)"

Just an idea I just had...

greetings, Florian Pflug



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: UPSERT
Следующее
От: Gregory Stark
Дата:
Сообщение: Re: UPSERT