Re: constraint problem

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Martín Marqués <martin(at)bugs(dot)unl(dot)edu(dot)ar>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: constraint problem
Date: 2005-07-26 02:29:53
Message-ID: 20050725192843.L16418@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Mon, 25 Jul 2005, [iso-8859-1] Martín Marqués wrote:

> I have a table with a login, password and confirmed columns (besides others),
> and I'm having so trouble getting this contraint to work.
>
> The account is created with login and password NULL and confirmed set to
> false. Once the user gives the app he's login and password (login is unique)
> the system updates that row with the new login, password and sets confirmed
> to true.
>
> Now to the constraint:
>
> I don't want the login and password columns to have nulls when the account
> (row) is confirmed (confirmed column is set to true).
>
> I tried adding this CONSTRAINT to the table definition, but with no luck:
>
> CONSTRAINT nonuloconfirmado CHECK
> ((login NOT NULL AND password NOT NULL) OR NOT confirmado)
>
> It gives an error on the first NULL.
>
> How can this be solved?

I think you'd want
(login IS NOT NULL AND password IS NOT NULL) OR NOT confirmado

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2005-07-26 02:34:42 Re: constraint problem
Previous Message Martín Marqués 2005-07-25 23:28:32 constraint problem