pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gary Stainburn <gary.stainburn@ringways.co.uk>
To: pgsql-sql@postgresql.org
Subject: unique value - trigger?
Date: Thu, 17 Jul 2003 12:56:52 +0100
Message-ID: <200307171256.52098.gary.stainburn@ringways.co.uk> (raw)

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 = <current lnid> 
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     




view thread (6+ messages)  latest in thread

Message-ID: <200307171256.52098.gary.stainburn@ringways.co.uk>
Permalink:  ../200307171256.52098.gary.stainburn@ringways.co.uk/
Also on:    postgresql.org/message-id/200307171256.52098.gary.stainburn@ringways.co.uk

 · 

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: gary.stainburn@ringways.co.uk
  Subject: Re: unique value - trigger?
  In-Reply-To: <200307171256.52098.gary.stainburn@ringways.co.uk>

* 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