From: | Jeff Davis <pgsql(at)j-davis(dot)com> |
---|---|
To: | Jeremy Smith <postgres(at)duckwizard(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: PostgreSQL: Question about rules |
Date: | 2006-11-17 02:33:53 |
Message-ID: | 1163730833.4514.11.camel@dogma.v10.wvs |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, 2006-11-16 at 16:58 -0800, Jeremy Smith wrote:
>
> One more thing that would sweeten the deal even further! Not so much
> for sequences, but for other columns with default values:
>
> insert into foo(bar) values(COALESCE(new.bar, DEFAULT))
>
> This doesn't work, because DEFAULT is a language construct that is
> only defined within the immediate scope of the values(...) list. Is
> there any way I can use COALESCE to defer to the table for the default
> value, rather than explicitly specifying it?
>
> I could probably fake this by writing a function to look up the
> default value in pg_attrdef and evaluate it - just want to see if
> there is a built-in function for this (I can't find one). Because it
> would be a lot of work :-)
>
Interesting question. It seems like you're trying to make a default
value for a view that's based on the underlying table's default value.
I think the normal way to do this is to _not_ have a default value on
the underlying table, and instead use the rule to define the default
value. Does that work for you?
Regards,
Jeff Davis
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Davis | 2006-11-17 02:46:02 | explain analyze taking longer than executing the query? |
Previous Message | Gregory S. Williamson | 2006-11-17 01:57:55 | Eliminating bad characters from a database for upgrading from 7.4 to 8.1 |