Re: Rules/Trigges Trade-offs - Mailing list pgsql-sql

From Josh Berkus
Subject Re: Rules/Trigges Trade-offs
Date
Msg-id 200212091206.09064.josh@agliodbs.com
Whole thread Raw
In response to Rules/Trigges Trade-offs  (Jean-Luc Lachance <jllachan@nsd.ca>)
List pgsql-sql
Ian,

> Anyway, I have a similar requirement, to intercept insert/update/delete and
redirect the data if a condition is met.  Right now I am trying an INSTEAD
rule that puts the condtion in the WHERE of the rule definition.  It seems to
work OK, but if the condition has exeptions where I would like to throw an
error, I can't.  And since it is an INSTEAD, I can't have a trigger on the
table fire to find the exception cases.  Urgh.

I'd suggest a "DO INSTEAD SELECT some_function(NEW)"
where some_function is a function that tests for errors, throws and exception
if necessary, otherwise inserts.  It's tricky, but probably the best way to
get trigger + rule functionality at once.

--
-Josh BerkusAglio Database SolutionsSan Francisco



pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Default Permissions (repost from Novice)
Next
From: Josh Berkus
Date:
Subject: Re: Rules/Trigges Trade-offs