pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Edoardo Causarano <curious.dot.corn.at.katamail.dot.com@postgresql.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: Rule creation
Date: Fri, 04 Oct 2002 10:24:47 -0400
Message-ID: <20527.1033741487@sss.pgh.pa.us> (raw)
In-Reply-To: <200210032134.24682.Edoardo Causarano <curious dot corn at katamail dot com>
References: <200210032134.24682.Edoardo Causarano <curious dot corn at katamail dot com>

Edoardo Causarano <curious.dot.corn.at.katamail.dot.com@postgresql.org> writes:
> Hello, I need help on this rule:
> CREATE RULE rule AS ON INSERT TO table WHERE (sum(new."field") > 10) DO
> INSTEAD NOTHING;
> Creation is ok but in inserting a row I get the following from pgaccessII
> number -2147467259
> ERROR: fireRIRrules: failed to remove aggs from qual...

This is a known bug, but the fix will be to reject such rules entirely.
An aggregate in a rule's WHERE clause is not sensible --- what are you
aggregating over?

> I need a rule that denies insertions if the total of the rows with an active 
> attribute maxes out (guess what, a vacancy set).

I think a rule is the wrong way to approach this anyhow.  What would
probably make more sense is an AFTER INSERT OR UPDATE trigger that
runs a SUM() computation on the table and throws an error if it doesn't
like the result.

			regards, tom lane



view thread (2+ messages)

Message-ID: <20527.1033741487@sss.pgh.pa.us>
Permalink:  ../20527.1033741487@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20527.1033741487@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, curious.dot.corn.at.katamail.dot.com@postgresql.org
  Subject: Re: Rule creation
  In-Reply-To: <20527.1033741487@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox