Search Postgresql Archives

Re: null values in a view

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

 



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@xxxxxxxxxxxxx> wrote:
> Lauri Kajan <lauri.kajan@xxxxxxxxx> 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
>

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