Re: Redefining a column within a view

From: "Schade, Jeffrey" <JSchade(at)iso(dot)com>
To: <pgadmin-support(at)postgresql(dot)org>
Subject: Re: Redefining a column within a view
Date: 2013-02-22 14:23:16
Message-ID: DB138660B6B01D458B16F9205C0C263427CFC120@ISOEMAILP3.iso.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

Thanks to Laurenz for providing the answer to my problem:

Try:

[...]

Substr(col3,1,1)::char(1) as col3_part1,

Substr(col3,2)::char(2) as col3_part2,

[...]

Yours,

Laurenz Albe

Jeff

_________________________________________
Jeffrey Schade

Systems Consultant, Technology Engineering

ISO
545 Washington Boulevard
Jersey City, NJ 07310
Voice: (201) 469-3738

FAX: (201) 748-1500
jschade(at)iso(dot)com <mailto:jschade(at)iso(dot)com>

From: pgadmin-support-owner(at)postgresql(dot)org
[mailto:pgadmin-support-owner(at)postgresql(dot)org] On Behalf Of Schade,
Jeffrey
Sent: Friday, February 22, 2013 8:09 AM
To: pgadmin-support(at)postgresql(dot)org
Subject: [pgadmin-support] Redefining a column within a view

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;

Any suggestions would be appreciated.

Jeff

_________________________________________
Jeffrey Schade

Systems Consultant, Technology Engineering

ISO
545 Washington Boulevard
Jersey City, NJ 07310
Voice: (201) 469-3738

FAX: (201) 748-1500
jschade(at)iso(dot)com <mailto:jschade(at)iso(dot)com>

This email is intended for the recipient only. If you are not the
intended recipient please disregard, and do not use the information for
any purpose.

This email is intended for the recipient only. If you are not the intended recipient please disregard, and do not use the information for any purpose.

In response to

Browse pgadmin-support by date

  From Date Subject
Next Message James B. Byrne 2013-02-22 15:37:59 Re: pg admin 92 beta 3 - bug report - row number 19 is out of range 0..18
Previous Message Dave Page 2013-02-22 14:09:22 Re: pg admin 92 beta 3 - bug report - row number 19 is out of range 0..18