Re: Rule system and unsucessful updates.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Rule system and unsucessful updates.
Дата
Msg-id 17060.1137438366@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Rule system and unsucessful updates.  (Matthew Schumacher <matt.s@aptalaska.net>)
Ответы Re: Rule system and unsucessful updates.  (Matthew Schumacher <matt.s@aptalaska.net>)
Список pgsql-general
Matthew Schumacher <matt.s@aptalaska.net> writes:
> update test set id = 1, data = 'test';

The above is a pretty bad idea in any case --- think about what happens
when you have some data in the table.  It'll set *every row* to id = 1
and data = 'test'.  The reason nothing happens when there is nothing in
the table is that there is no row that can be updated.  Taking an action
"instead of" an action that doesn't happen still doesn't happen.

Any practical application using UPDATE is going to say UPDATE ... WHERE
to limit the set of rows that get changed, and what you have to think
about is whether you need a rule to do anything in that situation.

For what I think you want this application to do, it'd make more sense
for the application to say "INSERT some-data", and for you to have a
rule that changes that into an UPDATE if there is a pre-existing row
with matching key columns.

            regards, tom lane

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

Предыдущее
От: Matthew Schumacher
Дата:
Сообщение: Re: Rule system and unsucessful updates.
Следующее
От: Emi Lu
Дата:
Сообщение: lists all users under groups