X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.225.181]) by svr1.postgresql.org (Postfix) with ESMTP id 7E9ECCC99E for ; Thu, 17 Jul 2003 11:57:10 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr5.postgresql.org [64.117.225.181]) (amavisd-new, port 10024) with ESMTP id 95131-05 for ; Thu, 17 Jul 2003 11:57:25 +0000 (GMT) Received: from stan.ringways.co.uk (hub.ringways.co.uk [213.38.87.130]) by svr1.postgresql.org (Postfix) with ESMTP id BC910CC997 for ; Thu, 17 Jul 2003 08:56:58 -0300 (ADT) Received: from gary.ringways.co.uk ([10.1.1.2]) by stan.ringways.co.uk with esmtp (Exim 3.22 #1) id 19d7N9-0001OT-00 for pgsql-sql@postgresql.org; Thu, 17 Jul 2003 12:56:31 +0100 Content-Type: text/plain; charset="us-ascii" From: Gary Stainburn Organization: Ringways Garages Ltd To: pgsql-sql@postgresql.org Subject: unique value - trigger? Date: Thu, 17 Jul 2003 12:56:52 +0100 User-Agent: KMail/1.4.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200307171256.52098.gary.stainburn@ringways.co.uk> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/214 X-Sequence-Number: 14328 Hi folks, I'm back with my lnumbers table again. nymr=# \d lnumbers Table "lnumbers" Column | Type | Modifiers -----------+-----------------------+----------- lnid | integer | not null lnumber | character varying(10) | not null lncurrent | boolean | Primary key: lnumbers_pkey Triggers: RI_ConstraintTrigger_7575462 While each loco can have a number of different numbers, only one can be current at any one time. I want to make it so that if I set lncurrent to true for one row, any existing true rows are set to false. I'm guessing that I need to create a trigger to be actioned after an insert or update which would update set lncurrent=false where lnid not = but I can't seem to sus it put. -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000