From: | Lauri Kajan <lauri(dot)kajan(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: null values in a view |
Date: | 2011-10-05 17:43:58 |
Message-ID: | CAKWoFMLYLzPPkV1C8X9wUjcsjvirfNYnNux_ysbRMsg2qk7yiw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
This worked.
Thank you all!
I know the casting is quite basic operation but could this be added to
the CREATE VIEW documentation? Now there is only an example:
CREATE VIEW vista AS SELECT text 'Hello World' AS hello;
The same syntax won't work with other type as Tom wrote.
-Lauri
On Wed, Oct 5, 2011 at 5:39 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Lauri Kajan <lauri(dot)kajan(at)gmail(dot)com> writes:
>> This works with other values but not with nulls:
>
>> CREATE VIEW view1 AS
>> SELECT
>> attribute1 as a1,
>> text null as a2,
>> text 'test' as a3
>> FROM
>> table;
>
> FYI, the syntax typename 'literal' works *only* with string literals,
> not anything else. For any other target you have to write
> CAST(value AS typename) or equivalently value::typename.
> CAST is SQL-standard, :: is a Postgres-ism.
>
> regards, tom lane
>
From | Date | Subject | |
---|---|---|---|
Next Message | Leif Biberg Kristensen | 2011-10-05 18:13:46 | I/O error on data file, can't run backup |
Previous Message | Filip Rembiałkowski | 2011-10-05 16:26:52 | Re: How to create database link and synonym in postgresql 9.0 |