From: | DaVinci <bombadil(at)wanadoo(dot)es> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Views and default values |
Date: | 2001-04-06 11:26:39 |
Message-ID: | 20010406132639.A611@fangorn.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Ansley | 2001-04-06 11:50:54 | RE: Views and default values |
Previous Message | Tim Knowles | 2001-04-06 09:44:09 |