Re: Defining Field Types with view

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Traci Sumpter" <Traci(dot)Sumpter(at)opus(dot)co(dot)nz>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Defining Field Types with view
Date: 2004-09-01 22:41:25
Message-ID: 10958.1094078485@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Traci Sumpter" <Traci(dot)Sumpter(at)opus(dot)co(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message ogjunk-pgjedan 2004-09-02 13:16:47 copy old column's values to new column
Previous Message Traci Sumpter 2004-09-01 20:27:14 Defining Field Types with view