From: | "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | "Pedro Doria Meunier" <pdoria(at)netmadeira(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: default value based on select |
Date: | 2008-04-05 10:14:45 |
Message-ID: | 162867790804050314l30a6b2b3x6ee03590bdc512e7@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello
On 05/04/2008, Pedro Doria Meunier <pdoria(at)netmadeira(dot)com> wrote:
> Hi,
>
> Is it possible to have a table's column default value set to some form of
> select?
>
directly no, but you can use function
postgres=# create table a(a integer);
CREATE TABLE
postgres=# create function mx() returns int as $$select max(a) from
a$$ language sql volatile;
CREATE FUNCTION
postgres=# create table b(x integer default mx());
CREATE TABLE
Regards
Pavel Stehule
> e.g. picking another table's value for a given SELECT ... WHERE ...
>
> Already thankful for any insight,
>
> --
> Pedro Doria Meunier
> Ips. da Olaria, Edf. Jardins do Garajau, 4, r/c Y
> 9125-162 Caniço
> Madeira - Portugal
> --------------------------------------------------
> Skype : pdoriam
> Mobile: +351961720188
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Volkan YAZICI | 2008-04-05 10:21:45 | Re: default value based on select |
Previous Message | Pedro Doria Meunier | 2008-04-05 09:56:00 | default value based on select |