Re: trigger to enforce FK with nulls?

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: trigger to enforce FK with nulls?
Дата
Msg-id 20060412182501.X57788@megazone.bigpanda.com
обсуждение исходный текст
Ответ на trigger to enforce FK with nulls?  (George Young <gry@ll.mit.edu>)
Список pgsql-sql
On Wed, 12 Apr 2006, George Young wrote:

> [PostgreSQL 8.1.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.0.1]
>
> I'm starting to use lots of foreign key constraints to keep my
> data clean.  In one case, however, I need to allow null values
> for the key.  E.g.:
>
> create table opset_steps(opset text, step text, step_num int);
> create table steps(run text, step text, opset text, user text, step_num int);
>
> The constraint on steps should be:
>    steps.(opset,step) must be found in opset_steps.(opset,step) UNLESS steps.opset is null.

The default foreign key case should not error if either steps.opset or
steps.step is null.  If you're seeing something else, can you give a
complete test case?


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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: trigger to enforce FK with nulls?
Следующее
От: ivan marchesini
Дата:
Сообщение: how to solve this problem