Re: Constraint Problem

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: Constraint Problem
Дата
Msg-id 87u15k3q6u.fsf@stark.dyndns.tv
обсуждение исходный текст
Ответ на Re: Constraint Problem  (Ron St-Pierre <rstpierre@syscor.com>)
Ответы Re: Constraint Problem  (Ron St-Pierre <rstpierre@syscor.com>)
Список pgsql-general
Ron St-Pierre <rstpierre@syscor.com> writes:

>>>>>This is not quite what I need. I need to create a constraint to allow only
>>>>>-one- of
>>>>>   company<->association<->default(=true) value
>>>>>but any number of
>>>>>   company<->association<->default(=false) values

> I then checked::
>     planrrontest=# SELECT * FROM compass WHERE company=23590;
>      compassnid | company | association | ysndefault
>     ------------+---------+-------------+------------
>            7777 |   23590 |           4 | t
>            8038 |   23590 |           2 | t
>            8040 |   23590 |           7 | t
>     (3 rows)
>
> And as you can see company 23590 has three default associations. Any ideas on
> how I can get around this?

But they're all different associations. If you reread your original question
above you'll see that's not what you described. You said you only wanted one
of any <company,association,default> value when default is true.

Try just

create unique index on compass (company) where ysndefault

--
greg

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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Constraint Problem
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: PostgreSQL v7.4 Release Candidate 1