Re: Views and default values

Поиск
Список
Период
Сортировка
От DaVinci
Тема Re: Views and default values
Дата
Msg-id 20010406132639.A611@fangorn.net
обсуждение исходный текст
Ответ на Views and default values  (DaVinci <bombadil@wanadoo.es>)
Ответы Re: Views and default values  (will trillich <will@serensoft.com>)
Список pgsql-general
On Fri, Apr 06, 2001 at 12:24:09PM +0100, Michael Ansley wrote:
> >>  Data Base:
> >>
> >>      create table foo (
> >>         cod            serial primary key,
> >>         explication    text,
> >>         silly        bool default 't');
> >>
> >>     create view v_foo as
> >>         select * from foo;
> >>
> >>     create rule v_foo_ins as on insert to v_foo do instead
> >>         insert into foo values (
> >>             NEW.cod,
> >>             NEW.explication,
> >>             NEW.silly);
> You should probably have this:
>
> create rule v_foo_ins as on insert to v_foo do instead
>     insert into foo (explication, silly) values (
>         NEW.explication,
>         NEW.silly);
>
> The rule is trying to insert NEW.cod, which is null, into the table.  This
> rule let's the cod field take care of itself.

 That is valid for 'cod' but not for 'silly'. I'd like that if insert value
 is null, then I get default value, but if insert value is not null, this is
 value that is saved.

 Any idea?...

 Thanks.

                                             David

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

Предыдущее
От: "Tim Knowles"
Дата:
Сообщение: ...
Следующее
От: Michael Ansley
Дата:
Сообщение: RE: Views and default values