Re: cannot use column references in default expression? - Mailing list pgsql-general

From Christophe Pettus
Subject Re: cannot use column references in default expression?
Date
Msg-id 9ECED4D8-B1B4-43F9-A848-1E3DD74A8160@thebuild.com
Whole thread Raw
In response to Re: cannot use column references in default expression?  (Jignesh Shah <jignesh.shah1980@gmail.com>)
List pgsql-general
On May 28, 2010, at 10:41 AM, Jignesh Shah wrote:

> Trigger should be the last solution. This used to be working but I
> think with latest postgresql upgrade, this stopped working. Might be
> someone around here knows whats going on here.

I'm afraid not.  It's never been allowed to have a variable in the
expression for a DEFAULT value.  To quote the manual:

> DEFAULT default_expr
> The DEFAULT clause assigns a default data value for the column whose
> column definition it appears within. The value is any variable-free
> expression (subqueries and cross-references to other columns in the
> current table are not allowed). The data type of the default
> expression must match the data type of the column.
>
A trigger is the appropriate solution in this case.

--
-- Christophe Pettus
    xof@thebuild.com


pgsql-general by date:

Previous
From: Jignesh Shah
Date:
Subject: Re: cannot use column references in default expression?
Next
From: Adrian Klaver
Date:
Subject: Re: cannot use column references in default expression?