Re: null values in a view

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
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:31:47
Message-ID: 20111005143147.GA17199@depesz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Oct 05, 2011 at 05:22:21PM +0300, Lauri Kajan wrote:
> Hi all,
>
> How could I create a view that returns null values among all other values.
> Here is a sample that i want to achieve:
>
> CREATE VIEW view1 AS
> SELECT
> attribute1 as a1,
> null as a2
> FROM
> table;
>
> Now the problem is that I got an warning: column "a2" has type "unknown"
> I know that I should define a data type for a field a2. But how?

using normal cast:
null::text as a2

or cast(null as text);

Best regards,

depesz

--
The best thing about modern society is how easy it is to avoid contact with it.
http://depesz.com/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dickson S. Guedes 2011-10-05 14:38:32 Re: Restoring 2 Tables From All Databases Backup
Previous Message Achilleas Mantzios 2011-10-05 14:30:10 Re: null values in a view