Re: Rule system and unsucessful updates.

Поиск
Список
Период
Сортировка
От Matthew Schumacher
Тема Re: Rule system and unsucessful updates.
Дата
Msg-id 43CBFAAE.4060302@aptalaska.net
обсуждение исходный текст
Ответ на Re: Rule system and unsucessful updates.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Tom Lane wrote:
> 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'.

Your right, DUH, I forgot my where clause in my example.  It is in the
real query though, perhaps I didn't get enough coffee this morning.

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.
>
> 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.

I'll go with updating instead of inserting in the rule, however I am
curious, is there a way to make an ON UPDATE rule work regardless if the
original query updated rows or not?  I was under the impression that the
rule engine just looked at the query syntax not what it did.

schu

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

Предыдущее
От: Emi Lu
Дата:
Сообщение: Re: lists all users under groups
Следующее
От:
Дата:
Сообщение: Ref cursor with Geometric Function