Check constraint problem

Поиск
Список
Период
Сортировка
От Michael Schmidt
Тема Check constraint problem
Дата
Msg-id BAY101-DAV1723B7EA80A6B27D985226A3E20@phx.gbl
обсуждение исходный текст
Ответы Re: Check constraint problem  (Michael Glaesemann <grzm@myrealbox.com>)
Re: Check constraint problem  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
New to PostgreSQL and hoping for some help with a constraint I've been struggling with for a could of days.  The table includes means and standard deviations.  They should either both be null or (mean any value and standard deviation >= 0)
 
The constraint statement:
 
ALTER TABLE "ClinData" ADD CONSTRAINT "Control_Score" CHECK
((("Control_Score_M" IS NULL) AND ("Control_Score_SD" IS NULL) ) OR
(("Control_Score_M" IS NOT NULL) AND ("Control_Score_SD" >= 0.0)))
 
This statement executes okay.  It prevents Control_Score_M of NULL and Control_Score_SD = 1.0 (as it should).  However, it allows Control_Score_M = 1 and Control_Score_SD of NULL (it shouldn't).  Any thoughts about what is wrong.  Thanks!
 
Michael Schmidt 

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

Предыдущее
От: David Pratt
Дата:
Сообщение: Re: Transparent i18n?
Следующее
От: "Marc G. Fournier"
Дата:
Сообщение: Re: [ANNOUNCE] Language to use with SQL database - Number ONE computer