Affected rows count by rule as condtition

From: mito <milos(dot)orszag(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Affected rows count by rule as condtition
Date: 2009-04-13 16:12:24
Message-ID: grvo97$mco$2@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,
is there any way how to count affected rows by on update rule and use it
as part of condtions.

Example:

CREATE OR REPLACE RULE "_UPDATE" AS ON UPDATE TO "users" DO INSTEAD (
UPDATE "s_users" SET
id = new.id,
login = new.login,
WHERE id IN (SELECT id FROM "s_users" ) AND 2 > (SELECT count(new.id)) ;

Error: agregate functions not allowed in WHERE statement

It need to simulate unique constraint on field s_users.new_id, so it
should deny to update multiple rows with same value.

Any suggestions are welcome.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jaime Casanova 2009-04-13 16:27:20 Re: Affected rows count by rule as condtition
Previous Message Hiroshi Saito 2009-04-13 15:12:36 Re: Solution of the file name problem of copy on windows.