pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nico <nicohmail-postgresql@yahoo.com>
To: pgsql-jdbc@postgresql.org
Subject: rule/trigger for batch update
Date: Fri, 25 Feb 2005 03:00:15 +0100
Message-ID: <cvm0uv$26p7$1@news.hub.org> (raw)

Hi,
I want to make a trigger or a rule. However here is the tricky part: I want 
it to happen after a batch of updates and not during one of them. It is 
already set (by means of a unique index) that maximum one record can contain 
the value 1. Point is that after every update I still have exactly one 
record where the field value is 1. Here is what is supposed to happen in the 
same batch:
UserRoleID (where value is 1) becomes 2 or 3. Which leaves no record to have 
a 1 value in this field.
The field becomes 1 in another record.
Now both actions must happen or neither.

Here is the table creation code:
CREATE TABLE "tblUser" (
    "UserID" serial NOT NULL,
    "UserName" character varying(50) NOT NULL,
    "UserPass" character varying(50) NOT NULL,
    "UserRoleID" integer DEFAULT 3 NOT NULL
);
CREATE UNIQUE INDEX indsuperadmin ON "tblUser" USING btree ("UserRoleID") 
WHERE ("UserRoleID" = 1);

Thanks in advance,
Nico. 





Message-ID: <cvm0uv$26p7$1@news.hub.org>
Permalink:  ../cvm0uv$26p7$1@news.hub.org/
Also on:    postgresql.org/message-id/cvm0uv$26p7$1@news.hub.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: nicohmail-postgresql@yahoo.com
  Subject: Re: rule/trigger for batch update
  In-Reply-To: <cvm0uv$26p7$1@news.hub.org>
  References: <cvm0uv$26p7$1@news.hub.org>

* 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