Re: null values in a view

From: Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: null values in a view
Date: 2011-10-05 14:30:10
Message-ID: 201110051730.10161.achill@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

try:

CREATE OR REPLACE VIEW view1 AS
SELECT
name as a1,
null::text as a2,
'test'::text as a3
FROM
some_table;

Στις Wednesday 05 October 2011 17:22:21 ο/η Lauri Kajan έγραψε:
> 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?
> 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;
>
>
>
> Thanks
>
> -Lauri Kajan
>

--
Achilleas Mantzios

In response to

Browse pgsql-general by date

  From Date Subject
Next Message hubert depesz lubaczewski 2011-10-05 14:31:47 Re: null values in a view
Previous Message Filip Rembiałkowski 2011-10-05 14:23:17 Re: gaps/overlaps in a time table : current and previous row question