unique value - trigger?

Поиск
Список
Период
Сортировка
От Gary Stainburn
Тема unique value - trigger?
Дата
Msg-id 200307171256.52098.gary.stainburn@ringways.co.uk
обсуждение исходный текст
Ответы Re: unique value - trigger?  (Dmitry Tkach <dmitry@openratings.com>)
Re: unique value - trigger?  (Richard Poole <rp@guests.deus.net>)
Re: unique value - trigger?  (Richard Poole <richard@ruthie.org>)
Список pgsql-sql
Hi folks,

I'm back with my lnumbers table again.

nymr=# \d lnumbers              Table "lnumbers" Column   |         Type          | Modifiers
-----------+-----------------------+-----------lnid      | integer               | not nulllnumber   | character
varying(10)| not nulllncurrent | 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     



В списке pgsql-sql по дате отправления:

Предыдущее
От: Terence Kearns
Дата:
Сообщение: parse error for function def
Следующее
От: BenLaKnet
Дата:
Сообщение: Is it possible to connect to another database