Search Postgresql Archives

Re: cannot use column references in default expression?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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@xxxxxxxxxxxx


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux