[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnumed-devel] Introducing myself
From: |
Karsten Hilbert |
Subject: |
Re: [Gnumed-devel] Introducing myself |
Date: |
Sun, 7 Dec 2003 23:20:23 +0100 |
User-agent: |
Mutt/1.3.22.1i |
> I am more of an DBA/sysadmin then programmer person, but I would love to
> look at it and try to help out.
Well, the story is simple: We allow several names per person
such that every "identity" can have several rows in the names
table linked to it. However, obviously, we only want one name
with active=true. Now, before insert/update we want to fire a
trigger that
- checks whether active is going to be set to true
- if so sets all existing names for that person to active=false
- then allows the update/insert with active=true to proceed
Currently we do:
if NEW.active = true then
update names set active = false where id_identity = NEW.id_identity and
active = true;
return NEW;
end if;
return NEW;
This is fired BEFORE INSERT OR UPDATE ON NAMES and FOR EACH
ROW.
For some reason it displays XOR/erratic behaviour regarding
the active flag.
Any ideas ?
Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346