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


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to