Re: Constraint Problem

From: Ron St-Pierre <rstpierre(at)syscor(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Cc: Greg Stark <gsstark(at)mit(dot)edu>
Subject: Re: Constraint Problem
Date: 2003-11-04 19:30:45
Message-ID: 3FA7FE65.5080500@syscor.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Greg Stark wrote:

>Ron St-Pierre <rstpierre(at)syscor(dot)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
>
>

You're right, I was trying to associate the company-association-default
where default=TRUE, when I didn't need the association as part of it at
all. It's working now, thanks. I'll now try to find my way out of
'Monday morning mode'.

Thanks all

Ron

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2003-11-04 19:36:26 Re: PostgreSQL v7.4 Release Candidate 1
Previous Message Martin Marques 2003-11-04 19:30:22 Re: PostgreSQL v7.4 Release Candidate 1