Insert Rule - Mailing list pgsql-general

From Curtis Scheer
Subject Insert Rule
Date
Msg-id 031936836C46D611BB1B00508BE7345D04A589E6@gatekeeper.daycos.com
Whole thread Raw
Responses Re: Insert Rule  (Martijn van Oosterhout <kleptog@svana.org>)
Re: Insert Rule  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general

I’m trying to prevent any further input of a particular field value via an insert rule with the following rule.

 

CREATE OR REPLACE RULE rule_foovalue AS

    ON INSERT TO foo

   WHERE new.foovalue = 1 DO  SELECT fooexception.fooexception

   FROM fooexception() fooexception(fooexception);

 

Basically the stored procedure that it calls raises an exception. The behavior I wanted\excepted was to call the stored procedure when foovalue = 1 and to execute a regular insert when foovalue <> 1. What its doing is calling the stored procedure when foovalue = 1, that part works just fine. However, when I try to insert a record into foo with any other value besides 1 it actually inserts the record but doesn’t return the # of rows affected. Is there something else I need to add to the rule so that it returns the number of rows affected like normal?

 

Thanks,
Curtis

pgsql-general by date:

Previous
From: Christopher Browne
Date:
Subject: Re: Postrgesql and Mysql in the same server Linux (Fedora core 5)
Next
From: Csaba Nagy
Date:
Subject: Re: Strange error related to temporary tables