Re: Multiple RULES on Views - Mailing list pgsql-general

From Sebastian Böck
Subject Re: Multiple RULES on Views
Date
Msg-id 4268BF5C.6010207@freenet.de
Whole thread Raw
In response to Multiple RULES on Views  (David Wheeler <david@kineticode.com>)
Responses Re: Multiple RULES on Views  (David Wheeler <david@kineticode.com>)
List pgsql-general
David Wheeler wrote:

[...]
> Well, I didn't have an unconditional update rule, so I added one without
> removing the other two:
>
> CREATE RULE nothing_one AS
> ON INSERT TO one DO INSTEAD NOTHING;
>
> And it worked! Now I can have an insert do an INSERT or UPDATE on
> another table magically.
>
> But my question is this: Is this a known and supported behavior? If not,
> is it likely to change? If so, how is the order or rules evaluated when
> a query is sent to the database? Order of definition? Alphabetically?

Yes, this is the correct way to do updateable views.

Multiple rules on the same table and same event type are
applied in alphabetical name order.

See:
http://www.postgresql.org/docs/current/static/sql-createrule.html
for more details and the above quote.

HTH

Sebastian

pgsql-general by date:

Previous
From: Patrick.FICHE@AQSACOM.COM
Date:
Subject: Re: Use of temporary tables in functions
Next
From: Hannes Dorbath
Date:
Subject: artificial keys or not?