Re: lowercase on columnname using view

From: Szymon Guz <mabewlun(at)gmail(dot)com>
To: Chrishelring <christianhelring(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: lowercase on columnname using view
Date: 2012-05-08 11:15:39
Message-ID: CAFjNrYvzVPhS=hYPnomBiuWmzy8oF-3GZQ8BtXn4LeGjN-AfoQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 8 May 2012 13:00, Chrishelring <christianhelring(at)gmail(dot)com> wrote:

> Hi all,
>
> had some help the other day, but now I´m kinda stuck again. :/
>
> I have a table ("virksomhedsdata") with the following columns:
>
> "MI_STYLE" character varying(254),
> "MI_PRINX" integer NOT NULL DEFAULT
> nextval('rk_ois."virksomhedsdata_MI_PRINX_seq"'::regclass),
> "SP_GEOMETRY" geometry,
>
> I would like to make a view so that the columnnames are presented in
> lowercase. I thought that the following would work:
>
> CREATE OR REPLACE VIEW rk_ois.virksomhedsdata AS
> SELECT virksomhedsdata.MI_STYLE AS mi_style, virksomhedsdata.MI_PRINX as
> mi_prinx, virksomhedsdata.SP_GEOMETRY AS sp_geometry
> FROM rk_ois.virksomhedsdata;
>
> But it fails saying that column virksomhedsdata.mi_style does not exist.
>
> What am I doing wrong here?
>
> thanks!
>
> Christian
>
>
If you created the columns like "MI_PRINX", then you need to call them
using "MI_PRINX", not MI_PRINX, because it will be change to lowercase in
the query.

So the proper query should look like this:

CREATE OR REPLACE VIEW rk_ois.virksomhedsdata AS
SELECT
virksomhedsdata."MI_STYLE" AS mi_style,
virksomhedsdata."MI_PRINX" as mi_prinx,
virksomhedsdata."SP_GEOMETRY" AS sp_geometry
FROM rk_ois.virksomhedsdata;

- szymon

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Guillaume Lelarge 2012-05-08 11:17:34 Re: lowercase on columnname using view
Previous Message Chrishelring 2012-05-08 11:00:17 lowercase on columnname using view