Re: Questions concerning check constraints

Поиск
Список
Период
Сортировка
От hubert depesz lubaczewski
Тема Re: Questions concerning check constraints
Дата
Msg-id 20071102113044.GA20336@depesz.com
обсуждение исходный текст
Ответ на Questions concerning check constraints  ("Christian Rengstl" <Christian.Rengstl@klinik.uni-regensburg.de>)
Список pgsql-general
On Fri, Nov 02, 2007 at 10:04:06AM +0100, Christian Rengstl wrote:
> 1) Is it possible to refer to a column in a different table, ie
> entering a value in mytable.x should only be allowed if mytable2.y=1 for
> example? I know that it is possible to use triggers to do that, but I
> think adding a simple check constraint might be simpler.

you would need to make a wrapper function for the actual checking, and
then add check (function(column) = true) or something like this.

> 2) Is it possible to issue custom error messages in case a constraint
> is violated?

if you have function based checks - sure, "raise exception"

depesz

--
quicksil1er: "postgres is excellent, but like any DB it requires a
highly paid DBA.  here's my CV!" :)
http://www.depesz.com/ - blog dla ciebie (i moje CV)

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

Предыдущее
От: Oleg Bartunov
Дата:
Сообщение: Re: Improve Search
Следующее
От: "Filip Rembiałkowski"
Дата:
Сообщение: Re: Calculation for Max_FSM_pages : Any rules of thumb?