Re: Rule system and unsucessful updates. - Mailing list pgsql-general

From Matthew Schumacher
Subject Re: Rule system and unsucessful updates.
Date
Msg-id 43CBFAAE.4060302@aptalaska.net
Whole thread Raw
In response to Re: Rule system and unsucessful updates.  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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 by date:

Previous
From: Emi Lu
Date:
Subject: Re: lists all users under groups
Next
From:
Date:
Subject: Ref cursor with Geometric Function