Re: Defining Field Types with view - Mailing list pgsql-sql

From Tom Lane
Subject Re: Defining Field Types with view
Date
Msg-id 10958.1094078485@sss.pgh.pa.us
Whole thread Raw
In response to Defining Field Types with view  ("Traci Sumpter" <Traci.Sumpter@opus.co.nz>)
List pgsql-sql
"Traci Sumpter" <Traci.Sumpter@opus.co.nz> writes:
> Cheesy one here....

Got a cheesy answer for you --- cast the result ...

regression=# create view voo as
regression-# select f1::varchar(20) from
regression-# (select f1 from foo union select f2 from foo) ss;
CREATE VIEW
regression=# \d voo            View "public.voo"Column |         Type          | Modifiers 
--------+-----------------------+-----------f1     | character varying(20) | 
View definition:SELECT ss.f1::character varying(20) AS f1  FROM ( SELECT foo.f1          FROM foo
UNION SELECT foo.f2  FROM foo) ss;
        regards, tom lane


pgsql-sql by date:

Previous
From: "Traci Sumpter"
Date:
Subject: Defining Field Types with view
Next
From:
Date:
Subject: copy old column's values to new column