Re: null values in a view

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Lauri Kajan <lauri(dot)kajan(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: null values in a view
Date: 2011-10-05 14:39:14
Message-ID: 19099.1317825554@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message salah jubeh 2011-10-05 14:40:47 Re: how to disable all pkey/fkey constraints globally
Previous Message Dickson S. Guedes 2011-10-05 14:38:32 Re: Restoring 2 Tables From All Databases Backup