Re: Redefining a column within a view

From: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Schade, Jeffrey *EXTERN*" <JSchade(at)iso(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Redefining a column within a view
Date: 2013-02-22 13:31:15
Message-ID: A737B7A37273E048B164557ADEF4A58B057B6BE3@ntex2010a.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jeffrey Schade wrote:
> We have a table which contains a 3 byte column with datatype CHAR(3) which we want to redefine within
> the view as a CHAR(1) column and a CHAR(2) column. When I code the SUBSTR function the resulting
> column datatype is TEXT. I would like to see the CHAR datatype, is there anything I can do to set the
> proper datatype. The sample view is below:
>
> CREATE OR REPLACE VIEW schema.jeff_view AS
> SELECT col1 ,
> col2,
> Substr(col3,1,1) as col3_part1,
> Substr(col3,2) as col3_part2,
> col4
> FROM schema.jeff_table;

Try:
[...]
Substr(col3,1,1)::char(1) as col3_part1,
Substr(col3,2)::char(2) as col3_part2,
[...]

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Schade, Jeffrey 2013-02-22 13:34:52 Re: Redefining a column within a view
Previous Message Stephen Frost 2013-02-22 13:29:40 Re: PostgreSQL binaries under /usr/lib, why?