Re: defaults referencing other columns?
От | Richard Broersma Jr |
---|---|
Тема | Re: defaults referencing other columns? |
Дата | |
Msg-id | 20060904014650.14524.qmail@web31801.mail.mud.yahoo.com обсуждение исходный текст |
Ответ на | defaults referencing other columns? (James Cloos <cloos@jhcloos.com>) |
Ответы |
Re: defaults referencing other columns?
|
Список | pgsql-novice |
> Can a default value reference the value specified for one of the other > columns in the insert? from: http://www.postgresql.org/docs/8.1/interactive/sql-createtable.html 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. The default expression will be used in any insert operation that does not specify a value for the column. If there is no default for a column, then the default is null. > bar TEXT DEFAULT somefunc(id) "The value is any variable-free expression". To me the "id" in somefunc would classify as a variable. The other suggestion to use a Rule might work, however a before insert trigger would diffently work in this case. However, why would you what to to store the text anyway? If you wanted to see it you could still generate "on the fly" with a select statement. select id, somefunc(id) from foo; Regards, Richard Broersma Jr.
В списке pgsql-novice по дате отправления: