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