Re: Rule system and unsucessful updates.

From: Matthew Schumacher <matt(dot)s(at)aptalaska(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Rule system and unsucessful updates.
Date: 2006-01-16 19:57:34
Message-ID: 43CBFAAE.4060302@aptalaska.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message sunithab 2006-01-16 20:17:26 Ref cursor with Geometric Function
Previous Message Emi Lu 2006-01-16 19:50:51 Re: lists all users under groups